pdfium-native 0.9.0 → 0.10.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 CHANGED
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.10.0] - 2026-09-22
10
+
11
+ ### Added
12
+
13
+ - `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.
14
+
15
+ ### Changed
16
+
17
+ - 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)).
18
+
19
+ ## [0.9.1] - 2026-08-07
20
+
21
+ Fixes for defects found by an adversarial audit of the 0.9.0 release. Every item
22
+ below was reproduced against the shipped build before being fixed, and each is
23
+ now pinned by a regression test.
24
+
25
+ ### Fixed
26
+
27
+ - `page.getCharacters()` corrupted every non-BMP character. `FPDFText_GetUnicode` returns one UTF-16 _code unit_ per index — on POSIX as well as Windows — so an emoji arrives as two consecutive lone surrogates, and converting each separately made V8 substitute `U+FFFD`. `chars.map((c) => c.char).join('') === getText()`, an invariant the docs promised, was false for any astral character. The pair is now joined onto the first entry with the second yielding an empty continuation, which keeps both that invariant and the index alignment with `getText()` / `search()`. A new `astral-text.pdf` fixture covers it; the previous tests were ASCII-only.
28
+ - `page.getStructTree()` could be made to allocate unboundedly by a ~1.2 KB file. PDFium's structure tree is a DAG and `CPDF_StructElement::UpdateKidIfElement` resolves every kid slot naming a matching dict, so a `/K` array repeating the same child gives that element two live children pointing at one node. Flattening it into a tree doubled the node count per level (a 12-link chain measured 4095 elements, 17 links would be 262,143), all while holding the global PDFium mutex — stalling every other PDFium call in the process, not just the one page. The walk is now bounded by `MAX_STRUCT_NODES` (20,000) in addition to the existing depth cap — a single page's structure tree covers only that page's content, so real documents run to hundreds of elements and the cap stays cheap to reach.
29
+ - `flattenDocument(pdf, { pages: [] })` flattened **every** page instead of none. The native worker could not distinguish an explicitly empty selection from an absent one, so a caller computing `pages` from a filter that matched nothing silently stripped every annotation and form widget in the document. An empty array is now a no-op that returns an unchanged copy; omitting the option still means every page.
30
+ - `nUpPages()` accepted a `columns`/`rows` value outside the signed 32-bit range and let the native `ToInt32` coercion wrap it, so `columns: 2**32 + 2` silently produced a 2-up layout instead of an error. It now uses the same `isNativeIndex` guard as every other index in the library.
31
+ - `TextCharacter.fontWeight` was documented "Absent if unavailable" but was present as a meaningless `0` for every character in a non-embedded font — PDFium returns 0 when the font declares no weight and reserves -1 for errors. The key is now omitted unless the weight is positive.
32
+ - `addAttachments()` truncated an attachment of 4 GiB or more on Windows, where `unsigned long` is 32-bit, writing a short file and reporting success. Payloads above `INT_MAX` are now rejected with an explicit message.
33
+
9
34
  ## [0.9.0] - 2026-08-07
10
35
 
11
36
  ### Added
@@ -332,7 +357,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
332
357
  - GitHub Actions publish workflow with test gate
333
358
  - TypeScript type declarations for JS consumers
334
359
 
335
- [Unreleased]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.9.0...HEAD
360
+ [Unreleased]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.10.0...HEAD
361
+ [0.10.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.9.1...v0.10.0
362
+ [0.9.1]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.9.0...v0.9.1
336
363
  [0.9.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.8.0...v0.9.0
337
364
  [0.8.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.7.0...v0.8.0
338
365
  [0.7.0]: https://github.com/xonaman/nodejs-pdfium-native/compare/v0.6.1...v0.7.0
package/README.md CHANGED
@@ -358,11 +358,14 @@ interface Attachment {
358
358
  index: number; // 0-based index in the embedded-files name tree
359
359
  name: string; // file name, e.g. 'factur-x.xml'
360
360
  mimeType: string; // /Subtype, e.g. 'text/xml' ('' if the PDF omits it)
361
+ afRelationship?: string; // /AFRelationship, e.g. 'Alternative' (absent if the PDF omits it)
361
362
  creationDate?: string; // PDF date string, e.g. 'D:20250101120000Z'
362
363
  modDate?: string; // PDF date string
363
364
  }
364
365
  ```
365
366
 
367
+ `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.
368
+
366
369
  #### `getAttachment(index, options?)`
367
370
 
368
371
  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).
@@ -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,qBAAqB,EACrB,eAAe,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EACb,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -69,8 +69,11 @@ export async function nUpPages(input, options) {
69
69
  ['columns', options.columns],
70
70
  ['rows', options.rows],
71
71
  ]) {
72
- if (!Number.isInteger(value) || value < 1) {
73
- throw new RangeError(`${name} must be a positive integer, got ${value}`);
72
+ // isNativeIndex, not just Number.isInteger: the native layer coerces with
73
+ // ToInt32, so 2**32 + 2 would wrap to 2 and silently produce a different,
74
+ // perfectly valid layout instead of an error.
75
+ if (!isNativeIndex(value) || value < 1) {
76
+ throw new RangeError(`${name} must be a positive 32-bit integer, got ${value}`);
74
77
  }
75
78
  }
76
79
  try {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAa9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAI1D,oEAAoE;AACpE,uEAAuE;AACvE,kEAAkE;AAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAC9D,IAAI,OAAO,CAAC,QAAQ,KAAK,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AAM,IAAI,IAAI,OAAO,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,UAAU,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,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"}
package/dist/types.d.ts CHANGED
@@ -117,11 +117,22 @@ export interface TextCharacter {
117
117
  /** 0-based index of this character in the page's text. */
118
118
  index: number;
119
119
  /**
120
- * The character itself. Empty string when the glyph has no Unicode mapping —
121
- * check `hasUnicodeMapError` before trusting it.
120
+ * The character itself.
121
+ *
122
+ * Empty string when the glyph has no Unicode mapping — check
123
+ * `hasUnicodeMapError` before trusting it — and also on the *second* entry of
124
+ * a non-BMP character. PDFium reports one UTF-16 code unit per index, so an
125
+ * emoji occupies two entries; the whole character is emitted on the first and
126
+ * the second is an empty continuation. That keeps indices aligned with
127
+ * `getText()` while `chars.map((c) => c.char).join('')` still reproduces it
128
+ * exactly.
122
129
  */
123
130
  char: string;
124
- /** Unicode code point, or 0 if the glyph has no mapping. */
131
+ /**
132
+ * The raw UTF-16 code unit at this index, or 0 if the glyph has no mapping.
133
+ * For a non-BMP character this is the high surrogate on the first entry and
134
+ * the low surrogate on the second, not the combined code point.
135
+ */
125
136
  unicode: number;
126
137
  /**
127
138
  * Tight bounding box in page points, hugging the glyph's ink. Absent if
@@ -138,7 +149,11 @@ export interface TextCharacter {
138
149
  fontName: string;
139
150
  /** Raw PDF font descriptor flags bitmask (see PDF spec Table 123). */
140
151
  fontFlags: number;
141
- /** Font weight (e.g. 400 = normal, 700 = bold). Absent if unavailable. */
152
+ /**
153
+ * Font weight (e.g. 400 = normal, 700 = bold). Absent when the font declares
154
+ * none — which is the case for the non-embedded standard fonts, so do not
155
+ * treat its absence as an error.
156
+ */
142
157
  fontWeight?: number;
143
158
  /**
144
159
  * Rotation of the character in radians, normalized to `[0, 2π)`. 0 for
@@ -184,7 +199,14 @@ export interface StructElement {
184
199
  lang?: string;
185
200
  /** Marked-content ID tying this element to page content. Absent if the element has none. */
186
201
  markedContentId?: number;
187
- /** Child elements. Absent when the element has no element children. */
202
+ /**
203
+ * Child elements. Absent when the element has no element children.
204
+ *
205
+ * The walk is capped at 100,000 elements per page. PDFium's structure tree is
206
+ * a DAG, so a document whose `/K` arrays repeat the same child expands
207
+ * exponentially when flattened into a tree; the cap bounds that. Real
208
+ * documents do not come close to it.
209
+ */
188
210
  children?: StructElement[];
189
211
  }
190
212
  export interface GetCharactersOptions {
@@ -410,6 +432,14 @@ export interface Attachment {
410
432
  name: string;
411
433
  /** MIME type (/Subtype), e.g. 'text/xml'. Empty string if the PDF omits it. */
412
434
  mimeType: string;
435
+ /**
436
+ * Associated-file relationship (/AFRelationship, PDF 2.0) describing the
437
+ * embedded file's role, e.g. 'Alternative' for a ZUGFeRD/Factur-X invoice
438
+ * XML, 'Supplement' for a human-readable companion, or 'Source' / 'Data' /
439
+ * 'Unspecified'. Absent when the PDF omits the entry. Note `addAttachments`
440
+ * cannot set it, so attachments written by this library report no value.
441
+ */
442
+ afRelationship?: string;
413
443
  /** Creation date as a PDF date string (e.g. 'D:20250101120000Z'). Absent if not set. */
414
444
  creationDate?: string;
415
445
  /** Modification date as a PDF date string. Absent if not set. */
@@ -600,7 +630,13 @@ export interface FlattenDocumentOptions {
600
630
  * a watermark marked print-only, for instance.
601
631
  */
602
632
  usage?: 'display' | 'print';
603
- /** Only flatten these page indices. Defaults to every page. */
633
+ /**
634
+ * Only flatten these page indices. Defaults to every page when omitted.
635
+ *
636
+ * An explicitly empty array flattens *nothing* and returns an unchanged copy —
637
+ * so a selection computed by a filter that happens to match no pages is a
638
+ * no-op rather than a document stripped of every annotation.
639
+ */
604
640
  pages?: number[];
605
641
  /** Write to this file path instead of returning a Buffer. */
606
642
  output?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;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xF,cAAc,CACZ,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,WAAW,EAAE,eAAe,EAAE,EAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/B,eAAe,CACb,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAChC"}
package/lib/index.ts CHANGED
@@ -152,8 +152,11 @@ export async function nUpPages(input: PdfInput, options: NUpPagesOptions): Promi
152
152
  ['columns', options.columns],
153
153
  ['rows', options.rows],
154
154
  ] as const) {
155
- if (!Number.isInteger(value) || value < 1) {
156
- throw new RangeError(`${name} must be a positive integer, got ${value}`);
155
+ // isNativeIndex, not just Number.isInteger: the native layer coerces with
156
+ // ToInt32, so 2**32 + 2 would wrap to 2 and silently produce a different,
157
+ // perfectly valid layout instead of an error.
158
+ if (!isNativeIndex(value) || value < 1) {
159
+ throw new RangeError(`${name} must be a positive 32-bit integer, got ${value}`);
157
160
  }
158
161
  }
159
162
  try {
package/lib/types.ts CHANGED
@@ -147,11 +147,22 @@ export interface TextCharacter {
147
147
  /** 0-based index of this character in the page's text. */
148
148
  index: number;
149
149
  /**
150
- * The character itself. Empty string when the glyph has no Unicode mapping —
151
- * check `hasUnicodeMapError` before trusting it.
150
+ * The character itself.
151
+ *
152
+ * Empty string when the glyph has no Unicode mapping — check
153
+ * `hasUnicodeMapError` before trusting it — and also on the *second* entry of
154
+ * a non-BMP character. PDFium reports one UTF-16 code unit per index, so an
155
+ * emoji occupies two entries; the whole character is emitted on the first and
156
+ * the second is an empty continuation. That keeps indices aligned with
157
+ * `getText()` while `chars.map((c) => c.char).join('')` still reproduces it
158
+ * exactly.
152
159
  */
153
160
  char: string;
154
- /** Unicode code point, or 0 if the glyph has no mapping. */
161
+ /**
162
+ * The raw UTF-16 code unit at this index, or 0 if the glyph has no mapping.
163
+ * For a non-BMP character this is the high surrogate on the first entry and
164
+ * the low surrogate on the second, not the combined code point.
165
+ */
155
166
  unicode: number;
156
167
  /**
157
168
  * Tight bounding box in page points, hugging the glyph's ink. Absent if
@@ -168,7 +179,11 @@ export interface TextCharacter {
168
179
  fontName: string;
169
180
  /** Raw PDF font descriptor flags bitmask (see PDF spec Table 123). */
170
181
  fontFlags: number;
171
- /** Font weight (e.g. 400 = normal, 700 = bold). Absent if unavailable. */
182
+ /**
183
+ * Font weight (e.g. 400 = normal, 700 = bold). Absent when the font declares
184
+ * none — which is the case for the non-embedded standard fonts, so do not
185
+ * treat its absence as an error.
186
+ */
172
187
  fontWeight?: number;
173
188
  /**
174
189
  * Rotation of the character in radians, normalized to `[0, 2π)`. 0 for
@@ -215,7 +230,14 @@ export interface StructElement {
215
230
  lang?: string;
216
231
  /** Marked-content ID tying this element to page content. Absent if the element has none. */
217
232
  markedContentId?: number;
218
- /** Child elements. Absent when the element has no element children. */
233
+ /**
234
+ * Child elements. Absent when the element has no element children.
235
+ *
236
+ * The walk is capped at 100,000 elements per page. PDFium's structure tree is
237
+ * a DAG, so a document whose `/K` arrays repeat the same child expands
238
+ * exponentially when flattened into a tree; the cap bounds that. Real
239
+ * documents do not come close to it.
240
+ */
219
241
  children?: StructElement[];
220
242
  }
221
243
 
@@ -488,6 +510,14 @@ export interface Attachment {
488
510
  name: string;
489
511
  /** MIME type (/Subtype), e.g. 'text/xml'. Empty string if the PDF omits it. */
490
512
  mimeType: string;
513
+ /**
514
+ * Associated-file relationship (/AFRelationship, PDF 2.0) describing the
515
+ * embedded file's role, e.g. 'Alternative' for a ZUGFeRD/Factur-X invoice
516
+ * XML, 'Supplement' for a human-readable companion, or 'Source' / 'Data' /
517
+ * 'Unspecified'. Absent when the PDF omits the entry. Note `addAttachments`
518
+ * cannot set it, so attachments written by this library report no value.
519
+ */
520
+ afRelationship?: string;
491
521
  /** Creation date as a PDF date string (e.g. 'D:20250101120000Z'). Absent if not set. */
492
522
  creationDate?: string;
493
523
  /** Modification date as a PDF date string. Absent if not set. */
@@ -695,7 +725,13 @@ export interface FlattenDocumentOptions {
695
725
  * a watermark marked print-only, for instance.
696
726
  */
697
727
  usage?: 'display' | 'print';
698
- /** Only flatten these page indices. Defaults to every page. */
728
+ /**
729
+ * Only flatten these page indices. Defaults to every page when omitted.
730
+ *
731
+ * An explicitly empty array flattens *nothing* and returns an unchanged copy —
732
+ * so a selection computed by a filter that happens to match no pages is a
733
+ * no-op rather than a document stripped of every annotation.
734
+ */
699
735
  pages?: number[];
700
736
  /** Write to this file path instead of returning a Buffer. */
701
737
  output?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfium-native",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Native Node.js bindings for PDFium",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -493,6 +493,105 @@ async function createEInvoicePdf() {
493
493
  return doc.save();
494
494
  }
495
495
 
496
+ // --- PDF containing a non-BMP (astral) character ---
497
+ // PDFium reports one UTF-16 code unit per character index, so an emoji arrives
498
+ // as two consecutive lone surrogates. A ToUnicode CMap mapping the glyph for
499
+ // 'A' to U+1F600 produces exactly that without needing an embedded font.
500
+ async function createAstralTextPdf() {
501
+ const doc = await PDFDocument.create();
502
+ const page = doc.addPage([200, 100]);
503
+
504
+ const {
505
+ PDFName,
506
+ PDFNumber,
507
+ PDFString,
508
+ PDFOperator,
509
+ PDFOperatorNames: Ops,
510
+ } = await import('pdf-lib');
511
+
512
+ // 'A' -> U+1F600 (surrogate pair D83D DE00), 'B' -> U+00E9
513
+ const cmap = [
514
+ '/CIDInit /ProcSet findresource begin',
515
+ '12 dict begin',
516
+ 'begincmap',
517
+ '1 begincodespacerange',
518
+ '<00> <FF>',
519
+ 'endcodespacerange',
520
+ '2 beginbfchar',
521
+ '<41> <D83DDE00>',
522
+ '<42> <00E9>',
523
+ 'endbfchar',
524
+ 'endcmap',
525
+ 'CMapName currentdict /CMap defineresource pop',
526
+ 'end',
527
+ 'end',
528
+ ].join('\n');
529
+ const toUnicodeRef = doc.context.register(doc.context.flateStream(Buffer.from(cmap, 'latin1')));
530
+
531
+ // The font dictionary is built by hand rather than via embedFont, so the
532
+ // /ToUnicode entry can be attached to it directly.
533
+ const fontRef = doc.context.register(
534
+ doc.context.obj({
535
+ Type: 'Font',
536
+ Subtype: 'Type1',
537
+ BaseFont: 'Helvetica',
538
+ Encoding: 'WinAnsiEncoding',
539
+ ToUnicode: toUnicodeRef,
540
+ }),
541
+ );
542
+ page.node.setFontDictionary(PDFName.of('F1'), fontRef);
543
+
544
+ page.pushOperators(
545
+ PDFOperator.of(Ops.BeginText),
546
+ PDFOperator.of(Ops.SetFontAndSize, [PDFName.of('F1'), PDFNumber.of(24)]),
547
+ PDFOperator.of(Ops.MoveText, [PDFNumber.of(20), PDFNumber.of(40)]),
548
+ PDFOperator.of(Ops.ShowText, [PDFString.of('AB')]),
549
+ PDFOperator.of(Ops.EndText),
550
+ );
551
+
552
+ return doc.save();
553
+ }
554
+
555
+ // --- Structure tree whose /K arrays repeat the same child ---
556
+ // PDFium resolves every kid slot naming a matching dict, so repeating a
557
+ // reference gives an element two live children pointing at one node. Flattening
558
+ // that DAG into a tree doubles the node count per level. 17 links would expand
559
+ // to 2^18-1 = 262,143 elements from ~1.3 KB, so this fixture actually trips the
560
+ // MAX_STRUCT_NODES budget rather than merely demonstrating the growth.
561
+ async function createStructTreeBombPdf() {
562
+ const doc = await PDFDocument.create();
563
+ const font = await doc.embedFont(StandardFonts.Helvetica);
564
+ const page = doc.addPage([200, 100]);
565
+ page.drawText('x', { x: 20, y: 40, size: 12, font });
566
+
567
+ const { PDFName, PDFNumber } = await import('pdf-lib');
568
+
569
+ const root = doc.context.obj({ Type: 'StructTreeRoot' });
570
+ const rootRef = doc.context.register(root);
571
+
572
+ const leaf = doc.context.obj({ Type: 'StructElem', S: 'P', Pg: page.ref, K: 0 });
573
+ const leafRef = doc.context.register(leaf);
574
+
575
+ let childRef = leafRef;
576
+ let childObj = leaf;
577
+ for (let i = 0; i < 17; i++) {
578
+ const node = doc.context.obj({ Type: 'StructElem', S: 'Div' });
579
+ const nodeRef = doc.context.register(node);
580
+ node.set(PDFName.of('K'), doc.context.obj([childRef, childRef]));
581
+ childObj.set(PDFName.of('P'), nodeRef);
582
+ childRef = nodeRef;
583
+ childObj = node;
584
+ }
585
+ childObj.set(PDFName.of('P'), rootRef);
586
+ root.set(PDFName.of('K'), doc.context.obj([childRef]));
587
+ root.set(PDFName.of('ParentTree'), doc.context.obj({ Nums: [0, [leafRef]] }));
588
+ page.node.set(PDFName.of('StructParents'), PDFNumber.of(0));
589
+ doc.catalog.set(PDFName.of('StructTreeRoot'), rootRef);
590
+ doc.catalog.set(PDFName.of('MarkInfo'), doc.context.obj({ Marked: true }));
591
+
592
+ return doc.save();
593
+ }
594
+
496
595
  // --- Tagged PDF with a real structure tree ---
497
596
  // tagged.pdf only sets /MarkInfo, which is enough for metadata.isTagged but
498
597
  // leaves nothing for getStructTree() to read. PDFium needs more than a
@@ -878,6 +977,8 @@ const fixtures = [
878
977
  ['four-page.pdf', createFourPagePdf],
879
978
  ['navigation.pdf', createNavigationPdf],
880
979
  ['struct-tree.pdf', createStructTreePdf],
980
+ ['astral-text.pdf', createAstralTextPdf],
981
+ ['struct-tree-bomb.pdf', createStructTreeBombPdf],
881
982
  ];
882
983
 
883
984
  for (const [name, generator] of fixtures) {
@@ -1,49 +1,49 @@
1
1
  {
2
2
  "pdfium": {
3
- "version": "chromium/7920",
3
+ "version": "chromium/8066",
4
4
  "origin": "https://github.com",
5
5
  "baseUrl": "https://github.com/bblanchon/pdfium-binaries/releases/download",
6
6
  "checksumSource": "Sigstore SLSA provenance attestation (pdfium-attestation.json) attached to the bblanchon/pdfium-binaries release",
7
7
  "targets": {
8
8
  "darwin-arm64": {
9
9
  "asset": "pdfium-mac-arm64.tgz",
10
- "sha256": "c032aa59be58b0f12e41e76a8ef707e347b9841b0426446f646b2568d350ec4f"
10
+ "sha256": "336219e80580b93c6523f44db7dc1de59cc497b13a7390ddac84223f68ca162b"
11
11
  },
12
12
  "darwin-x64": {
13
13
  "asset": "pdfium-mac-x64.tgz",
14
- "sha256": "0c78b8d55a4c97e02c9bb516997253cb972739373009cf29554c959a2f6b194a"
14
+ "sha256": "841ecac278cdd46288dd065873522cf72f3996560d8978f473d336f01d59942c"
15
15
  },
16
16
  "linux-x64": {
17
17
  "asset": "pdfium-linux-x64.tgz",
18
- "sha256": "49ab3afbd4e6c1e284b5f2898129c8bb8a10fd785c1c5392c8c1fc70242f9ced"
18
+ "sha256": "0b43f405477cf2cfc4dbff06905093c3309756c6bca1fb9da99234a2ca97fed2"
19
19
  },
20
20
  "linux-arm64": {
21
21
  "asset": "pdfium-linux-arm64.tgz",
22
- "sha256": "00551476a77fbc1a31c37573eadc9b63f1c366f65ad727539326927da083bb4d"
22
+ "sha256": "0e6f90dccbc6b81fd5d7106abaf164c4222178f024c204d00d526b60fd2ad535"
23
23
  },
24
24
  "linux-arm": {
25
25
  "asset": "pdfium-linux-arm.tgz",
26
- "sha256": "b430bb61d27fee059a80f3219921daf30ac021acda2696f41e0d15b236d38569"
26
+ "sha256": "3253c2bc3d0164482825e96f7abf03a201ac03ef6993250938301a0d04e3a610"
27
27
  },
28
28
  "linux-ppc64": {
29
29
  "asset": "pdfium-linux-ppc64.tgz",
30
- "sha256": "56bb7196e36b219c2a5ebc54c7f140a84b10458911fe16cee2b88e50644684d3"
30
+ "sha256": "4cdb99207f02ad46676486c6cbbb56f2d2bb8822f9f570ef044e464d2a8e70e5"
31
31
  },
32
32
  "linux-musl-x64": {
33
33
  "asset": "pdfium-linux-musl-x64.tgz",
34
- "sha256": "4471ccd9d4f64ff16ac592d97016e404ec888d1c17fc1b3d0cd6e4763b47275c"
34
+ "sha256": "3eb7427ed0a9498260f94a548e2a647f604932050dacaf1707be342602613bec"
35
35
  },
36
36
  "linux-musl-arm64": {
37
37
  "asset": "pdfium-linux-musl-arm64.tgz",
38
- "sha256": "62e75cd629dc6a810d4f72ea864d2ba2f41b7e2141920161868869c8cc2c5912"
38
+ "sha256": "12b963674d596b8f8ecd145a7d68613e6347a87e3888f520c8d42446241d50c6"
39
39
  },
40
40
  "win32-x64": {
41
41
  "asset": "pdfium-win-x64.tgz",
42
- "sha256": "bf25149815b34b00042f48a886653d469c817529dd9cccabb4b509b6465a9526"
42
+ "sha256": "739a57d597d864297909cc40a2411eba728490c76a0fa25e3ea299c7f6b07020"
43
43
  },
44
44
  "win32-arm64": {
45
45
  "asset": "pdfium-win-arm64.tgz",
46
- "sha256": "7d580ba612765063f9bb76b5c6571db5144714a4dc9cd6d448763d788de8f9fb"
46
+ "sha256": "5d04b6d0281e78613ef836dea2e0fefe6831f3ae92b3573e8fdf55330de67d3d"
47
47
  }
48
48
  }
49
49
  }
@@ -1,12 +1,12 @@
1
1
  {
2
- "darwin-arm64": "56bddf0dad15140105f03bb3fd58ed333e77a989fba80af48c5397300a90cd0d",
3
- "darwin-x64": "1075f8658d706d60e3697a3d0d9a12e3af85d66e3dff64424175c1874ce29726",
4
- "linux-arm": "841b1753cd31a9538518c51745e987358468f0f19b92d65b82d61bce6dfc911f",
5
- "linux-arm64": "28de3cd26006c6ceed129d03e3d1955ce0c12a7c5df4d9a0d4ce32406d7719da",
6
- "linux-musl-arm64": "6a0d7b93baa006fa80ddacf29f369669618e9db4c58200062d1e74c479068b81",
7
- "linux-musl-x64": "2050dbe6dddfbc3bc1877740d734474afef1546ca425dc3265b3ef08035b8491",
8
- "linux-ppc64": "5222e7a4370da9cfb65873805f834f047f4398617fac3b05f85e7a2a542c9630",
9
- "linux-x64": "71bfc07c71aa3e51332b6bdd09d5b07f97c09dd9e2c8de7040846d79fab9d384",
10
- "win32-arm64": "45983993f978df229c8acdcd84ee406f463524c61375329ed3f8f2a1defff383",
11
- "win32-x64": "308fd42eab86adc917e3bc278366a6668869d36364e59033fa1b332777c8471a"
2
+ "darwin-arm64": "78c5d4a91d187790d17c0b5641c04c99929cc2e312d5831fe9ddf8cb9c7b873a",
3
+ "darwin-x64": "e8472aa6e372ec2d58fd2afc411c4f79dbd34d848e0f08a1343b95f6f223ba2e",
4
+ "linux-arm": "f053989d5a64abb4ab1ba4b61b78b64f9d3c5612b03b6760e28111d9183e2135",
5
+ "linux-arm64": "80752d0a66c9c4f7acb9ff61f17991f4e41b3d297d69d5f2a8f6b789ac53decf",
6
+ "linux-musl-arm64": "5f271caaee4d66369c92a74d5d063ec5696f604365fd97c412d246d1059f378a",
7
+ "linux-musl-x64": "41c72cbe0ee59cee73e97b25dad1cb0de5a68d9ee5a3a08ce497f95e8f557646",
8
+ "linux-ppc64": "6a8ff6ab81578b2fb47321695c0d7185d16d0b1445c7c600cbe99463909ef73e",
9
+ "linux-x64": "9166a2993e1948e34a08c191b953f70490a6a648c0d076f92c44a064ccd21f5a",
10
+ "win32-arm64": "b03ab956a5c2398c1c633e269d755badbfbb2497ab122b6a9392c7959432291b",
11
+ "win32-x64": "dd006906854326f75d19a321faddacdbb05e9915753d52e9efa4ce58d4cf6dfb"
12
12
  }
@@ -80,6 +80,7 @@ struct AttachmentInfo {
80
80
  int index = 0;
81
81
  std::u16string name;
82
82
  std::u16string mimeType;
83
+ std::u16string afRelationship;
83
84
  std::u16string creationDate;
84
85
  std::u16string modDate;
85
86
  };
@@ -130,6 +131,20 @@ protected:
130
131
  return FPDFAttachment_GetSubtype(attachment, buf, len);
131
132
  });
132
133
 
134
+ // /AFRelationship (PDF 2.0) states an embedded file's role -- a
135
+ // ZUGFeRD/Factur-X invoice XML is marked "Alternative", a human-readable
136
+ // companion "Supplement". PDFium returns an empty string both when the
137
+ // entry is absent and when it is not a name object, so the two are
138
+ // indistinguishable here and the key is omitted rather than reported
139
+ // as "".
140
+ info.afRelationship = ReadU16(
141
+ [&](auto *, unsigned long) {
142
+ return FPDFAttachment_GetAFRelationship(attachment, nullptr, 0);
143
+ },
144
+ [&](FPDF_WCHAR *buf, unsigned long len) {
145
+ return FPDFAttachment_GetAFRelationship(attachment, buf, len);
146
+ });
147
+
133
148
  info.creationDate = ReadAttachmentStringValue(attachment, "CreationDate");
134
149
  info.modDate = ReadAttachmentStringValue(attachment, "ModDate");
135
150
 
@@ -146,6 +161,7 @@ protected:
146
161
  obj.Set("index", Napi::Number::New(env, info.index));
147
162
  SetU16(obj, "name", env, info.name);
148
163
  SetU16(obj, "mimeType", env, info.mimeType);
164
+ SetU16IfPresent(obj, "afRelationship", env, info.afRelationship);
149
165
  SetU16IfPresent(obj, "creationDate", env, info.creationDate);
150
166
  SetU16IfPresent(obj, "modDate", env, info.modDate);
151
167
  arr.Set(i, obj);
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include "document_io.h"
4
4
 
5
+ #include <climits>
5
6
  #include <string>
6
7
  #include <vector>
7
8
 
@@ -82,6 +83,15 @@ protected:
82
83
  return;
83
84
  }
84
85
 
86
+ // unsigned long is 32-bit on Windows, so an oversized payload would be
87
+ // truncated mod 2^32 and silently written short. PDFium rejects anything
88
+ // above INT_MAX anyway; refuse it here with a message that says why.
89
+ if (item.data.size() > static_cast<size_t>(INT_MAX)) {
90
+ FPDF_CloseDocument(doc);
91
+ SetError("Attachment is too large (max 2 GiB): " + Utf8Of(item.name));
92
+ return;
93
+ }
94
+
85
95
  // SetFile must come first: it rebuilds the embedded-file stream and its
86
96
  // /Params, discarding anything already written there.
87
97
  if (!FPDFAttachment_SetFile(attachment, doc, item.data.data(),
@@ -21,17 +21,50 @@
21
21
  // A dense page can hold tens of thousands of characters, so the range options
22
22
  // exist to let callers page through instead of materialising everything.
23
23
 
24
- // Encode a Unicode code point as UTF-16. PDFium stores text page characters in
25
- // wchar_t, which is 32-bit on POSIX and 16-bit on Windows, so a code point
26
- // above the BMP arrives whole on one platform and pre-split on the other.
27
- // Splitting it here makes both behave the same on the JS side.
28
- inline std::u16string CodePointToU16(unsigned int codePoint) {
29
- if (codePoint == 0 || codePoint > 0x10FFFF)
24
+ inline bool IsHighSurrogate(unsigned int u) {
25
+ return u >= 0xD800 && u <= 0xDBFF;
26
+ }
27
+ inline bool IsLowSurrogate(unsigned int u) {
28
+ return u >= 0xDC00 && u <= 0xDFFF;
29
+ }
30
+
31
+ // Encode one text-page entry as the JS string for its `char` field.
32
+ //
33
+ // FPDFText_GetUnicode returns a single UTF-16 *code unit* per character index —
34
+ // on POSIX as well as Windows — so a non-BMP character occupies two consecutive
35
+ // indices holding its high and low surrogate. A lone surrogate cannot survive
36
+ // the trip into a JS string (V8 substitutes U+FFFD), so emitting each unit
37
+ // separately would corrupt every astral character.
38
+ //
39
+ // Instead the pair is joined onto the FIRST index and the second yields an
40
+ // empty string. That keeps both invariants callers rely on: indices still line
41
+ // up one-to-one with getText() and with search() results, and concatenating
42
+ // every `char` still reproduces getText() exactly.
43
+ inline std::u16string EncodeCharAt(const std::vector<unsigned int> &units,
44
+ size_t i) {
45
+ unsigned int u = units[i];
46
+ if (u == 0 || u > 0x10FFFF)
30
47
  return {};
31
- if (codePoint <= 0xFFFF)
32
- return std::u16string(1, static_cast<char16_t>(codePoint));
33
48
 
34
- unsigned int v = codePoint - 0x10000;
49
+ if (IsHighSurrogate(u)) {
50
+ if (i + 1 < units.size() && IsLowSurrogate(units[i + 1])) {
51
+ std::u16string out;
52
+ out.push_back(static_cast<char16_t>(u));
53
+ out.push_back(static_cast<char16_t>(units[i + 1]));
54
+ return out;
55
+ }
56
+ return {}; // unpaired high surrogate — not representable
57
+ }
58
+
59
+ // the low half of a pair already emitted on the previous index
60
+ if (IsLowSurrogate(u))
61
+ return {};
62
+
63
+ if (u <= 0xFFFF)
64
+ return std::u16string(1, static_cast<char16_t>(u));
65
+
66
+ // a whole code point above the BMP, should PDFium ever report one directly
67
+ unsigned int v = u - 0x10000;
35
68
  std::u16string out;
36
69
  out.push_back(static_cast<char16_t>(0xD800 + (v >> 10)));
37
70
  out.push_back(static_cast<char16_t>(0xDC00 + (v & 0x3FF)));
@@ -152,12 +185,19 @@ protected:
152
185
 
153
186
  void OnOK() override {
154
187
  Napi::Env env = Env();
188
+
189
+ // EncodeCharAt needs the next entry to pair a surrogate with its partner
190
+ std::vector<unsigned int> units;
191
+ units.reserve(characters_.size());
192
+ for (const auto &info : characters_)
193
+ units.push_back(info.unicode);
194
+
155
195
  Napi::Array arr = Napi::Array::New(env, characters_.size());
156
196
  for (uint32_t i = 0; i < characters_.size(); i++) {
157
197
  const auto &info = characters_[i];
158
198
  Napi::Object obj = Napi::Object::New(env);
159
199
  obj.Set("index", Napi::Number::New(env, info.index));
160
- SetU16(obj, "char", env, CodePointToU16(info.unicode));
200
+ SetU16(obj, "char", env, EncodeCharAt(units, i));
161
201
  obj.Set("unicode", Napi::Number::New(env, info.unicode));
162
202
  if (info.hasBounds) {
163
203
  obj.Set("bounds", CreateBoundsObject(env, info.left, info.bottom,
@@ -170,7 +210,10 @@ protected:
170
210
  obj.Set("fontSize", Napi::Number::New(env, info.fontSize));
171
211
  obj.Set("fontName", Napi::String::New(env, info.fontName));
172
212
  obj.Set("fontFlags", Napi::Number::New(env, info.fontFlags));
173
- if (info.fontWeight >= 0)
213
+ // -1 is PDFium's error return and 0 means the font declares no weight;
214
+ // neither is a usable value, so omit the key rather than report a
215
+ // meaningless 0 for every non-embedded font.
216
+ if (info.fontWeight > 0)
174
217
  obj.Set("fontWeight", Napi::Number::New(env, info.fontWeight));
175
218
  obj.Set("angle", Napi::Number::New(env, info.angle));
176
219
  obj.Set("isGenerated", Napi::Boolean::New(env, info.isGenerated));
@@ -26,21 +26,21 @@ class FlattenDocumentWorker : public SafeAsyncWorker {
26
26
  public:
27
27
  // buffer variant
28
28
  FlattenDocumentWorker(Napi::Env env, std::vector<uint8_t> data, int flag,
29
- std::vector<int> pages, std::string outputPath,
30
- std::string password)
29
+ std::vector<int> pages, bool hasPageSelection,
30
+ std::string outputPath, std::string password)
31
31
  : SafeAsyncWorker(env), deferred_(Napi::Promise::Deferred::New(env)),
32
32
  bufferData_(std::move(data)), flag_(flag), pages_(std::move(pages)),
33
- outputPath_(std::move(outputPath)), password_(std::move(password)),
34
- useFile_(false) {}
33
+ hasPageSelection_(hasPageSelection), outputPath_(std::move(outputPath)),
34
+ password_(std::move(password)), useFile_(false) {}
35
35
 
36
36
  // file path variant
37
37
  FlattenDocumentWorker(Napi::Env env, std::string filePath, int flag,
38
- std::vector<int> pages, std::string outputPath,
39
- std::string password)
38
+ std::vector<int> pages, bool hasPageSelection,
39
+ std::string outputPath, std::string password)
40
40
  : SafeAsyncWorker(env), deferred_(Napi::Promise::Deferred::New(env)),
41
41
  filePath_(std::move(filePath)), flag_(flag), pages_(std::move(pages)),
42
- outputPath_(std::move(outputPath)), password_(std::move(password)),
43
- useFile_(true) {}
42
+ hasPageSelection_(hasPageSelection), outputPath_(std::move(outputPath)),
43
+ password_(std::move(password)), useFile_(true) {}
44
44
 
45
45
  Napi::Promise Promise() { return deferred_.Promise(); }
46
46
 
@@ -58,8 +58,12 @@ protected:
58
58
 
59
59
  int pageCount = FPDF_GetPageCount(doc);
60
60
 
61
+ // An explicitly empty selection means "flatten nothing", NOT "flatten
62
+ // everything" — a caller that computes `pages` from a filter and legitimately
63
+ // gets [] must end up with an unchanged copy, not a document stripped of
64
+ // every annotation.
61
65
  std::vector<int> targets = pages_;
62
- if (targets.empty()) {
66
+ if (!hasPageSelection_) {
63
67
  targets.reserve(pageCount);
64
68
  for (int i = 0; i < pageCount; i++)
65
69
  targets.push_back(i);
@@ -126,6 +130,7 @@ private:
126
130
  std::string filePath_;
127
131
  int flag_ = FLAT_NORMALDISPLAY;
128
132
  std::vector<int> pages_;
133
+ bool hasPageSelection_ = false;
129
134
  std::string outputPath_;
130
135
  std::string password_;
131
136
  bool useFile_ = false;
@@ -627,6 +627,7 @@ Napi::Value FlattenDocument(const Napi::CallbackInfo &info) {
627
627
 
628
628
  int flag = FLAT_NORMALDISPLAY;
629
629
  std::vector<int> pages;
630
+ bool hasPageSelection = false;
630
631
  std::string outputPath;
631
632
  std::string password;
632
633
 
@@ -643,6 +644,7 @@ Napi::Value FlattenDocument(const Napi::CallbackInfo &info) {
643
644
  }
644
645
  }
645
646
  if (opts.Has("pages") && opts.Get("pages").IsArray()) {
647
+ hasPageSelection = true;
646
648
  Napi::Array jsPages = opts.Get("pages").As<Napi::Array>();
647
649
  pages.reserve(jsPages.Length());
648
650
  for (uint32_t i = 0; i < jsPages.Length(); i++) {
@@ -664,12 +666,14 @@ Napi::Value FlattenDocument(const Napi::CallbackInfo &info) {
664
666
  auto buffer = arg.As<Napi::Buffer<uint8_t>>();
665
667
  std::vector<uint8_t> data(buffer.Data(), buffer.Data() + buffer.Length());
666
668
  worker = new FlattenDocumentWorker(env, std::move(data), flag,
667
- std::move(pages), std::move(outputPath),
669
+ std::move(pages), hasPageSelection,
670
+ std::move(outputPath),
668
671
  std::move(password));
669
672
  } else if (arg.IsString()) {
670
673
  std::string path = arg.As<Napi::String>().Utf8Value();
671
674
  worker = new FlattenDocumentWorker(env, std::move(path), flag,
672
- std::move(pages), std::move(outputPath),
675
+ std::move(pages), hasPageSelection,
676
+ std::move(outputPath),
673
677
  std::move(password));
674
678
  } else {
675
679
  Napi::TypeError::New(env, "Expected a Buffer or string path argument")
@@ -24,6 +24,23 @@
24
24
  // maximum structure tree recursion depth, mirroring MAX_BOOKMARK_DEPTH
25
25
  constexpr int MAX_STRUCT_DEPTH = 64;
26
26
 
27
+ // Maximum number of elements returned for one page.
28
+ //
29
+ // A depth cap alone does not bound the work: PDFium's structure tree is a DAG,
30
+ // and CPDF_StructElement::UpdateKidIfElement resolves EVERY kid slot whose dict
31
+ // matches, so a /K array naming the same child twice gives that element two
32
+ // live children pointing at one node. Flattening that into a tree doubles the
33
+ // node count per level — a 1.8 KB file with a 12-link chain expands to 4095
34
+ // elements, and each extra link doubles it again. Since the whole traversal
35
+ // runs holding g_pdfium_mutex, an unbounded walk would stall every other
36
+ // PDFium call in the process, not just this one.
37
+ //
38
+ // The value is deliberately low enough that reaching it stays cheap: a single
39
+ // page's structure tree covers only that page's own content, so a real document
40
+ // runs to hundreds of elements, not thousands. 20,000 leaves ample headroom
41
+ // while keeping the worst case fast even on an emulated runner.
42
+ constexpr int MAX_STRUCT_NODES = 20000;
43
+
27
44
  // read one of the struct element's UTF-16LE string properties
28
45
  template <typename Fn> inline std::u16string ReadStructString(Fn fn) {
29
46
  return ReadU16([&](auto *, unsigned long) { return fn(nullptr, 0); },
@@ -66,6 +83,8 @@ protected:
66
83
 
67
84
  int count = FPDF_StructTree_CountChildren(tree);
68
85
  for (int i = 0; i < count; i++) {
86
+ if (nodeCount_ >= MAX_STRUCT_NODES)
87
+ break;
69
88
  FPDF_STRUCTELEMENT element = FPDF_StructTree_GetChildAtIndex(tree, i);
70
89
  if (!element)
71
90
  continue;
@@ -87,6 +106,7 @@ protected:
87
106
  private:
88
107
  StructElementInfo ReadElement(FPDF_STRUCTELEMENT element, int depth) {
89
108
  StructElementInfo info;
109
+ nodeCount_++;
90
110
 
91
111
  info.type = ReadStructString([&](FPDF_WCHAR *buf, unsigned long len) {
92
112
  return FPDF_StructElement_GetType(element, buf, len);
@@ -113,12 +133,16 @@ private:
113
133
  info.markedContentId = FPDF_StructElement_GetMarkedContentID(element);
114
134
 
115
135
  // A malformed or hostile PDF can nest structure elements arbitrarily deep,
116
- // or cycle; stop descending rather than overflow the stack.
117
- if (depth >= MAX_STRUCT_DEPTH)
136
+ // or cycle; stop descending rather than overflow the stack. The node budget
137
+ // additionally bounds *breadth*, which the depth cap does not — see
138
+ // MAX_STRUCT_NODES.
139
+ if (depth >= MAX_STRUCT_DEPTH || nodeCount_ >= MAX_STRUCT_NODES)
118
140
  return info;
119
141
 
120
142
  int childCount = FPDF_StructElement_CountChildren(element);
121
143
  for (int i = 0; i < childCount; i++) {
144
+ if (nodeCount_ >= MAX_STRUCT_NODES)
145
+ break;
122
146
  // returns null for children that are content references rather than
123
147
  // elements, which is expected and simply skipped
124
148
  FPDF_STRUCTELEMENT child =
@@ -161,4 +185,5 @@ private:
161
185
  std::shared_ptr<std::atomic<bool>> pageAlive_;
162
186
  std::shared_ptr<std::atomic<bool>> docAlive_;
163
187
  std::vector<StructElementInfo> roots_;
188
+ int nodeCount_ = 0;
164
189
  };