pdfium-native 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -41
- package/binding.gyp +27 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/page.d.ts +13 -3
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +22 -3
- package/dist/page.js.map +1 -1
- package/dist/types.d.ts +213 -7
- package/dist/types.d.ts.map +1 -1
- package/lib/index.ts +9 -2
- package/lib/page.ts +22 -4
- package/lib/types.ts +256 -7
- package/package.json +16 -3
- package/scripts/bundle-lib.mjs +24 -3
- package/scripts/download-pdfium.mjs +2 -1
- package/scripts/generate-fixtures.mjs +308 -1
- package/scripts/install.mjs +19 -1
- package/src/annotations_worker.h +274 -0
- package/src/bookmarks_worker.h +162 -0
- package/src/document.h +48 -5
- package/src/form_fields_worker.h +250 -0
- package/src/links_worker.h +158 -0
- package/src/napi_helpers.h +76 -1
- package/src/objects_worker.h +322 -0
- package/src/page.h +62 -9
- package/src/pdfium_addon.cc +93 -17
- package/src/render_worker.h +37 -17
- package/src/search_worker.h +121 -0
- package/src/text_worker.h +69 -0
- package/src/page_workers.h +0 -724
package/README.md
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
# pdfium-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/pdfium-native)
|
|
4
|
+
[](https://nodejs.org)
|
|
5
|
+
[](https://github.com/xonaman/nodejs-pdfium-native/blob/main/LICENSE)
|
|
6
|
+
[]()
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Fast, native PDF rendering and text extraction for Node.js — powered by [PDFium](https://pdfium.googlesource.com/pdfium/), the same engine used in Chromium. Built as a C++ addon with N-API for ABI stability across Node.js versions.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
> Designed for server-side workloads. Non-blocking, fast, and production-ready.
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
npm install pdfium-native
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Prebuilt PDFium binaries are downloaded automatically during install. A C++ compiler is required (Xcode CLI tools on macOS, `build-essential` on Linux, Visual Studio on Windows).
|
|
14
|
-
|
|
15
|
-
## Supported Platforms
|
|
16
|
-
|
|
17
|
-
| OS | Architectures |
|
|
18
|
-
| --------------------- | ---------------------- |
|
|
19
|
-
| macOS | arm64, x64 |
|
|
20
|
-
| Linux (glibc) | x64, arm64, arm, ppc64 |
|
|
21
|
-
| Linux (musl / Alpine) | x64, arm64 |
|
|
22
|
-
| Windows | x64, arm64 |
|
|
23
|
-
|
|
24
|
-
## Quick Start
|
|
12
|
+
## 🚀 Quick Start
|
|
25
13
|
|
|
26
14
|
```typescript
|
|
27
15
|
import { loadDocument } from 'pdfium-native';
|
|
@@ -29,20 +17,76 @@ import { loadDocument } from 'pdfium-native';
|
|
|
29
17
|
const doc = await loadDocument('invoice.pdf');
|
|
30
18
|
const page = await doc.getPage(0);
|
|
31
19
|
|
|
32
|
-
// extract text
|
|
33
20
|
const text = await page.getText();
|
|
34
|
-
|
|
35
|
-
// render to buffer
|
|
36
|
-
const jpeg = await page.render({ scale: 3, format: 'jpeg', quality: 90 });
|
|
37
|
-
|
|
38
|
-
// render to file
|
|
39
|
-
await page.render({ scale: 4, format: 'png', output: 'page-0.png' });
|
|
21
|
+
const image = await page.render({ scale: 3, format: 'png' }); // high-resolution render
|
|
40
22
|
|
|
41
23
|
page.close();
|
|
42
24
|
doc.destroy();
|
|
43
25
|
```
|
|
44
26
|
|
|
45
|
-
##
|
|
27
|
+
## 💡 Why pdfium-native?
|
|
28
|
+
|
|
29
|
+
**⚡ Performance**
|
|
30
|
+
|
|
31
|
+
- Native C++ — no WASM overhead, no JS parsing
|
|
32
|
+
- Non-blocking — all operations run off the main thread via libuv workers
|
|
33
|
+
|
|
34
|
+
**🛠️ Developer experience**
|
|
35
|
+
|
|
36
|
+
- Built-in JPEG/PNG rendering — no extra dependencies like sharp
|
|
37
|
+
- Prebuilt binaries for 10 platform/arch combinations — no compile step
|
|
38
|
+
- Full TypeScript support with types included
|
|
39
|
+
|
|
40
|
+
**🔒 Reliability**
|
|
41
|
+
|
|
42
|
+
- Built on PDFium — the PDF engine used in Chromium
|
|
43
|
+
- ABI-stable via N-API — works across Node.js 18–24 without recompilation
|
|
44
|
+
- Password-protected PDFs supported out of the box
|
|
45
|
+
|
|
46
|
+
### 🎯 Use cases
|
|
47
|
+
|
|
48
|
+
- 🖼️ Generate thumbnails and previews for uploaded PDFs
|
|
49
|
+
- 📄 Extract searchable text from documents at scale
|
|
50
|
+
- ⚙️ Build server-side PDF processing pipelines
|
|
51
|
+
- 🔗 Read annotations, bookmarks, links, and form fields from existing PDFs
|
|
52
|
+
|
|
53
|
+
### 📊 How it compares
|
|
54
|
+
|
|
55
|
+
| | **pdfium-native** | @hyzyla/pdfium | pdfjs-dist |
|
|
56
|
+
| ------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
57
|
+
| Engine | PDFium (C++ addon) | PDFium (WASM) | pdf.js (JS) |
|
|
58
|
+
| Rendering | ✅ JPEG/PNG built-in | ⚠️ Raw bitmap (BYO sharp) | ⚠️ Canvas/browser |
|
|
59
|
+
| Text extraction | ✅ | ❌ | ✅ |
|
|
60
|
+
| Search (with rects) | ✅ | ❌ | ⚠️ Manual |
|
|
61
|
+
| Annotations | ✅ | ❌ | ⚠️ Partial |
|
|
62
|
+
| Bookmarks | ✅ | ❌ | ✅ |
|
|
63
|
+
| Links | ✅ | ❌ | ✅ |
|
|
64
|
+
| Form fields | ✅ | ❌ | ✅ |
|
|
65
|
+
| Async I/O | ✅ libuv workers | ❌ Sync (WASM) | ❌ Main thread |
|
|
66
|
+
| Environment | Node.js | Node.js + browser | Node.js + browser |
|
|
67
|
+
| Dependencies | None¹ | None (WASM bundled) | None |
|
|
68
|
+
| Platforms | macOS / Linux / Windows | Any (WASM) | Any |
|
|
69
|
+
|
|
70
|
+
¹ Prebuilt binaries downloaded at install — no runtime dependencies. Falls back to source compilation if unavailable.
|
|
71
|
+
|
|
72
|
+
## 📦 Install
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install pdfium-native
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Prebuilt binaries are available for all [supported platforms](#supported-platforms) — most installs require no compiler. If no prebuilt is available, the package falls back to compiling from source (requires a C++ toolchain: Xcode CLI tools on macOS, `build-essential` on Linux, Visual Studio on Windows).
|
|
79
|
+
|
|
80
|
+
## 🌍 Supported Platforms
|
|
81
|
+
|
|
82
|
+
| OS | Architectures |
|
|
83
|
+
| --------------------- | ---------------------- |
|
|
84
|
+
| macOS | arm64, x64 |
|
|
85
|
+
| Linux (glibc) | x64, arm64, arm, ppc64 |
|
|
86
|
+
| Linux (musl / Alpine) | x64, arm64 |
|
|
87
|
+
| Windows | x64, arm64 |
|
|
88
|
+
|
|
89
|
+
## 📚 API
|
|
46
90
|
|
|
47
91
|
### `loadDocument(input, password?)`
|
|
48
92
|
|
|
@@ -86,6 +130,12 @@ Returns the bookmark/outline tree. Returns `Promise<Bookmark[]>`.
|
|
|
86
130
|
interface Bookmark {
|
|
87
131
|
title: string;
|
|
88
132
|
pageIndex?: number;
|
|
133
|
+
open: boolean; // whether the node is initially expanded
|
|
134
|
+
actionType?: 'goto' | 'remoteGoto' | 'uri' | 'launch' | 'embeddedGoto';
|
|
135
|
+
url?: string; // external URL for URI bookmarks
|
|
136
|
+
destX?: number; // destination X coordinate
|
|
137
|
+
destY?: number; // destination Y coordinate
|
|
138
|
+
destZoom?: number; // destination zoom level
|
|
89
139
|
children?: Bookmark[];
|
|
90
140
|
}
|
|
91
141
|
```
|
|
@@ -98,13 +148,17 @@ Closes the document and frees all native resources. Must be called when done.
|
|
|
98
148
|
|
|
99
149
|
### PDFiumPage
|
|
100
150
|
|
|
101
|
-
| Property
|
|
102
|
-
|
|
|
103
|
-
| `width`
|
|
104
|
-
| `height`
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
151
|
+
| Property | Type | Description |
|
|
152
|
+
| ----------------- | ------------------- | --------------------------------------------------- |
|
|
153
|
+
| `width` | `number` | Page width in points (1 pt = 1/72 inch). |
|
|
154
|
+
| `height` | `number` | Page height in points. |
|
|
155
|
+
| `number` | `number` | 0-based page index. |
|
|
156
|
+
| `objectCount` | `number` | Number of page objects (text, images, paths, etc.). |
|
|
157
|
+
| `rotation` | `number` | Page rotation: 0, 1 (90° CW), 2 (180°), 3 (270°). |
|
|
158
|
+
| `hasTransparency` | `boolean` | Whether the page has transparency. |
|
|
159
|
+
| `label` | `string?` | Page label (e.g. 'i', 'ii', '1'). |
|
|
160
|
+
| `cropBox` | `PageObjectBounds?` | Crop box (visible region), if set. |
|
|
161
|
+
| `trimBox` | `PageObjectBounds?` | Trim box (intended finished size), if set. |
|
|
108
162
|
|
|
109
163
|
#### `getText()`
|
|
110
164
|
|
|
@@ -122,6 +176,11 @@ interface PageRenderOptions {
|
|
|
122
176
|
format?: 'jpeg' | 'png'; // default: 'jpeg'
|
|
123
177
|
quality?: number; // JPEG quality 1–100 (default: 100)
|
|
124
178
|
output?: string; // write to file instead of returning a Buffer
|
|
179
|
+
rotation?: 0 | 1 | 2 | 3; // 0=none, 1=90° CW, 2=180°, 3=270° CW
|
|
180
|
+
transparent?: boolean; // transparent background (PNG only, default: false)
|
|
181
|
+
renderAnnotations?: boolean; // render annotations (default: true)
|
|
182
|
+
grayscale?: boolean; // render in grayscale
|
|
183
|
+
lcdText?: boolean; // LCD-optimized sub-pixel text rendering
|
|
125
184
|
}
|
|
126
185
|
```
|
|
127
186
|
|
|
@@ -137,8 +196,10 @@ type PageObject = TextPageObject | ImagePageObject | OtherPageObject;
|
|
|
137
196
|
// fillColor: { r, g, b, a } | null
|
|
138
197
|
// strokeColor: { r, g, b, a } | null
|
|
139
198
|
|
|
140
|
-
// type: 'text' adds: text, fontSize, fontName
|
|
141
|
-
//
|
|
199
|
+
// type: 'text' adds: text, fontSize, fontName, fontWeight?, italicAngle?,
|
|
200
|
+
// renderMode?, fontFamily?, isEmbedded?, fontFlags?
|
|
201
|
+
// type: 'image' adds: imageWidth, imageHeight, horizontalDpi?, verticalDpi?,
|
|
202
|
+
// bitsPerPixel?, colorspace?, filters?
|
|
142
203
|
// type: 'path' | 'shading' | 'form' | 'unknown'
|
|
143
204
|
```
|
|
144
205
|
|
|
@@ -151,6 +212,11 @@ interface Link {
|
|
|
151
212
|
bounds?: { left; bottom; right; top };
|
|
152
213
|
url?: string; // external URL
|
|
153
214
|
pageIndex?: number; // internal link target
|
|
215
|
+
actionType?: 'goto' | 'remoteGoto' | 'uri' | 'launch' | 'embeddedGoto' | 'unknown';
|
|
216
|
+
destX?: number; // destination X coordinate
|
|
217
|
+
destY?: number; // destination Y coordinate
|
|
218
|
+
destZoom?: number; // destination zoom level
|
|
219
|
+
filePath?: string; // file path for remote goto / launch actions
|
|
154
220
|
}
|
|
155
221
|
```
|
|
156
222
|
|
|
@@ -159,8 +225,12 @@ interface Link {
|
|
|
159
225
|
Searches for text on the page. Returns `Promise<SearchMatch[]>` with character positions and bounding rectangles.
|
|
160
226
|
|
|
161
227
|
```typescript
|
|
162
|
-
const matches = await page.search('invoice', {
|
|
163
|
-
|
|
228
|
+
const matches = await page.search('invoice', {
|
|
229
|
+
caseSensitive: true,
|
|
230
|
+
wholeWord: false,
|
|
231
|
+
consecutive: false,
|
|
232
|
+
});
|
|
233
|
+
// [{ charIndex: 42, length: 7, matchedText: 'invoice', rects: [{ left, top, right, bottom }] }]
|
|
164
234
|
```
|
|
165
235
|
|
|
166
236
|
#### `getAnnotations()`
|
|
@@ -173,9 +243,54 @@ interface Annotation {
|
|
|
173
243
|
bounds?: { left; bottom; right; top };
|
|
174
244
|
contents: string;
|
|
175
245
|
color: { r; g; b; a } | null;
|
|
246
|
+
interiorColor?: { r; g; b; a }; // fill color for markup annotations
|
|
247
|
+
author: string; // annotation author
|
|
248
|
+
subject: string; // annotation subject
|
|
249
|
+
creationDate: string; // PDF date string (e.g. "D:20250101120000Z")
|
|
250
|
+
modDate: string; // modification date
|
|
251
|
+
flags: number; // annotation flags bitmask (PDF spec Table 165)
|
|
252
|
+
border?: { horizontalRadius; verticalRadius; width };
|
|
253
|
+
quadPoints?: Array<{ x1; y1; x2; y2; x3; y3; x4; y4 }>;
|
|
176
254
|
}
|
|
177
255
|
```
|
|
178
256
|
|
|
257
|
+
#### `getFormFields()`
|
|
258
|
+
|
|
259
|
+
Returns all form fields on the page. Returns `Promise<FormField[]>`.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
interface FormField {
|
|
263
|
+
type:
|
|
264
|
+
| 'unknown'
|
|
265
|
+
| 'pushButton'
|
|
266
|
+
| 'checkbox'
|
|
267
|
+
| 'radioButton'
|
|
268
|
+
| 'comboBox'
|
|
269
|
+
| 'listBox'
|
|
270
|
+
| 'textField'
|
|
271
|
+
| 'signature';
|
|
272
|
+
name: string; // field name
|
|
273
|
+
value: string; // current value
|
|
274
|
+
alternateName?: string; // tooltip / alternate field name
|
|
275
|
+
exportValue?: string; // export value (checkboxes / radio buttons)
|
|
276
|
+
flags: number; // field flags bitmask
|
|
277
|
+
bounds?: { left; bottom; right; top };
|
|
278
|
+
isChecked: boolean; // whether checkbox / radio is checked
|
|
279
|
+
options?: FormFieldOption[]; // options for combo box / list box
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
interface FormFieldOption {
|
|
283
|
+
label: string;
|
|
284
|
+
isSelected: boolean;
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
const fields = await page.getFormFields();
|
|
290
|
+
const textFields = fields.filter((f) => f.type === 'textField');
|
|
291
|
+
const checked = fields.filter((f) => f.isChecked);
|
|
292
|
+
```
|
|
293
|
+
|
|
179
294
|
#### `close()`
|
|
180
295
|
|
|
181
296
|
Closes the page and frees resources. Must be called when done with the page.
|
|
@@ -195,16 +310,32 @@ interface DocumentMetadata {
|
|
|
195
310
|
creationDate: string;
|
|
196
311
|
modDate: string;
|
|
197
312
|
pdfVersion: number; // e.g. 17 for PDF 1.7
|
|
313
|
+
permissions: {
|
|
314
|
+
print: boolean;
|
|
315
|
+
modify: boolean;
|
|
316
|
+
copy: boolean;
|
|
317
|
+
annotate: boolean;
|
|
318
|
+
fillForms: boolean;
|
|
319
|
+
extractForAccessibility: boolean;
|
|
320
|
+
assemble: boolean;
|
|
321
|
+
printHighQuality: boolean;
|
|
322
|
+
};
|
|
323
|
+
isTagged: boolean; // whether the PDF is a tagged PDF
|
|
324
|
+
language: string; // document language (e.g. 'en-US')
|
|
325
|
+
signatureCount: number; // number of digital signatures
|
|
326
|
+
attachmentCount: number; // number of file attachments
|
|
327
|
+
permanentId?: string; // permanent file identifier (hex)
|
|
328
|
+
changingId?: string; // changing file identifier (hex)
|
|
198
329
|
}
|
|
199
330
|
```
|
|
200
331
|
|
|
201
332
|
---
|
|
202
333
|
|
|
203
|
-
## Acknowledgements
|
|
334
|
+
## 🙏 Acknowledgements
|
|
204
335
|
|
|
205
336
|
This project uses prebuilt PDFium binaries from [bblanchon/pdfium-binaries](https://github.com/bblanchon/pdfium-binaries), which provides automated builds of the PDFium library for multiple platforms. Thanks to [@bblanchon](https://github.com/bblanchon) for maintaining this invaluable resource.
|
|
206
337
|
|
|
207
|
-
## Memory Management
|
|
338
|
+
## 🧹 Memory Management
|
|
208
339
|
|
|
209
340
|
Always call `page.close()` and `doc.destroy()` when done. While GC-triggered destructor hooks exist as a safety net, they should not be relied on — explicit cleanup ensures resources are freed promptly.
|
|
210
341
|
|
|
@@ -222,6 +353,6 @@ try {
|
|
|
222
353
|
}
|
|
223
354
|
```
|
|
224
355
|
|
|
225
|
-
## License
|
|
356
|
+
## 📄 License
|
|
226
357
|
|
|
227
358
|
MIT
|
package/binding.gyp
CHANGED
|
@@ -17,11 +17,18 @@
|
|
|
17
17
|
"cflags!": [
|
|
18
18
|
"-fno-exceptions"
|
|
19
19
|
],
|
|
20
|
+
"cflags": [
|
|
21
|
+
"-Os",
|
|
22
|
+
"-flto",
|
|
23
|
+
"-ffunction-sections",
|
|
24
|
+
"-fdata-sections"
|
|
25
|
+
],
|
|
20
26
|
"cflags_cc!": [
|
|
21
27
|
"-fno-exceptions"
|
|
22
28
|
],
|
|
23
29
|
"cflags_cc": [
|
|
24
|
-
"-std=c++17"
|
|
30
|
+
"-std=c++17",
|
|
31
|
+
"-fvisibility=hidden"
|
|
25
32
|
],
|
|
26
33
|
"conditions": [
|
|
27
34
|
[
|
|
@@ -30,10 +37,21 @@
|
|
|
30
37
|
"xcode_settings": {
|
|
31
38
|
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
32
39
|
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
|
|
40
|
+
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES",
|
|
41
|
+
"DEAD_CODE_STRIPPING": "YES",
|
|
42
|
+
"LLVM_LTO": "YES",
|
|
43
|
+
"OTHER_CPLUSPLUSFLAGS": [
|
|
44
|
+
"-Os",
|
|
45
|
+
"-ffunction-sections",
|
|
46
|
+
"-fdata-sections"
|
|
47
|
+
],
|
|
33
48
|
"OTHER_LDFLAGS": [
|
|
34
49
|
"-L<(module_root_dir)/deps/pdfium/lib",
|
|
35
50
|
"-lpdfium",
|
|
36
51
|
"-Wl,-rpath,@loader_path",
|
|
52
|
+
"-Wl,-dead_strip",
|
|
53
|
+
"-Wl,-S",
|
|
54
|
+
"-flto",
|
|
37
55
|
"-framework CoreFoundation",
|
|
38
56
|
"-framework CoreGraphics"
|
|
39
57
|
]
|
|
@@ -47,6 +65,9 @@
|
|
|
47
65
|
"-L<(module_root_dir)/deps/pdfium/lib",
|
|
48
66
|
"-lpdfium",
|
|
49
67
|
"-Wl,-rpath,'$$ORIGIN'",
|
|
68
|
+
"-Wl,--gc-sections",
|
|
69
|
+
"-Wl,-S",
|
|
70
|
+
"-flto",
|
|
50
71
|
"-lpthread",
|
|
51
72
|
"-ldl"
|
|
52
73
|
]
|
|
@@ -61,9 +82,14 @@
|
|
|
61
82
|
"msvs_settings": {
|
|
62
83
|
"VCCLCompilerTool": {
|
|
63
84
|
"ExceptionHandling": 1,
|
|
85
|
+
"Optimization": 1,
|
|
86
|
+
"WholeProgramOptimization": "true",
|
|
64
87
|
"AdditionalOptions": [
|
|
65
88
|
"/std:c++17"
|
|
66
89
|
]
|
|
90
|
+
},
|
|
91
|
+
"VCLinkerTool": {
|
|
92
|
+
"LinkTimeCodeGeneration": 1
|
|
67
93
|
}
|
|
68
94
|
},
|
|
69
95
|
"libraries": [
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare function loadDocument(input: PdfInput, password?: string): Promis
|
|
|
7
7
|
export { PDFiumDocument } from './document.js';
|
|
8
8
|
export { PDFiumError, PDFiumFileError, PDFiumFormatError, PDFiumPasswordError, PDFiumSecurityError, } from './errors.js';
|
|
9
9
|
export { PDFiumPage } from './page.js';
|
|
10
|
-
export type { Annotation, AnnotationType, Bookmark, DocumentMetadata, ImagePageObject, Link, OtherPageObject, PageObject, PageObjectBounds,
|
|
10
|
+
export type { Annotation, AnnotationBorder, AnnotationType, Bookmark, DocumentMetadata, DocumentPermissions, FormField, FormFieldOption, FormFieldType, ImageColorspace, ImagePageObject, Link, LinkActionType, OtherPageObject, PageObject, PageObjectBounds, PageRenderOptions, QuadPoints, RGBA, SearchMatch, SearchOptions, SearchRect, TextPageObject, TextRenderMode, } from './types.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO/C,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAchC;;GAEG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAM9F;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EACV,UAAU,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO/C,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAchC;;GAEG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAM9F;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,IAAI,EACJ,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,WAAW,EACX,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Annotation, Link, NativePage, PageObject,
|
|
1
|
+
import type { Annotation, FormField, Link, NativePage, PageObject, PageObjectBounds, PageRenderOptions, SearchMatch, SearchOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* A page in a PDF document.
|
|
4
4
|
*/
|
|
@@ -8,12 +8,20 @@ export declare class PDFiumPage {
|
|
|
8
8
|
readonly width: number;
|
|
9
9
|
/** Page height in points (1 pt = 1/72 inch). */
|
|
10
10
|
readonly height: number;
|
|
11
|
-
/** Page dimensions in points. */
|
|
12
|
-
readonly size: PageSize;
|
|
13
11
|
/** 0-based page index. */
|
|
14
12
|
readonly number: number;
|
|
15
13
|
/** Number of page objects (text spans, paths, images, etc.). */
|
|
16
14
|
readonly objectCount: number;
|
|
15
|
+
/** Page rotation: 0 = none, 1 = 90° CW, 2 = 180°, 3 = 270° CW. */
|
|
16
|
+
readonly rotation: number;
|
|
17
|
+
/** Whether the page has transparency. */
|
|
18
|
+
readonly hasTransparency: boolean;
|
|
19
|
+
/** Page label (e.g. 'i', 'ii', '1', '2'). Only set if the document defines page labels. */
|
|
20
|
+
readonly label?: string;
|
|
21
|
+
/** Crop box (visible region), if explicitly set. */
|
|
22
|
+
readonly cropBox?: PageObjectBounds;
|
|
23
|
+
/** Trim box (intended finished page size), if explicitly set. */
|
|
24
|
+
readonly trimBox?: PageObjectBounds;
|
|
17
25
|
/** @internal */
|
|
18
26
|
constructor(native: NativePage);
|
|
19
27
|
/** Extracts all text from the page. */
|
|
@@ -36,5 +44,7 @@ export declare class PDFiumPage {
|
|
|
36
44
|
search(text: string, options?: SearchOptions): Promise<SearchMatch[]>;
|
|
37
45
|
/** Returns all annotations on the page. */
|
|
38
46
|
getAnnotations(): Promise<Annotation[]>;
|
|
47
|
+
/** Returns all form fields on the page. */
|
|
48
|
+
getFormFields(): Promise<FormField[]>;
|
|
39
49
|
}
|
|
40
50
|
//# sourceMappingURL=page.d.ts.map
|
package/dist/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../lib/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../lib/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,UAAU;IAqBT,OAAO,CAAC,MAAM;IApB1B,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAEpC,gBAAgB;gBACI,MAAM,EAAE,UAAU;IAYtC,uCAAuC;IACvC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B,kCAAkC;IAClC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IACtE,iEAAiE;IACjE,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAKpD,uEAAuE;IACvE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7C,wEAAwE;IACjE,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC;IAM5C,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAIb,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAI3B,wFAAwF;IACxF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAIrE,2CAA2C;IAC3C,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAIvC,2CAA2C;IAC3C,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAGtC"}
|
package/dist/page.js
CHANGED
|
@@ -7,20 +7,35 @@ export class PDFiumPage {
|
|
|
7
7
|
width;
|
|
8
8
|
/** Page height in points (1 pt = 1/72 inch). */
|
|
9
9
|
height;
|
|
10
|
-
/** Page dimensions in points. */
|
|
11
|
-
size;
|
|
12
10
|
/** 0-based page index. */
|
|
13
11
|
number;
|
|
14
12
|
/** Number of page objects (text spans, paths, images, etc.). */
|
|
15
13
|
objectCount;
|
|
14
|
+
/** Page rotation: 0 = none, 1 = 90° CW, 2 = 180°, 3 = 270° CW. */
|
|
15
|
+
rotation;
|
|
16
|
+
/** Whether the page has transparency. */
|
|
17
|
+
hasTransparency;
|
|
18
|
+
/** Page label (e.g. 'i', 'ii', '1', '2'). Only set if the document defines page labels. */
|
|
19
|
+
label;
|
|
20
|
+
/** Crop box (visible region), if explicitly set. */
|
|
21
|
+
cropBox;
|
|
22
|
+
/** Trim box (intended finished page size), if explicitly set. */
|
|
23
|
+
trimBox;
|
|
16
24
|
/** @internal */
|
|
17
25
|
constructor(native) {
|
|
18
26
|
this.native = native;
|
|
19
27
|
this.width = native.width;
|
|
20
28
|
this.height = native.height;
|
|
21
|
-
this.size = native.size;
|
|
22
29
|
this.number = native.number;
|
|
23
30
|
this.objectCount = native.objectCount;
|
|
31
|
+
this.rotation = native.rotation;
|
|
32
|
+
this.hasTransparency = native.hasTransparency;
|
|
33
|
+
if (native.label !== undefined)
|
|
34
|
+
this.label = native.label;
|
|
35
|
+
if (native.cropBox !== undefined)
|
|
36
|
+
this.cropBox = native.cropBox;
|
|
37
|
+
if (native.trimBox !== undefined)
|
|
38
|
+
this.trimBox = native.trimBox;
|
|
24
39
|
}
|
|
25
40
|
/** Extracts all text from the page. */
|
|
26
41
|
getText() {
|
|
@@ -55,5 +70,9 @@ export class PDFiumPage {
|
|
|
55
70
|
getAnnotations() {
|
|
56
71
|
return this.native.getAnnotations();
|
|
57
72
|
}
|
|
73
|
+
/** Returns all form fields on the page. */
|
|
74
|
+
getFormFields() {
|
|
75
|
+
return this.native.getFormFields();
|
|
76
|
+
}
|
|
58
77
|
}
|
|
59
78
|
//# sourceMappingURL=page.js.map
|
package/dist/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../lib/page.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../lib/page.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,OAAO,UAAU;IAqBD;IApBpB,+CAA+C;IACtC,KAAK,CAAS;IACvB,gDAAgD;IACvC,MAAM,CAAS;IACxB,0BAA0B;IACjB,MAAM,CAAS;IACxB,gEAAgE;IACvD,WAAW,CAAS;IAC7B,kEAAkE;IACzD,QAAQ,CAAS;IAC1B,yCAAyC;IAChC,eAAe,CAAU;IAClC,2FAA2F;IAClF,KAAK,CAAU;IACxB,oDAAoD;IAC3C,OAAO,CAAoB;IACpC,iEAAiE;IACxD,OAAO,CAAoB;IAEpC,gBAAgB;IAChB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QACpC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC9C,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1D,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAChE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClE,CAAC;IAED,uCAAuC;IACvC,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAMD,MAAM,CAAC,OAA2B;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,uEAAuE;IACvE,SAAS,CAAC,KAAa;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,CAAC,OAAO;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,2CAA2C;IAC3C,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,qCAAqC;IACrC,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAED,wFAAwF;IACxF,MAAM,CAAC,IAAY,EAAE,OAAuB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,2CAA2C;IAC3C,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IACtC,CAAC;IAED,2CAA2C;IAC3C,aAAa;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;CACF"}
|