pdfium-native 0.9.1 → 0.11.0
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/CHANGELOG.md +33 -1
- package/README.md +90 -12
- package/dist/document.d.ts +62 -3
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +64 -0
- package/dist/document.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/page.d.ts +25 -4
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +23 -2
- package/dist/page.js.map +1 -1
- package/dist/types.d.ts +52 -7
- package/dist/types.d.ts.map +1 -1
- package/lib/document.ts +68 -3
- package/lib/index.ts +2 -0
- package/lib/page.ts +25 -4
- package/lib/types.ts +55 -7
- package/package.json +4 -4
- package/scripts/generate-fixtures.mjs +304 -3
- package/scripts/native-deps.json +11 -11
- package/scripts/prebuilds.json +10 -10
- package/src/annotations_worker.h +21 -1
- package/src/attachments_worker.h +43 -4
- package/src/destinations_worker.h +146 -43
- package/src/document.h +27 -0
- package/src/form_fields_worker.h +23 -1
- package/src/javascript_worker.h +18 -1
- package/src/objects_worker.h +192 -108
- package/src/pdfium_addon.cc +10 -0
- package/src/signatures_worker.h +24 -1
- package/src/structtree_worker.h +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,36 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.11.0] - 2026-11-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `objects` on a form page object: the page objects a form XObject draws, in drawing order, nested forms with their own `objects` and bounds mapped to page coordinates through every form matrix (`FPDFFormObj_CountObjects` / `FPDFFormObj_GetObject` / `FPDFPageObj_GetMatrix`). PDFium lists only the form itself on the page, so for a producer that draws the whole page inside one form — some retailers' e-receipts do — `objects()` showed a single opaque box while `getText()` returned all of its text, and nothing could tell its text objects, their render modes or the images beside them from a scanned picture wrapped the same way. An image inside a form carries no `render()`, since `renderImage()` addresses page-level objects by index. The walk is bounded at 32 levels of nested forms and 20,000 objects per call, and sets `objectsTruncated: true` where it stops, so a crafted file cannot make it allocate without limit while it holds the global PDFium mutex. Pinned by new `form-xobjects.pdf` and `form-depth-bomb.pdf` fixtures. `OtherPageObject` no longer includes `'form'`; form objects are the new `FormPageObject`, and `NestedPageObject` types what `objects` holds.
|
|
14
|
+
- `getNamedDestination(name)` on `PDFiumDocument`, resolving a single anchor by name and returning `null` when the document carries none with that name. It exists because `getNamedDestinations()` cannot always enumerate what the document declares: `FPDF_GetNamedDest` resolves an index below the `/Names /Dests` name-tree count through the tree, which dereferences indirect objects, and lets the rest fall through to the legacy catalog `/Dests` dictionary, which does not — so a legal entry whose value is an indirect reference (ISO 32000-1 allows one wherever a direct object is allowed) is counted by `FPDF_CountNamedDests` and then yields nothing. Not a destination, and not a name either: the in/out buffer length is left at zero, which is why such an entry cannot be surfaced as a `null` the way the other counted listings surface theirs. `FPDF_GetNamedDestByName` searches both stores and dereferences in either, so it resolves exactly the destinations the listing drops. Resolving the `#Chapter2` of an incoming link is the stated use of this part of the API, and for such a document the listing previously returned nothing to match the name against. Pinned by a new `indirect-legacy-dests.pdf` fixture whose three legacy entries are counted and unlistable while its one name-tree entry lists normally.
|
|
15
|
+
- `metadata.namedDestinationCount`, the `FPDF_CountNamedDests` total. `getNamedDestinations()` is the one listing in the library that can come back shorter than its own count, and nothing previously exposed the count, so the shortfall was invisible — the same silent-drop shape as [#34](https://github.com/xonaman/nodejs-pdfium-native/issues/34), which the fix for that issue could not reach here because there is no index to hang a `null` on. A caller can now compare `getNamedDestinations().length` against it and fall back to `getNamedDestination(name)`.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- `getAttachments()` silently dropped an embedded file that failed to load, contradicting `metadata.attachmentCount` with no way for a caller to tell ([#34](https://github.com/xonaman/nodejs-pdfium-native/issues/34)). Both numbers come from the same `FPDFDoc_GetAttachmentCount` call, but the count only sums the slots in the `/EmbeddedFiles` name tree while `FPDFDoc_GetAttachment` resolves each one and is documented to return `NULL` _on failure_ — so a filespec reference pointing at a missing object is counted and does not load. The loop mapped that onto `continue`, which is the same outcome as the attachment not existing: a document reporting `attachmentCount: 1` came back from `getAttachments()` as `[]`. That is the dangerous direction to be wrong in, because an empty array reads as "safe to proceed" — `splitDocument()` and `mergeDocuments()` discard the embedded-files tree, so a caller checking for attachments before splitting would destroy the file it was checking for, and for a PDF/A-3 e-invoice the embedded XML is usually the only machine-readable copy. The failed index is now reported as a `null` entry, so the array length always matches the count and array position is the document index. Pinned by a new `damaged-attachment.pdf` fixture. Note the sibling `getAttachment(index)` already rejected for the same index, so the list path was inconsistent with the read path.
|
|
20
|
+
- The same skip-on-`NULL` shape was silently losing entries in three more listings, each now reporting a `null` the same way, each with its own damaged fixture: `getAnnotations()` (`dangling-annotation.pdf`), `getJavaScriptActions()` (`dangling-javascript.pdf`) and `getFormFields()` (`damaged-widget.pdf`). `getFormFields()` is the awkward one: it is a filtered subset — only widget annotations are form fields — and the subtype is readable only through the handle that failed, so an unloadable annotation cannot be ruled out as a non-widget. Dropping it let a damaged widget pass for a page that simply has fewer fields; reporting it means a `null` there says "a form field _may_ be missing", and the fixture deliberately damages one widget and one plain annotation so that the indistinguishability is exercised rather than merely documented. Since that listing carries no index, `getAnnotations()` on the same page reports the identical failure at its true index.
|
|
21
|
+
- `getSignatures()` got the same treatment for consistency with its twin, though no document was found that reaches it. Thirteen damage shapes were tried and `metadata.signatureCount` and the array length moved in lockstep every time; both entry points appear to derive from the same collection of signature dictionaries. This one is defensive against the documented `"NULL on failure"` contract and a bundled PDFium that gets bumped, not a fix for observed loss — and is consequently the one site with no regression test.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **Breaking (types).** The five listing methods above now return `(T | null)[]` rather than `T[]`. Nothing changes at runtime for a well-formed document — every entry is non-`null`, and every existing fixture produces identical results — but under `strictNullChecks` the compiler will flag call sites that assumed success. That is the point: the previous behaviour was invisible by construction, and a flag or a side-channel count would have been just as ignorable as the silent drop it replaced. Use `a?.name`, or filter with `(a) => a !== null` where a `null` is genuinely acceptable.
|
|
26
|
+
- A `null` is only reported once PDFium has counted the entry, so damage severe enough to break the count is still invisible: an `/EmbeddedFiles` name tree that fails to parse at all reports `attachmentCount: 0` and an empty array, indistinguishable from a document with no embedded files. This is the scope the issue itself set, and it is now stated in the README rather than left implicit. For the page-level listings the trigger is also narrower than "damage" — `FPDFPage_GetAnnot` returns `NULL` for an explicit PDF null object left in an `/Annots` array, which is legal and something some producers emit after deleting an annotation.
|
|
27
|
+
- Three neighbouring `NULL` skips were deliberately **not** converted, and each now carries a comment saying why. `FPDF_StructElement_GetChildAtIndex` returns `NULL` for a child that is a content reference rather than an element, which the code already documented. `FPDF_StructTree_GetChildAtIndex` turns out to do the same for a top-level element belonging to a **different page** — the count is document-wide while `getStructTree()` walks one page — so a document with one `/Part` per chapter yields a `NULL` for every chapter that is not the current one; the existing fixtures hid this because one is single-root and the other untagged. `getNamedDestinations()` was converted and then reverted after review: `FPDF_GetNamedDest` resolves indices below the `/Names /Dests` name-tree count through the tree, which dereferences indirect objects, and lets the rest fall through to the legacy catalog `/Dests` dictionary, which does not, while `FPDF_CountNamedDests` counts every legacy key regardless — so a legal entry whose value is an indirect reference to a destination array is counted, returns `NULL`, and would have been reported as damage. A three-entry legacy `/Dests` dictionary with indirect values came back `[null, null, null]` while PDFium resolved all three correctly through its own name lookup. PDFium exposes no way to ask for the name-tree count alone, so the two cases cannot be told apart at that call site. `getNamedDestinations()` keeps its `NamedDestination[]` type and its existing drop behaviour.
|
|
28
|
+
|
|
29
|
+
## [0.10.0] - 2026-09-22
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- `Attachment.afRelationship` on `getAttachments()`: the `/AFRelationship` entry (PDF 2.0, ISO 32000-2:2020 Table 43) states an embedded file's _role_ rather than its type — a ZUGFeRD / Factur-X e-invoice marks the machine-readable invoice XML `Alternative` and a human-readable companion `Supplement`, alongside `Source`, `Data` and `Unspecified`. Without it a reader had to guess which attachment was the invoice from its file name. The key is absent when the PDF omits the entry; PDFium reports "absent" and "present but not a name" identically, so neither is surfaced as `''`. `addAttachments()` still cannot set it — the entry sits on the file-specification dictionary, which the write path does not build — so attachments written by this library report no value.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Bumped the bundled PDFium to `chromium/8066` (156.0.8066.0) from `chromium/7920`. This is the first build carrying `FPDFAttachment_GetAFRelationship()`, the API behind `Attachment.afRelationship`, which this project contributed upstream ([pdfium CL 154470](https://pdfium-review.googlesource.com/c/pdfium/+/154470)).
|
|
38
|
+
|
|
9
39
|
## [0.9.1] - 2026-08-07
|
|
10
40
|
|
|
11
41
|
Fixes for defects found by an adversarial audit of the 0.9.0 release. Every item
|
|
@@ -347,7 +377,9 @@ now pinned by a regression test.
|
|
|
347
377
|
- GitHub Actions publish workflow with test gate
|
|
348
378
|
- TypeScript type declarations for JS consumers
|
|
349
379
|
|
|
350
|
-
[Unreleased]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.
|
|
380
|
+
[Unreleased]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.11.0...HEAD
|
|
381
|
+
[0.11.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.10.0...v0.11.0
|
|
382
|
+
[0.10.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.9.1...v0.10.0
|
|
351
383
|
[0.9.1]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.9.0...v0.9.1
|
|
352
384
|
[0.9.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.8.0...v0.9.0
|
|
353
385
|
[0.8.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.7.0...v0.8.0
|
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ doc.destroy();
|
|
|
83
83
|
- [Install](#-install)
|
|
84
84
|
- [Supported Platforms](#-supported-platforms)
|
|
85
85
|
- [API](#-api)
|
|
86
|
+
- [Unloadable entries](#unloadable-entries)
|
|
86
87
|
- [loadDocument](#loaddocumentinput-password)
|
|
87
88
|
- [splitDocument](#splitdocumentinput-splitat-options)
|
|
88
89
|
- [mergeDocuments](#mergedocumentsinputs-options)
|
|
@@ -117,6 +118,44 @@ Prebuilt binaries are available for all [supported platforms](#-supported-platfo
|
|
|
117
118
|
|
|
118
119
|
## 📚 API
|
|
119
120
|
|
|
121
|
+
### Unloadable entries
|
|
122
|
+
|
|
123
|
+
Five listing methods — [`getAttachments()`](#getattachments), [`getSignatures()`](#getsignatures), [`getJavaScriptActions()`](#getjavascriptactions), [`getAnnotations()`](#getannotations) and [`getFormFields()`](#getformfields) — can yield `null` in place of an entry.
|
|
124
|
+
|
|
125
|
+
PDFium counts these collections and loads their members through two separate calls. The count walks a structure (a name tree, an `/Annots` array, the AcroForm field list); loading resolves each slot and is documented to return `NULL` **on failure**. A damaged document makes the two disagree: a `/EmbeddedFiles` slot whose file-specification reference points at a missing object is counted, but does not load.
|
|
126
|
+
|
|
127
|
+
Such an index comes back as `null` rather than being dropped from the array. Dropping it was silent — the array simply got shorter, so `getAttachments()` could return `[]` for a document whose `metadata.attachmentCount` said `1`, and a caller had no way to tell damage from absence. That distinction decides real questions: [`splitDocument`](#splitdocumentinput-splitat-options) and [`mergeDocuments`](#mergedocumentsinputs-options) discard the embedded-files tree, so a caller who checks for attachments and then splits would destroy the file it was checking for, and for a PDF/A-3 e-invoice the embedded XML is usually the only machine-readable copy.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const attachments = await doc.getAttachments();
|
|
131
|
+
|
|
132
|
+
attachments.length === doc.metadata.attachmentCount; // always true
|
|
133
|
+
attachments.every((a, i) => a === null || a.index === i); // always true
|
|
134
|
+
|
|
135
|
+
// an embedded file the name tree counted but PDFium could not load
|
|
136
|
+
if (attachments.some((a) => a === null)) {
|
|
137
|
+
throw new Error('document has an embedded file that could not be loaded');
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Under `strictNullChecks` the compiler flags every call site that assumed success, which is the point — the previous behaviour was invisible by construction. Use `a?.name` or filter with `(a) => a !== null` where a `null` is genuinely acceptable.
|
|
142
|
+
|
|
143
|
+
A `null` reports only that the entry could not be loaded, not why. The singular reader for the same index — [`getAttachment(index)`](#getattachmentindex-options), [`getSignatureContents(index)`](#getsignaturecontentsindex-options) — rejects with the underlying failure. The converse does not hold: an entry that lists fine can still fail to yield bytes (a file specification missing its `/EF` entry, say), so a non-`null` entry is not a guarantee that reading it will succeed.
|
|
144
|
+
|
|
145
|
+
Three neighbouring cases are deliberately **not** reported this way, because in none of them does `NULL` mean the entry failed to load.
|
|
146
|
+
|
|
147
|
+
- `FPDF_StructElement_GetChildAtIndex` returns `NULL` for a struct-tree child that is a content reference rather than an element. PDFium's header documents this.
|
|
148
|
+
- `FPDF_StructTree_GetChildAtIndex` does the same for a top-level element belonging to a **different page**: the count is document-wide while [`getStructTree()`](#getstructtree) walks a single page, so a document with one `/Part` per chapter yields a `NULL` for every chapter that is not the current one. PDFium's header does not mention this; it was established by measurement.
|
|
149
|
+
- [`getNamedDestinations()`](#getnameddestinations) omits a destination it cannot resolve. `FPDF_GetNamedDest` resolves indices below the `/Names /Dests` name-tree count through the tree, which dereferences indirect objects, and lets the rest fall through to the legacy catalog `/Dests` dictionary, which does not — while `FPDF_CountNamedDests` counts every legacy key regardless. A legal entry whose value is an indirect reference is therefore counted and then not resolved, so reporting these as `null` would flag healthy documents. It could not be done in any case: when the lookup fails PDFium writes no name into the buffer either, so the index yields nothing at all to report an entry under. This is the one listing in the library that can come back shorter than its own count — compare against `metadata.namedDestinationCount` to see the gap, and use [`getNamedDestination(name)`](#getnameddestinationname) to resolve such a destination, which goes through PDFium's own name lookup and does dereference.
|
|
150
|
+
|
|
151
|
+
The widget-subtype filter in [`getFormFields()`](#getformfields) is a different thing again: it skips an annotation whose handle loaded _successfully_ and turned out not to be a form field, so no `NULL` is involved.
|
|
152
|
+
|
|
153
|
+
### Where a `null` is not reported
|
|
154
|
+
|
|
155
|
+
A `null` only appears once PDFium has counted the entry, which means damage severe enough to break the count is still invisible. For attachments, a `/EmbeddedFiles` name tree that fails to parse at all — an odd-length `/Names` array, or an `/EmbeddedFiles` key whose reference dangles — reports `attachmentCount: 0` and an empty array, which is indistinguishable from a document with no embedded files. `CPDF_NameTree::Create` fails and `FPDFDoc_GetAttachmentCount` has no error return, so this binding cannot currently see the difference.
|
|
156
|
+
|
|
157
|
+
For the page-level listings the trigger is narrower than "damage": `FPDFPage_GetAnnot` also returns `NULL` for an explicit PDF null object left in an `/Annots` array, which is syntactically legal and something some producers emit after deleting an annotation. A `null` from [`getAnnotations()`](#getannotations) or [`getFormFields()`](#getformfields) means the slot did not resolve to an annotation dictionary — not necessarily that the file is corrupt.
|
|
158
|
+
|
|
120
159
|
### `loadDocument(input, password?)`
|
|
121
160
|
|
|
122
161
|
Opens a PDF from a `Buffer` or file path string. Returns `Promise<PDFiumDocument>`.
|
|
@@ -351,18 +390,21 @@ interface Bookmark {
|
|
|
351
390
|
|
|
352
391
|
#### `getAttachments()`
|
|
353
392
|
|
|
354
|
-
Lists every embedded file (attachment) in the document's `/EmbeddedFiles` name tree. Returns `Promise<Attachment[]
|
|
393
|
+
Lists every embedded file (attachment) in the document's `/EmbeddedFiles` name tree. Returns `Promise<(Attachment | null)[]>` — one entry per `metadata.attachmentCount`, `null` where the embedded file could not be loaded (see [Unloadable entries](#unloadable-entries)). This reads only dictionary metadata — it does **not** decode the file streams; use [`getAttachment(index)`](#getattachmentindex-options) to read the bytes.
|
|
355
394
|
|
|
356
395
|
```typescript
|
|
357
396
|
interface Attachment {
|
|
358
397
|
index: number; // 0-based index in the embedded-files name tree
|
|
359
398
|
name: string; // file name, e.g. 'factur-x.xml'
|
|
360
399
|
mimeType: string; // /Subtype, e.g. 'text/xml' ('' if the PDF omits it)
|
|
400
|
+
afRelationship?: string; // /AFRelationship, e.g. 'Alternative' (absent if the PDF omits it)
|
|
361
401
|
creationDate?: string; // PDF date string, e.g. 'D:20250101120000Z'
|
|
362
402
|
modDate?: string; // PDF date string
|
|
363
403
|
}
|
|
364
404
|
```
|
|
365
405
|
|
|
406
|
+
`afRelationship` is the associated-file relationship defined by PDF 2.0 (ISO 32000-2:2020, Table 43) and used by PDF/A-3: it states an embedded file's _role_ rather than its type. A ZUGFeRD / Factur-X e-invoice marks the machine-readable invoice XML `Alternative` (it is an alternative representation of the visible page), while a human-readable companion is `Supplement`; `Source`, `Data` and `Unspecified` are the other standard values. Without it, an e-invoice reader has to guess which attachment is the invoice from its file name. The key is absent when the PDF omits the entry, and `addAttachments()` cannot set it (see [Writing attachments](#addattachmentsinput-attachments-options)), so attachments written by this library report no value.
|
|
407
|
+
|
|
366
408
|
#### `getAttachment(index, options?)`
|
|
367
409
|
|
|
368
410
|
Reads the raw bytes of the attachment at `index`. Returns `Promise<Buffer>`, or `Promise<void>` when `options.output` is a file path (the bytes are written there instead).
|
|
@@ -374,7 +416,7 @@ const E_INVOICE_NAMES = ['factur-x.xml', 'zugferd-invoice.xml', 'xrechnung.xml']
|
|
|
374
416
|
|
|
375
417
|
const doc = await loadDocument('invoice.pdf');
|
|
376
418
|
const attachments = await doc.getAttachments();
|
|
377
|
-
const entry = attachments.find((a) => E_INVOICE_NAMES.includes(a.name.toLowerCase()));
|
|
419
|
+
const entry = attachments.find((a) => a && E_INVOICE_NAMES.includes(a.name.toLowerCase()));
|
|
378
420
|
|
|
379
421
|
if (entry) {
|
|
380
422
|
const xml = await doc.getAttachment(entry.index); // Buffer of the exact embedded bytes
|
|
@@ -391,7 +433,7 @@ Rejects if `index` is out of range (`0 … attachmentCount - 1`). `metadata.atta
|
|
|
391
433
|
|
|
392
434
|
#### `getSignatures()`
|
|
393
435
|
|
|
394
|
-
Lists every digital signature in the document. Returns `Promise<Signature[]
|
|
436
|
+
Lists every digital signature in the document. Returns `Promise<(Signature | null)[]>` — one entry per `metadata.signatureCount`, `null` where the signature could not be loaded (see [Unloadable entries](#unloadable-entries)). A `null` is not "unsigned": it is a signature this library could not read.
|
|
395
437
|
|
|
396
438
|
Nothing here is cryptographically verified — PDFium does not do that. These values are what the signature dictionary _declares_, so a well-formed entry proves only that the document claims to be signed.
|
|
397
439
|
|
|
@@ -411,6 +453,7 @@ interface Signature {
|
|
|
411
453
|
const doc = await loadDocument('contract.pdf');
|
|
412
454
|
|
|
413
455
|
for (const sig of await doc.getSignatures()) {
|
|
456
|
+
if (!sig) continue; // counted but unloadable — see Unloadable entries
|
|
414
457
|
// A signature covers the whole file only if its last range ends at the file
|
|
415
458
|
// size. Anything less means content was appended after signing.
|
|
416
459
|
const end = sig.byteRange.at(-2)! + sig.byteRange.at(-1)!;
|
|
@@ -428,7 +471,7 @@ Pass this, together with the `byteRange` from `getSignatures()`, to a crypto lib
|
|
|
428
471
|
|
|
429
472
|
#### `getJavaScriptActions()`
|
|
430
473
|
|
|
431
|
-
Lists the document-level scripts a viewer runs when the document opens. Returns `Promise<JavaScriptAction[]
|
|
474
|
+
Lists the document-level scripts a viewer runs when the document opens. Returns `Promise<(JavaScriptAction | null)[]>` — `null` where an action could not be loaded (see [Unloadable entries](#unloadable-entries)). For triage that matters: a document-open script that cannot be read is not the same as no script.
|
|
432
475
|
|
|
433
476
|
Nothing is executed — the bundled PDFium is built with V8 disabled, so scripts come back as inert text. This is for inspection and triage.
|
|
434
477
|
|
|
@@ -446,6 +489,9 @@ const scripts = await doc.getJavaScriptActions();
|
|
|
446
489
|
if (scripts.length > 0) {
|
|
447
490
|
console.warn(`${scripts.length} document-open script(s) — review before rendering`);
|
|
448
491
|
}
|
|
492
|
+
// an action PDFium could not read is the one most worth looking at by hand
|
|
493
|
+
const unreadable = scripts.filter((s) => s === null).length;
|
|
494
|
+
if (unreadable > 0) console.warn(`${unreadable} script(s) could not be decoded`);
|
|
449
495
|
```
|
|
450
496
|
|
|
451
497
|
#### `getNamedDestinations()`
|
|
@@ -454,6 +500,8 @@ Lists the document's named destinations — the anchors that GoTo actions and ex
|
|
|
454
500
|
|
|
455
501
|
Both storage forms are read: the modern `/Names /Dests` name tree and the legacy `/Dests` catalog dictionary.
|
|
456
502
|
|
|
503
|
+
**This is the only listing here that can come back shorter than its count.** A legal legacy `/Dests` entry whose value is an indirect reference is counted by `FPDF_CountNamedDests` and then resolved by neither half of `FPDF_GetNamedDest`: no destination, and no name written to the buffer — so it cannot be reported even as a `null` the way the other counted listings report theirs. Compare the length against `metadata.namedDestinationCount` to detect the gap, and reach the missing entries with [`getNamedDestination(name)`](#getnameddestinationname). See [Unloadable entries](#unloadable-entries) for why this one is different.
|
|
504
|
+
|
|
457
505
|
```typescript
|
|
458
506
|
interface NamedDestination {
|
|
459
507
|
name: string; // e.g. 'Chapter2'
|
|
@@ -466,13 +514,31 @@ interface NamedDestination {
|
|
|
466
514
|
}
|
|
467
515
|
```
|
|
468
516
|
|
|
517
|
+
```typescript
|
|
518
|
+
// Every anchor the document declares, and whether any are out of reach.
|
|
519
|
+
const doc = await loadDocument('document.pdf');
|
|
520
|
+
const dests = await doc.getNamedDestinations();
|
|
521
|
+
if (dests.length < doc.metadata.namedDestinationCount) {
|
|
522
|
+
// destinations exist that the index-based listing cannot enumerate;
|
|
523
|
+
// getNamedDestination(name) still resolves them
|
|
524
|
+
}
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
#### `getNamedDestination(name)`
|
|
528
|
+
|
|
529
|
+
Resolves a single named destination by name. Returns `Promise<NamedDestination | null>` — `null` when the document carries no destination with that name, which is an answer rather than an error.
|
|
530
|
+
|
|
531
|
+
Prefer this over scanning [`getNamedDestinations()`](#getnameddestinations) when a name is already in hand. It searches the `/Names /Dests` name tree and the legacy `/Dests` catalog dictionary alike and dereferences an indirect value in either, so it reaches destinations the listing cannot enumerate.
|
|
532
|
+
|
|
469
533
|
```typescript
|
|
470
534
|
// Resolve "document.pdf#Chapter2" to a page index without walking every link.
|
|
471
535
|
const doc = await loadDocument('document.pdf');
|
|
472
|
-
const target =
|
|
536
|
+
const target = await doc.getNamedDestination('Chapter2');
|
|
473
537
|
console.log(target?.pageIndex);
|
|
474
538
|
```
|
|
475
539
|
|
|
540
|
+
The name is matched as bytes, against the raw name-tree key. Names are ASCII in practice; one stored in UTF-16BE or PDFDocEncoding will not be found by its decoded form.
|
|
541
|
+
|
|
476
542
|
#### `destroy()`
|
|
477
543
|
|
|
478
544
|
Closes the document and frees all native resources. Must be called when done.
|
|
@@ -593,7 +659,7 @@ interface PageRenderOptions {
|
|
|
593
659
|
Returns the page object at the given index. Returns `Promise<PageObject>`. Objects are discriminated by `type`:
|
|
594
660
|
|
|
595
661
|
```typescript
|
|
596
|
-
type PageObject = TextPageObject | ImagePageObject | OtherPageObject;
|
|
662
|
+
type PageObject = TextPageObject | ImagePageObject | OtherPageObject | FormPageObject;
|
|
597
663
|
|
|
598
664
|
// all objects have:
|
|
599
665
|
// bounds: { left, bottom, right, top }
|
|
@@ -604,7 +670,18 @@ type PageObject = TextPageObject | ImagePageObject | OtherPageObject;
|
|
|
604
670
|
// renderMode?, fontFamily?, isEmbedded?, fontFlags?
|
|
605
671
|
// type: 'image' adds: imageWidth, imageHeight, horizontalDpi?, verticalDpi?,
|
|
606
672
|
// bitsPerPixel?, colorspace?, filters?, render()
|
|
607
|
-
// type: '
|
|
673
|
+
// type: 'form' adds: objects, objectsTruncated?
|
|
674
|
+
// type: 'path' | 'shading' | 'unknown'
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**Form objects** carry the objects the form XObject draws in `objects`, nested forms with their own `objects`, bounds in page coordinates. PDFium lists only the form on the page, so a page drawn entirely inside a form shows its text in `getText()` but its text objects, their render modes and the images beside them only here. An image inside a form has no `render()`. The walk stops at 32 levels of nesting or 20,000 objects per call and then sets `objectsTruncated: true`.
|
|
678
|
+
|
|
679
|
+
```typescript
|
|
680
|
+
const visit = (obj: PageObject | NestedPageObject): void => {
|
|
681
|
+
if (obj.type === 'form') obj.objects.forEach(visit);
|
|
682
|
+
else if (obj.type === 'text') console.log(obj.text, obj.renderMode);
|
|
683
|
+
};
|
|
684
|
+
for await (const obj of page.objects()) visit(obj);
|
|
608
685
|
```
|
|
609
686
|
|
|
610
687
|
**Image objects** have a `render()` method for extracting the embedded image:
|
|
@@ -673,7 +750,7 @@ const matches = await page.search('invoice', {
|
|
|
673
750
|
|
|
674
751
|
#### `getAnnotations()`
|
|
675
752
|
|
|
676
|
-
Returns all annotations on the page. Returns `Promise<Annotation[]
|
|
753
|
+
Returns all annotations on the page. Returns `Promise<(Annotation | null)[]>` — one entry per annotation the page declares, `null` where it could not be loaded (see [Unloadable entries](#unloadable-entries)). Array position matches `index`.
|
|
677
754
|
|
|
678
755
|
```typescript
|
|
679
756
|
interface Annotation {
|
|
@@ -705,7 +782,7 @@ Rejects if the annotation at `index` is not a file attachment or carries no embe
|
|
|
705
782
|
```typescript
|
|
706
783
|
const annotations = await page.getAnnotations();
|
|
707
784
|
for (const annot of annotations) {
|
|
708
|
-
if (annot
|
|
785
|
+
if (annot?.type === 'fileattachment') {
|
|
709
786
|
const bytes = await page.getAnnotationAttachment(annot.index); // Buffer of exact embedded bytes
|
|
710
787
|
// ...or write straight to disk:
|
|
711
788
|
await page.getAnnotationAttachment(annot.index, { output: annot.fileName ?? 'attachment.bin' });
|
|
@@ -715,7 +792,7 @@ for (const annot of annotations) {
|
|
|
715
792
|
|
|
716
793
|
#### `getFormFields()`
|
|
717
794
|
|
|
718
|
-
Returns all form fields on the page. Returns `Promise<FormField[]>`.
|
|
795
|
+
Returns all form fields on the page. Returns `Promise<(FormField | null)[]>`. Unlike the other listings this array is a filtered subset — only widget annotations are form fields — so its length tracks no count, and array position is not a page index. A `null` means an annotation on the page could not be loaded; because the subtype is only readable through the handle that failed, it cannot be ruled out as a non-widget, so it means "a form field may be missing here" (see [Unloadable entries](#unloadable-entries)).
|
|
719
796
|
|
|
720
797
|
```typescript
|
|
721
798
|
interface FormField {
|
|
@@ -746,8 +823,8 @@ interface FormFieldOption {
|
|
|
746
823
|
|
|
747
824
|
```typescript
|
|
748
825
|
const fields = await page.getFormFields();
|
|
749
|
-
const textFields = fields.filter((f) => f
|
|
750
|
-
const checked = fields.filter((f) => f
|
|
826
|
+
const textFields = fields.filter((f) => f?.type === 'textField');
|
|
827
|
+
const checked = fields.filter((f) => f?.isChecked);
|
|
751
828
|
```
|
|
752
829
|
|
|
753
830
|
#### `close()`
|
|
@@ -783,6 +860,7 @@ interface DocumentMetadata {
|
|
|
783
860
|
language: string; // document language (e.g. 'en-US')
|
|
784
861
|
signatureCount: number; // number of digital signatures
|
|
785
862
|
attachmentCount: number; // number of file attachments
|
|
863
|
+
namedDestinationCount: number; // anchors counted; see getNamedDestinations()
|
|
786
864
|
permanentId?: string; // permanent file identifier (hex)
|
|
787
865
|
changingId?: string; // changing file identifier (hex)
|
|
788
866
|
}
|
package/dist/document.d.ts
CHANGED
|
@@ -26,8 +26,35 @@ export declare class PDFiumDocument {
|
|
|
26
26
|
* For ZUGFeRD / Factur-X / XRechnung PDF/A-3 e-invoices, the structured
|
|
27
27
|
* invoice lives here (e.g. `factur-x.xml`); pass its `index` to
|
|
28
28
|
* {@link getAttachment} to read the bytes.
|
|
29
|
+
*
|
|
30
|
+
* An entry is `null` when PDFium counted an embedded file but could not load
|
|
31
|
+
* it — a `/EmbeddedFiles` name-tree slot whose file-specification reference
|
|
32
|
+
* points at a missing object, for instance. The array always has one entry
|
|
33
|
+
* per `metadata.attachmentCount`, so array position matches
|
|
34
|
+
* {@link Attachment.index}. Telling a damaged embedded file apart from a
|
|
35
|
+
* document that simply has none matters before a
|
|
36
|
+
* destructive operation: {@link splitDocument} and {@link mergeDocuments}
|
|
37
|
+
* discard the embedded-files tree, and for an e-invoice the embedded XML is
|
|
38
|
+
* often the only machine-readable copy.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const attachments = await doc.getAttachments();
|
|
42
|
+
* if (attachments.some((a) => a === null)) throw new Error('damaged embedded file');
|
|
43
|
+
* const invoice = attachments.find((a) => a?.name === 'factur-x.xml');
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* A `null` says only that the entry could not be loaded, not why;
|
|
47
|
+
* {@link getAttachment} on the same index rejects with the underlying
|
|
48
|
+
* failure. Note the converse does not hold — an entry that lists fine can
|
|
49
|
+
* still fail to yield bytes, so a non-`null` entry is not a promise that
|
|
50
|
+
* {@link getAttachment} will succeed.
|
|
51
|
+
*
|
|
52
|
+
* A `null` only appears once PDFium has counted the entry, so damage that
|
|
53
|
+
* breaks the count itself stays invisible: a name tree that fails to parse
|
|
54
|
+
* reports `attachmentCount: 0` and an empty array, indistinguishable from a
|
|
55
|
+
* document with no embedded files.
|
|
29
56
|
*/
|
|
30
|
-
getAttachments(): Promise<Attachment[]>;
|
|
57
|
+
getAttachments(): Promise<(Attachment | null)[]>;
|
|
31
58
|
/** Writes the attachment at `index` to a file path. */
|
|
32
59
|
getAttachment(index: number, options: GetAttachmentOptions & {
|
|
33
60
|
output: string;
|
|
@@ -50,8 +77,14 @@ export declare class PDFiumDocument {
|
|
|
50
77
|
* Nothing is cryptographically verified: this reports what the PDF declares
|
|
51
78
|
* about itself. To actually validate a signature, read its blob with
|
|
52
79
|
* {@link getSignatureContents} and check it against `byteRange`.
|
|
80
|
+
*
|
|
81
|
+
* An entry is `null` when PDFium counted a signature but could not load it,
|
|
82
|
+
* so the array always has one entry per `metadata.signatureCount`. A `null`
|
|
83
|
+
* is not "unsigned" — it is a signature this library could not read, which
|
|
84
|
+
* for a document whose signatures are the point is the more alarming of the
|
|
85
|
+
* two.
|
|
53
86
|
*/
|
|
54
|
-
getSignatures(): Promise<Signature[]>;
|
|
87
|
+
getSignatures(): Promise<(Signature | null)[]>;
|
|
55
88
|
/** Writes the signature's /Contents bytes at `index` to a file path. */
|
|
56
89
|
getSignatureContents(index: number, options: GetSignatureContentsOptions & {
|
|
57
90
|
output: string;
|
|
@@ -66,14 +99,40 @@ export declare class PDFiumDocument {
|
|
|
66
99
|
* carries document-open JavaScript is worth checking before rendering.
|
|
67
100
|
* Nothing here is executed; the scripts come back as inert text.
|
|
68
101
|
*/
|
|
69
|
-
getJavaScriptActions(): Promise<JavaScriptAction[]>;
|
|
102
|
+
getJavaScriptActions(): Promise<(JavaScriptAction | null)[]>;
|
|
70
103
|
/**
|
|
71
104
|
* Returns the document's named destinations — the anchors that GoTo actions
|
|
72
105
|
* and external links target by name rather than by page number.
|
|
73
106
|
*
|
|
74
107
|
* This resolves a name like `Chapter2` to a concrete page index without
|
|
75
108
|
* walking every link on every page.
|
|
109
|
+
*
|
|
110
|
+
* **This is the one listing in the library that can come back shorter than
|
|
111
|
+
* its own count.** A legal legacy `/Dests` entry whose value is an indirect
|
|
112
|
+
* reference is counted by PDFium and then resolved by neither of the two
|
|
113
|
+
* things the index-based lookup could return: it yields no destination and
|
|
114
|
+
* writes no name, so the entry cannot be reported even as a `null` the way
|
|
115
|
+
* the other counted listings report theirs. Compare the length against
|
|
116
|
+
* `metadata.namedDestinationCount` to detect the gap, and use
|
|
117
|
+
* {@link getNamedDestination} to resolve such a destination by name — that
|
|
118
|
+
* path goes through PDFium's own name lookup, which dereferences the value
|
|
119
|
+
* and finds it.
|
|
76
120
|
*/
|
|
77
121
|
getNamedDestinations(): Promise<NamedDestination[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Resolves a single named destination by name, or `null` when the document
|
|
124
|
+
* has none with that name.
|
|
125
|
+
*
|
|
126
|
+
* Prefer this over scanning {@link getNamedDestinations} when a name is
|
|
127
|
+
* already in hand — following `#Chapter2` from an incoming link, say. It
|
|
128
|
+
* searches the `/Names /Dests` name tree and the legacy catalog `/Dests`
|
|
129
|
+
* dictionary alike and dereferences an indirect value in either, so it
|
|
130
|
+
* reaches destinations the listing cannot enumerate.
|
|
131
|
+
*
|
|
132
|
+
* The name is matched as bytes, against the raw name-tree key. Names are
|
|
133
|
+
* ASCII in practice; one stored in UTF-16BE or PDFDocEncoding will not be
|
|
134
|
+
* found by its decoded form.
|
|
135
|
+
*/
|
|
136
|
+
getNamedDestination(name: string): Promise<NamedDestination | null>;
|
|
78
137
|
}
|
|
79
138
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../lib/document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,cAAc;IAOb,OAAO,CAAC,MAAM;IAN1B,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC,gBAAgB;gBACI,MAAM,EAAE,cAAc;IAK1C,oCAAoC;IAC9B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD,4EAA4E;IACrE,KAAK,IAAI,cAAc,CAAC,UAAU,CAAC;IAM1C,mDAAmD;IACnD,OAAO,IAAI,IAAI;IAIf,yCAAyC;IACzC,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAInC
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../lib/document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,SAAS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AC,MAAM,CAAC;IAe3F;;;;;;;OAOG;IACH,oBAAoB,IAAI,OAAO,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,CAAC;IAI5D;;;;;;;;;;;;;;;;;OAiBG;IACH,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAInD;;;;;;;;;;;;;OAaG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAMpE"}
|
package/dist/document.js
CHANGED
|
@@ -41,6 +41,33 @@ export class PDFiumDocument {
|
|
|
41
41
|
* For ZUGFeRD / Factur-X / XRechnung PDF/A-3 e-invoices, the structured
|
|
42
42
|
* invoice lives here (e.g. `factur-x.xml`); pass its `index` to
|
|
43
43
|
* {@link getAttachment} to read the bytes.
|
|
44
|
+
*
|
|
45
|
+
* An entry is `null` when PDFium counted an embedded file but could not load
|
|
46
|
+
* it — a `/EmbeddedFiles` name-tree slot whose file-specification reference
|
|
47
|
+
* points at a missing object, for instance. The array always has one entry
|
|
48
|
+
* per `metadata.attachmentCount`, so array position matches
|
|
49
|
+
* {@link Attachment.index}. Telling a damaged embedded file apart from a
|
|
50
|
+
* document that simply has none matters before a
|
|
51
|
+
* destructive operation: {@link splitDocument} and {@link mergeDocuments}
|
|
52
|
+
* discard the embedded-files tree, and for an e-invoice the embedded XML is
|
|
53
|
+
* often the only machine-readable copy.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* const attachments = await doc.getAttachments();
|
|
57
|
+
* if (attachments.some((a) => a === null)) throw new Error('damaged embedded file');
|
|
58
|
+
* const invoice = attachments.find((a) => a?.name === 'factur-x.xml');
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* A `null` says only that the entry could not be loaded, not why;
|
|
62
|
+
* {@link getAttachment} on the same index rejects with the underlying
|
|
63
|
+
* failure. Note the converse does not hold — an entry that lists fine can
|
|
64
|
+
* still fail to yield bytes, so a non-`null` entry is not a promise that
|
|
65
|
+
* {@link getAttachment} will succeed.
|
|
66
|
+
*
|
|
67
|
+
* A `null` only appears once PDFium has counted the entry, so damage that
|
|
68
|
+
* breaks the count itself stays invisible: a name tree that fails to parse
|
|
69
|
+
* reports `attachmentCount: 0` and an empty array, indistinguishable from a
|
|
70
|
+
* document with no embedded files.
|
|
44
71
|
*/
|
|
45
72
|
getAttachments() {
|
|
46
73
|
return withConcurrency(() => this.native.getAttachments());
|
|
@@ -64,6 +91,12 @@ export class PDFiumDocument {
|
|
|
64
91
|
* Nothing is cryptographically verified: this reports what the PDF declares
|
|
65
92
|
* about itself. To actually validate a signature, read its blob with
|
|
66
93
|
* {@link getSignatureContents} and check it against `byteRange`.
|
|
94
|
+
*
|
|
95
|
+
* An entry is `null` when PDFium counted a signature but could not load it,
|
|
96
|
+
* so the array always has one entry per `metadata.signatureCount`. A `null`
|
|
97
|
+
* is not "unsigned" — it is a signature this library could not read, which
|
|
98
|
+
* for a document whose signatures are the point is the more alarming of the
|
|
99
|
+
* two.
|
|
67
100
|
*/
|
|
68
101
|
getSignatures() {
|
|
69
102
|
return withConcurrency(() => this.native.getSignatures());
|
|
@@ -93,9 +126,40 @@ export class PDFiumDocument {
|
|
|
93
126
|
*
|
|
94
127
|
* This resolves a name like `Chapter2` to a concrete page index without
|
|
95
128
|
* walking every link on every page.
|
|
129
|
+
*
|
|
130
|
+
* **This is the one listing in the library that can come back shorter than
|
|
131
|
+
* its own count.** A legal legacy `/Dests` entry whose value is an indirect
|
|
132
|
+
* reference is counted by PDFium and then resolved by neither of the two
|
|
133
|
+
* things the index-based lookup could return: it yields no destination and
|
|
134
|
+
* writes no name, so the entry cannot be reported even as a `null` the way
|
|
135
|
+
* the other counted listings report theirs. Compare the length against
|
|
136
|
+
* `metadata.namedDestinationCount` to detect the gap, and use
|
|
137
|
+
* {@link getNamedDestination} to resolve such a destination by name — that
|
|
138
|
+
* path goes through PDFium's own name lookup, which dereferences the value
|
|
139
|
+
* and finds it.
|
|
96
140
|
*/
|
|
97
141
|
getNamedDestinations() {
|
|
98
142
|
return withConcurrency(() => this.native.getNamedDestinations());
|
|
99
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Resolves a single named destination by name, or `null` when the document
|
|
146
|
+
* has none with that name.
|
|
147
|
+
*
|
|
148
|
+
* Prefer this over scanning {@link getNamedDestinations} when a name is
|
|
149
|
+
* already in hand — following `#Chapter2` from an incoming link, say. It
|
|
150
|
+
* searches the `/Names /Dests` name tree and the legacy catalog `/Dests`
|
|
151
|
+
* dictionary alike and dereferences an indirect value in either, so it
|
|
152
|
+
* reaches destinations the listing cannot enumerate.
|
|
153
|
+
*
|
|
154
|
+
* The name is matched as bytes, against the raw name-tree key. Names are
|
|
155
|
+
* ASCII in practice; one stored in UTF-16BE or PDFDocEncoding will not be
|
|
156
|
+
* found by its decoded form.
|
|
157
|
+
*/
|
|
158
|
+
getNamedDestination(name) {
|
|
159
|
+
if (typeof name !== 'string') {
|
|
160
|
+
throw new TypeError('name must be a string');
|
|
161
|
+
}
|
|
162
|
+
return withConcurrency(() => this.native.getNamedDestination(name));
|
|
163
|
+
}
|
|
100
164
|
}
|
|
101
165
|
//# sourceMappingURL=document.js.map
|
package/dist/document.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../lib/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAa9C;;GAEG;AACH,MAAM,OAAO,cAAc;IAOL;IANpB,6BAA6B;IACpB,SAAS,CAAS;IAC3B,sDAAsD;IAC7C,QAAQ,CAAmB;IAEpC,gBAAgB;IAChB,YAAoB,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;QACxC,IAAI,CAAC,SAAS,GAAG,MAAM,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;;OAcG;IACH,aAAa;QACX,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5D,CAAC;IASD,oBAAoB,CAClB,KAAa,EACb,OAAqC;QAErC,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,UAAU,CAAC,iDAAiD,KAAK,EAAE,CAAC,CACzE,CAAC;QACJ,CAAC;QACD,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IAED;;;;;;;OAOG;IACH,oBAAoB;QAClB,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,oBAAoB;QAClB,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,mBAAmB,CAAC,IAAY;QAC9B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -82,5 +82,5 @@ export { concurrency } from './concurrency.js';
|
|
|
82
82
|
export { PDFiumDocument } from './document.js';
|
|
83
83
|
export { PDFiumError, PDFiumFileError, PDFiumFormatError, PDFiumPasswordError, PDFiumSecurityError, } from './errors.js';
|
|
84
84
|
export { PDFiumPage } from './page.js';
|
|
85
|
-
export type { AddAttachmentsOptions, Annotation, AnnotationBorder, AnnotationType, AssemblePagesOptions, Attachment, AttachmentInput, Bookmark, DocumentMetadata, DestinationView, DocumentPermissions, FormField, FormFieldOption, FlattenDocumentOptions, FormFieldType, GetAttachmentOptions, GetCharactersOptions, GetSignatureContentsOptions, ImageColorspace, ImagePageObject, ImageRenderOptions, JavaScriptAction, Link, LinkActionType, MergeDocumentInput, MergeDocumentsOptions, NUpPagesOptions, NamedDestination, OtherPageObject, PageObject, PageObjectBounds, PageRenderOptions, QuadPoints, RGBA, SearchMatch, SearchOptions, SearchRect, Signature, StructElement, SplitDocumentOptions, TextCharacter, TextPageObject, TextRenderMode, } from './types.js';
|
|
85
|
+
export type { AddAttachmentsOptions, Annotation, AnnotationBorder, AnnotationType, AssemblePagesOptions, Attachment, AttachmentInput, Bookmark, DocumentMetadata, DestinationView, DocumentPermissions, FormField, FormFieldOption, FlattenDocumentOptions, FormFieldType, FormPageObject, GetAttachmentOptions, GetCharactersOptions, GetSignatureContentsOptions, ImageColorspace, ImagePageObject, ImageRenderOptions, JavaScriptAction, Link, LinkActionType, MergeDocumentInput, MergeDocumentsOptions, NUpPagesOptions, NamedDestination, NestedPageObject, OtherPageObject, PageObject, PageObjectBounds, PageRenderOptions, QuadPoints, RGBA, SearchMatch, SearchOptions, SearchRect, Signature, StructElement, SplitDocumentOptions, TextCharacter, TextPageObject, TextRenderMode, } from './types.js';
|
|
86
86
|
//# 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":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB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qB,EACrB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,IAAI,EACJ,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,WAAW,EACX,aAAa,EACb,UAAU,EACV,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EAEf,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAKpB,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAgBhC;;GAEG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAM9F;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,oBAAoB,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GACpD,OAAO,CAAC,IAAI,CAAC,CAAC;AACjB,wBAAsB,aAAa,CACjC,KAAK,EA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,UAAU,EACV,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/page.d.ts
CHANGED
|
@@ -63,8 +63,20 @@ export declare class PDFiumPage {
|
|
|
63
63
|
getLinks(): Promise<Link[]>;
|
|
64
64
|
/** Searches for text on the page. Returns matches with positions and bounding rects. */
|
|
65
65
|
search(text: string, options?: SearchOptions): Promise<SearchMatch[]>;
|
|
66
|
-
/**
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Returns all annotations on the page.
|
|
68
|
+
*
|
|
69
|
+
* An entry is `null` when PDFium counted an annotation on the page but could
|
|
70
|
+
* not load it. The array always has one entry per annotation the page
|
|
71
|
+
* declares, so array position matches {@link Annotation.index} and a
|
|
72
|
+
* dropped annotation leaves no unexplained gap in that sequence.
|
|
73
|
+
*
|
|
74
|
+
* The trigger is narrower than "the document is damaged": `/Annots` slots
|
|
75
|
+
* hold an explicit PDF null object in some producers' output after an
|
|
76
|
+
* annotation is deleted, which is legal and also yields a `null` here. Read
|
|
77
|
+
* it as "this slot did not resolve to an annotation dictionary".
|
|
78
|
+
*/
|
|
79
|
+
getAnnotations(): Promise<(Annotation | null)[]>;
|
|
68
80
|
/**
|
|
69
81
|
* Reads the embedded file of the file-attachment annotation at `index`
|
|
70
82
|
* (the annotation's {@link Annotation.index}). Use this for page-level
|
|
@@ -78,7 +90,16 @@ export declare class PDFiumPage {
|
|
|
78
90
|
output: string;
|
|
79
91
|
}): Promise<void>;
|
|
80
92
|
getAnnotationAttachment(index: number, options?: GetAttachmentOptions): Promise<Buffer>;
|
|
81
|
-
/**
|
|
82
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Returns all form fields on the page.
|
|
95
|
+
*
|
|
96
|
+
* An entry is `null` when an annotation on the page could not be loaded.
|
|
97
|
+
* Unlike the other listings this array is a filtered subset — only widget
|
|
98
|
+
* annotations are form fields — and the subtype is readable only through the
|
|
99
|
+
* handle that failed, so an unloadable annotation cannot be ruled out as a
|
|
100
|
+
* non-widget. A `null` therefore means "a form field may be missing here",
|
|
101
|
+
* and array position does not track any page index.
|
|
102
|
+
*/
|
|
103
|
+
getFormFields(): Promise<(FormField | null)[]>;
|
|
83
104
|
}
|
|
84
105
|
//# 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":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EAGpB,IAAI,EACJ,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,aAAa,EACb,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;IA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AW,EAAE,CAAC;IAIrE;;;;;;;;;;;;OAYG;IACH,cAAc,IAAI,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAIhD;;;;;;;;OAQG;IACH,uBAAuB,CACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,oBAAoB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,IAAI,CAAC;IAChB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAavF;;;;;;;;;OASG;IACH,aAAa,IAAI,OAAO,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC;CAG/C"}
|
package/dist/page.js
CHANGED
|
@@ -116,7 +116,19 @@ export class PDFiumPage {
|
|
|
116
116
|
search(text, options) {
|
|
117
117
|
return withConcurrency(() => this.native.search(text, options));
|
|
118
118
|
}
|
|
119
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Returns all annotations on the page.
|
|
121
|
+
*
|
|
122
|
+
* An entry is `null` when PDFium counted an annotation on the page but could
|
|
123
|
+
* not load it. The array always has one entry per annotation the page
|
|
124
|
+
* declares, so array position matches {@link Annotation.index} and a
|
|
125
|
+
* dropped annotation leaves no unexplained gap in that sequence.
|
|
126
|
+
*
|
|
127
|
+
* The trigger is narrower than "the document is damaged": `/Annots` slots
|
|
128
|
+
* hold an explicit PDF null object in some producers' output after an
|
|
129
|
+
* annotation is deleted, which is legal and also yields a `null` here. Read
|
|
130
|
+
* it as "this slot did not resolve to an annotation dictionary".
|
|
131
|
+
*/
|
|
120
132
|
getAnnotations() {
|
|
121
133
|
return withConcurrency(() => this.native.getAnnotations());
|
|
122
134
|
}
|
|
@@ -129,7 +141,16 @@ export class PDFiumPage {
|
|
|
129
141
|
}
|
|
130
142
|
return withConcurrency(() => this.native.getAnnotationAttachment(index, options?.output));
|
|
131
143
|
}
|
|
132
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Returns all form fields on the page.
|
|
146
|
+
*
|
|
147
|
+
* An entry is `null` when an annotation on the page could not be loaded.
|
|
148
|
+
* Unlike the other listings this array is a filtered subset — only widget
|
|
149
|
+
* annotations are form fields — and the subtype is readable only through the
|
|
150
|
+
* handle that failed, so an unloadable annotation cannot be ruled out as a
|
|
151
|
+
* non-widget. A `null` therefore means "a form field may be missing here",
|
|
152
|
+
* and array position does not track any page index.
|
|
153
|
+
*/
|
|
133
154
|
getFormFields() {
|
|
134
155
|
return withConcurrency(() => this.native.getFormFields());
|
|
135
156
|
}
|