pdf-parser.js 5.2.24 → 5.2.26

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.
Files changed (95) hide show
  1. package/dist/afm-widths.cjs +1 -1
  2. package/dist/afm-widths.js +1 -1
  3. package/dist/builtin-encoding.cjs +1 -1
  4. package/dist/builtin-encoding.d.cts +2 -2
  5. package/dist/builtin-encoding.d.ts +2 -2
  6. package/dist/builtin-encoding.js +1 -1
  7. package/dist/cff-bounds.d.cts +1 -1
  8. package/dist/cff-bounds.d.ts +1 -1
  9. package/dist/cff.d.cts +1 -1
  10. package/dist/cff.d.ts +1 -1
  11. package/dist/cmap-table.d.cts +1 -1
  12. package/dist/cmap-table.d.ts +1 -1
  13. package/dist/cmap.d.cts +1 -1
  14. package/dist/cmap.d.ts +1 -1
  15. package/dist/content-write.cjs +1 -1
  16. package/dist/content-write.d.cts +3 -3
  17. package/dist/content-write.d.ts +3 -3
  18. package/dist/content-write.js +1 -1
  19. package/dist/document.d.cts +4 -4
  20. package/dist/document.d.ts +4 -4
  21. package/dist/{embedded-font-BRhZfEN2.d.ts → embedded-font-Bnhh4juV.d.ts} +3 -3
  22. package/dist/{embedded-font-DJUn9kMH.d.cts → embedded-font-CEf-zBCA.d.cts} +3 -3
  23. package/dist/embedded-font-write.d.cts +1 -1
  24. package/dist/embedded-font-write.d.ts +1 -1
  25. package/dist/embedded-font.cjs +1 -1
  26. package/dist/embedded-font.d.cts +1 -1
  27. package/dist/embedded-font.d.ts +1 -1
  28. package/dist/embedded-font.js +1 -1
  29. package/dist/encoding.cjs +1 -1
  30. package/dist/encoding.js +1 -1
  31. package/dist/encrypt-write.d.cts +2 -2
  32. package/dist/encrypt-write.d.ts +2 -2
  33. package/dist/encrypt.d.cts +2 -2
  34. package/dist/encrypt.d.ts +2 -2
  35. package/dist/font-read.cjs +1 -1
  36. package/dist/font-read.d.cts +2 -2
  37. package/dist/font-read.d.ts +2 -2
  38. package/dist/font-read.js +1 -1
  39. package/dist/font-registry.d.cts +2 -2
  40. package/dist/font-registry.d.ts +2 -2
  41. package/dist/gdef-table.d.cts +3 -3
  42. package/dist/gdef-table.d.ts +3 -3
  43. package/dist/{glyf-vMGtP1pb.d.ts → glyf-Bv1katwK.d.ts} +4 -4
  44. package/dist/{glyf-nXC-IDRW.d.cts → glyf-DFyknMrW.d.cts} +4 -4
  45. package/dist/{glyf-contours-zRQbj-Yp.d.cts → glyf-contours-BRpvd0rt.d.cts} +1 -1
  46. package/dist/{glyf-contours-OSdG6Edr.d.ts → glyf-contours-C0epBNqP.d.ts} +1 -1
  47. package/dist/glyf-contours.d.cts +1 -1
  48. package/dist/glyf-contours.d.ts +1 -1
  49. package/dist/glyf.d.cts +1 -1
  50. package/dist/glyf.d.ts +1 -1
  51. package/dist/gsub-table.cjs +1 -1
  52. package/dist/gsub-table.js +1 -1
  53. package/dist/hmtx-table.d.cts +1 -1
  54. package/dist/hmtx-table.d.ts +1 -1
  55. package/dist/image/jbig2-generic.cjs +2 -2
  56. package/dist/image/jbig2-generic.js +2 -2
  57. package/dist/image/jpeg2000-tagtree.cjs +1 -1
  58. package/dist/image/jpeg2000-tagtree.js +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.d.cts +1 -1
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/interpret.cjs +2 -2
  64. package/dist/interpret.d.cts +4 -4
  65. package/dist/interpret.d.ts +4 -4
  66. package/dist/interpret.js +2 -2
  67. package/dist/math-content-write.cjs +3 -3
  68. package/dist/math-content-write.js +3 -3
  69. package/dist/math-font.d.cts +4 -4
  70. package/dist/math-font.d.ts +4 -4
  71. package/dist/measure.cjs +1 -1
  72. package/dist/measure.js +1 -1
  73. package/dist/navigation.d.cts +1 -1
  74. package/dist/navigation.d.ts +1 -1
  75. package/dist/ot-layout-common.d.cts +2 -2
  76. package/dist/ot-layout-common.d.ts +2 -2
  77. package/dist/parse.cjs +5 -0
  78. package/dist/parse.d.cts +2 -1
  79. package/dist/parse.d.ts +2 -1
  80. package/dist/parse.js +5 -1
  81. package/dist/raster.cjs +10 -40
  82. package/dist/raster.d.cts +4 -4
  83. package/dist/raster.d.ts +4 -4
  84. package/dist/raster.js +10 -40
  85. package/dist/structure.cjs +4 -4
  86. package/dist/structure.js +4 -4
  87. package/dist/winansi.cjs +1 -1
  88. package/dist/winansi.js +1 -1
  89. package/dist/write.cjs +4 -4
  90. package/dist/write.d.cts +1 -1
  91. package/dist/write.d.ts +1 -1
  92. package/dist/write.js +4 -4
  93. package/package.json +2 -2
  94. package/dist/{afm-widths-BTu0IDp2.cjs → afm-widths-BYiX2L9D.cjs} +1 -1
  95. package/dist/{afm-widths-De_QMWgC.js → afm-widths-blUDDjlI.js} +1 -1
@@ -91,14 +91,14 @@ function resolveTemplate(template) {
91
91
  if (positions === void 0) throw new require_image_jbig2_errors.Jbig2UnsupportedError(`generic region declares GBTEMPLATE ${String(template)}, which is outside the 0-3 range T.88 6.2.5.3 defines`);
92
92
  return positions;
93
93
  }
94
- function flattenTemplate(positions, at) {
94
+ function flattenTemplate(positions, atPixels) {
95
95
  const dx = new Int32Array(positions.length);
96
96
  const dy = new Int32Array(positions.length);
97
97
  positions.forEach((position, i) => {
98
98
  const offset = position.kind === "fixed" ? {
99
99
  x: position.dx,
100
100
  y: position.dy
101
- } : at[position.index] ?? {
101
+ } : atPixels[position.index] ?? {
102
102
  x: 0,
103
103
  y: 0
104
104
  };
@@ -90,14 +90,14 @@ function resolveTemplate(template) {
90
90
  if (positions === void 0) throw new Jbig2UnsupportedError(`generic region declares GBTEMPLATE ${String(template)}, which is outside the 0-3 range T.88 6.2.5.3 defines`);
91
91
  return positions;
92
92
  }
93
- function flattenTemplate(positions, at) {
93
+ function flattenTemplate(positions, atPixels) {
94
94
  const dx = new Int32Array(positions.length);
95
95
  const dy = new Int32Array(positions.length);
96
96
  positions.forEach((position, i) => {
97
97
  const offset = position.kind === "fixed" ? {
98
98
  x: position.dx,
99
99
  y: position.dy
100
- } : at[position.index] ?? {
100
+ } : atPixels[position.index] ?? {
101
101
  x: 0,
102
102
  y: 0
103
103
  };
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_image_jpeg2000_errors = require("./jpeg2000-errors.cjs");
3
3
  //#region src/image/jpeg2000-tagtree.ts
4
+ const SENTINEL_VALUE = 2147483647;
4
5
  var PacketBitReader = class {
5
6
  data;
6
7
  end;
@@ -99,7 +100,6 @@ var TagTree = class {
99
100
  return this.value[y * (this.levelWidths[0] ?? 1) + x] ?? SENTINEL_VALUE;
100
101
  }
101
102
  };
102
- const SENTINEL_VALUE = 2147483647;
103
103
  //#endregion
104
104
  exports.PacketBitReader = PacketBitReader;
105
105
  exports.TagTree = TagTree;
@@ -1,5 +1,6 @@
1
1
  import { Jpeg2000ParseError } from "./jpeg2000-errors.js";
2
2
  //#region src/image/jpeg2000-tagtree.ts
3
+ const SENTINEL_VALUE = 2147483647;
3
4
  var PacketBitReader = class {
4
5
  data;
5
6
  end;
@@ -98,6 +99,5 @@ var TagTree = class {
98
99
  return this.value[y * (this.levelWidths[0] ?? 1) + x] ?? SENTINEL_VALUE;
99
100
  }
100
101
  };
101
- const SENTINEL_VALUE = 2147483647;
102
102
  //#endregion
103
103
  export { PacketBitReader, TagTree };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
2
+ const require_afm_widths = require("./afm-widths-BYiX2L9D.cjs");
3
3
  const require_image_ccitt = require("./image/ccitt.cjs");
4
4
  const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
5
5
  const require_image_jbig2 = require("./image/jbig2.cjs");
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnost
3
3
  import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.cjs";
4
4
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
5
5
  import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
6
- import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-DJUn9kMH.cjs";
6
+ import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-CEf-zBCA.cjs";
7
7
  import { WinAnsiSubstitution } from "./winansi.cjs";
8
8
  import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.cjs";
9
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.cjs";
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnost
3
3
  import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.js";
4
4
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
5
5
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
6
- import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-BRhZfEN2.js";
6
+ import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-Bnhh4juV.js";
7
7
  import { WinAnsiSubstitution } from "./winansi.js";
8
8
  import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.js";
9
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as STANDARD_METRICS } from "./afm-widths-De_QMWgC.js";
1
+ import { t as STANDARD_METRICS } from "./afm-widths-blUDDjlI.js";
2
2
  import { decodeCcittFax } from "./image/ccitt.js";
3
3
  import { Jbig2ParseError, Jbig2UnsupportedError } from "./image/jbig2-errors.js";
4
4
  import { decodeJbig2Embedded } from "./image/jbig2.js";
@@ -487,10 +487,10 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
487
487
  ...vertical ? { vertical: true } : {}
488
488
  });
489
489
  };
490
- const showText = (bytes) => {
490
+ const showText = (textBytes) => {
491
491
  showTextArray([{
492
492
  kind: "string",
493
- bytes,
493
+ bytes: textBytes,
494
494
  hex: false
495
495
  }]);
496
496
  };
@@ -106,12 +106,12 @@ interface GlyphAdvance {
106
106
  readonly vertical?: VerticalGlyphAdvance;
107
107
  }
108
108
  interface FontMetricsPort {
109
- glyphAdvance(fontResourceName: string, resources: PdfDict, codes: Uint8Array<ArrayBuffer>, byteOffset: number): GlyphAdvance | undefined;
110
- isVertical(fontResourceName: string, resources: PdfDict): boolean;
109
+ glyphAdvance: (fontResourceName: string, resources: PdfDict, codes: Uint8Array<ArrayBuffer>, byteOffset: number) => GlyphAdvance | undefined;
110
+ isVertical: (fontResourceName: string, resources: PdfDict) => boolean;
111
111
  }
112
112
  interface PdfObjectResolver {
113
- resolve(obj: PdfObject | undefined): PdfObject | undefined;
114
- resolveDict(obj: PdfObject | undefined): PdfDict | undefined;
113
+ resolve: (obj: PdfObject | undefined) => PdfObject | undefined;
114
+ resolveDict: (obj: PdfObject | undefined) => PdfDict | undefined;
115
115
  }
116
116
  interface InterpretContext {
117
117
  readonly fontMetrics: FontMetricsPort;
@@ -106,12 +106,12 @@ interface GlyphAdvance {
106
106
  readonly vertical?: VerticalGlyphAdvance;
107
107
  }
108
108
  interface FontMetricsPort {
109
- glyphAdvance(fontResourceName: string, resources: PdfDict, codes: Uint8Array<ArrayBuffer>, byteOffset: number): GlyphAdvance | undefined;
110
- isVertical(fontResourceName: string, resources: PdfDict): boolean;
109
+ glyphAdvance: (fontResourceName: string, resources: PdfDict, codes: Uint8Array<ArrayBuffer>, byteOffset: number) => GlyphAdvance | undefined;
110
+ isVertical: (fontResourceName: string, resources: PdfDict) => boolean;
111
111
  }
112
112
  interface PdfObjectResolver {
113
- resolve(obj: PdfObject | undefined): PdfObject | undefined;
114
- resolveDict(obj: PdfObject | undefined): PdfDict | undefined;
113
+ resolve: (obj: PdfObject | undefined) => PdfObject | undefined;
114
+ resolveDict: (obj: PdfObject | undefined) => PdfDict | undefined;
115
115
  }
116
116
  interface InterpretContext {
117
117
  readonly fontMetrics: FontMetricsPort;
package/dist/interpret.js CHANGED
@@ -486,10 +486,10 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
486
486
  ...vertical ? { vertical: true } : {}
487
487
  });
488
488
  };
489
- const showText = (bytes) => {
489
+ const showText = (textBytes) => {
490
490
  showTextArray([{
491
491
  kind: "string",
492
- bytes,
492
+ bytes: textBytes,
493
493
  hex: false
494
494
  }]);
495
495
  };
@@ -28,15 +28,15 @@ function encodeGlyphRunToCids(font, text) {
28
28
  return bytes;
29
29
  }
30
30
  function writeGlyphRun(writer, positioned, item, ctx) {
31
- const cidBytes = encodeGlyphRunToCids(ctx.font, item.text);
32
- if (cidBytes.length === 0) return;
31
+ const encodedCids = encodeGlyphRunToCids(ctx.font, item.text);
32
+ if (encodedCids.length === 0) return;
33
33
  const x = toPdfX(positioned, item.xPt);
34
34
  const y = toPdfY(positioned, item.yPt);
35
35
  writer.writeAscii("BT\n");
36
36
  writer.writeAscii(`/${ctx.resourceName} ${require_serialize.formatNumber(item.sizePt)} Tf\n`);
37
37
  writeRgbOperator(writer, item.color, "rg");
38
38
  writer.writeAscii(`1 0 0 1 ${require_serialize.formatNumber(x)} ${require_serialize.formatNumber(y)} Tm\n`);
39
- require_serialize.writeObject(writer, require_objects.pdfHexString(cidBytes));
39
+ require_serialize.writeObject(writer, require_objects.pdfHexString(encodedCids));
40
40
  writer.writeAscii(" Tj\n");
41
41
  writer.writeAscii("ET\n");
42
42
  }
@@ -27,15 +27,15 @@ function encodeGlyphRunToCids(font, text) {
27
27
  return bytes;
28
28
  }
29
29
  function writeGlyphRun(writer, positioned, item, ctx) {
30
- const cidBytes = encodeGlyphRunToCids(ctx.font, item.text);
31
- if (cidBytes.length === 0) return;
30
+ const encodedCids = encodeGlyphRunToCids(ctx.font, item.text);
31
+ if (encodedCids.length === 0) return;
32
32
  const x = toPdfX(positioned, item.xPt);
33
33
  const y = toPdfY(positioned, item.yPt);
34
34
  writer.writeAscii("BT\n");
35
35
  writer.writeAscii(`/${ctx.resourceName} ${formatNumber(item.sizePt)} Tf\n`);
36
36
  writeRgbOperator(writer, item.color, "rg");
37
37
  writer.writeAscii(`1 0 0 1 ${formatNumber(x)} ${formatNumber(y)} Tm\n`);
38
- writeObject(writer, pdfHexString(cidBytes));
38
+ writeObject(writer, pdfHexString(encodedCids));
39
39
  writer.writeAscii(" Tj\n");
40
40
  writer.writeAscii("ET\n");
41
41
  }
@@ -16,11 +16,11 @@ interface MathFont {
16
16
  readonly metrics: MathFontMetrics;
17
17
  readonly cffBytes: Uint8Array<ArrayBuffer>;
18
18
  readonly descriptor: MathFontDescriptorMetrics;
19
- glyphId(codePoint: number): number | undefined;
20
- glyphSpaceWidth(glyphId: number): number;
21
- glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
19
+ glyphId: (codePoint: number) => number | undefined;
20
+ glyphSpaceWidth: (glyphId: number) => number;
21
+ glyphInkBounds: (glyphId: number) => GlyphInkBounds | undefined;
22
22
  readonly minConnectorOverlap: number;
23
- stretchyConstruction(codePoint: number, axis: MathStretchAxis): MathGlyphConstruction | undefined;
23
+ stretchyConstruction: (codePoint: number, axis: MathStretchAxis) => MathGlyphConstruction | undefined;
24
24
  }
25
25
  interface LoadedMathFont {
26
26
  readonly font: MathFont;
@@ -16,11 +16,11 @@ interface MathFont {
16
16
  readonly metrics: MathFontMetrics;
17
17
  readonly cffBytes: Uint8Array<ArrayBuffer>;
18
18
  readonly descriptor: MathFontDescriptorMetrics;
19
- glyphId(codePoint: number): number | undefined;
20
- glyphSpaceWidth(glyphId: number): number;
21
- glyphInkBounds(glyphId: number): GlyphInkBounds | undefined;
19
+ glyphId: (codePoint: number) => number | undefined;
20
+ glyphSpaceWidth: (glyphId: number) => number;
21
+ glyphInkBounds: (glyphId: number) => GlyphInkBounds | undefined;
22
22
  readonly minConnectorOverlap: number;
23
- stretchyConstruction(codePoint: number, axis: MathStretchAxis): MathGlyphConstruction | undefined;
23
+ stretchyConstruction: (codePoint: number, axis: MathStretchAxis) => MathGlyphConstruction | undefined;
24
24
  }
25
25
  interface LoadedMathFont {
26
26
  readonly font: MathFont;
package/dist/measure.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
2
+ const require_afm_widths = require("./afm-widths-BYiX2L9D.cjs");
3
3
  const require_embedded_font = require("./embedded-font.cjs");
4
4
  const require_font_registry = require("./font-registry.cjs");
5
5
  //#region src/measure.ts
package/dist/measure.js CHANGED
@@ -1,4 +1,4 @@
1
- import { h as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-De_QMWgC.js";
1
+ import { h as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-blUDDjlI.js";
2
2
  import { encodeForShowEmbedded } from "./embedded-font.js";
3
3
  import { resolveFaceWithRegistry } from "./font-registry.js";
4
4
  //#region src/measure.ts
@@ -10,7 +10,7 @@ declare function parseDestination(value: PdfObject | undefined, resolver: PdfObj
10
10
  } | undefined;
11
11
  interface DestinationRegistry {
12
12
  readonly entries: readonly LayoutDestination[];
13
- intern(obj: PdfObject | undefined): string | undefined;
13
+ intern: (obj: PdfObject | undefined) => string | undefined;
14
14
  }
15
15
  declare function createDestinationRegistry(catalog: PdfDict, resolver: PdfObjectResolver, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): DestinationRegistry;
16
16
  declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): LayoutOutlineItem[];
@@ -10,7 +10,7 @@ declare function parseDestination(value: PdfObject | undefined, resolver: PdfObj
10
10
  } | undefined;
11
11
  interface DestinationRegistry {
12
12
  readonly entries: readonly LayoutDestination[];
13
- intern(obj: PdfObject | undefined): string | undefined;
13
+ intern: (obj: PdfObject | undefined) => string | undefined;
14
14
  }
15
15
  declare function createDestinationRegistry(catalog: PdfDict, resolver: PdfObjectResolver, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): DestinationRegistry;
16
16
  declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): LayoutOutlineItem[];
@@ -1,7 +1,7 @@
1
1
  //#region src/ot-layout-common.d.ts
2
2
  interface CoverageTable {
3
- coverageIndex(glyphId: number): number | undefined;
4
- entries(): IterableIterator<readonly [number, number]>;
3
+ coverageIndex: (glyphId: number) => number | undefined;
4
+ entries: () => IterableIterator<readonly [number, number]>;
5
5
  }
6
6
  declare function parseCoverage(bytes: Uint8Array<ArrayBuffer>, coverageOffset: number): CoverageTable | undefined;
7
7
  type ClassDefTable = (glyphId: number) => number;
@@ -1,7 +1,7 @@
1
1
  //#region src/ot-layout-common.d.ts
2
2
  interface CoverageTable {
3
- coverageIndex(glyphId: number): number | undefined;
4
- entries(): IterableIterator<readonly [number, number]>;
3
+ coverageIndex: (glyphId: number) => number | undefined;
4
+ entries: () => IterableIterator<readonly [number, number]>;
5
5
  }
6
6
  declare function parseCoverage(bytes: Uint8Array<ArrayBuffer>, coverageOffset: number): CoverageTable | undefined;
7
7
  type ClassDefTable = (glyphId: number) => number;
package/dist/parse.cjs CHANGED
@@ -22,6 +22,10 @@ function parseValue(reader, sink) {
22
22
  });
23
23
  return require_objects.pdfNull();
24
24
  }
25
+ return assertNeverToken(token);
26
+ }
27
+ function assertNeverToken(token) {
28
+ throw new Error(`parseValue: unhandled token ${JSON.stringify(token)}`);
25
29
  }
26
30
  function parseKeywordValue(keyword, sink) {
27
31
  if (keyword === "true") return require_objects.pdfBool(true);
@@ -226,5 +230,6 @@ function parseIndirectObject(reader, sink) {
226
230
  };
227
231
  }
228
232
  //#endregion
233
+ exports.assertNeverToken = assertNeverToken;
229
234
  exports.parseIndirectObject = parseIndirectObject;
230
235
  exports.parseValue = parseValue;
package/dist/parse.d.cts CHANGED
@@ -3,6 +3,7 @@ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  import { ByteReader } from "./bytes/reader.cjs";
4
4
  //#region src/parse.d.ts
5
5
  declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
6
+ declare function assertNeverToken(token: never): never;
6
7
  interface ParsedIndirectObject {
7
8
  readonly num: number;
8
9
  readonly gen: number;
@@ -10,4 +11,4 @@ interface ParsedIndirectObject {
10
11
  }
11
12
  declare function parseIndirectObject(reader: ByteReader, sink: PdfDiagnosticSink): ParsedIndirectObject | undefined;
12
13
  //#endregion
13
- export { ParsedIndirectObject, parseIndirectObject, parseValue };
14
+ export { ParsedIndirectObject, assertNeverToken, parseIndirectObject, parseValue };
package/dist/parse.d.ts CHANGED
@@ -3,6 +3,7 @@ import { r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  import { ByteReader } from "./bytes/reader.js";
4
4
  //#region src/parse.d.ts
5
5
  declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
6
+ declare function assertNeverToken(token: never): never;
6
7
  interface ParsedIndirectObject {
7
8
  readonly num: number;
8
9
  readonly gen: number;
@@ -10,4 +11,4 @@ interface ParsedIndirectObject {
10
11
  }
11
12
  declare function parseIndirectObject(reader: ByteReader, sink: PdfDiagnosticSink): ParsedIndirectObject | undefined;
12
13
  //#endregion
13
- export { ParsedIndirectObject, parseIndirectObject, parseValue };
14
+ export { ParsedIndirectObject, assertNeverToken, parseIndirectObject, parseValue };
package/dist/parse.js CHANGED
@@ -21,6 +21,10 @@ function parseValue(reader, sink) {
21
21
  });
22
22
  return pdfNull();
23
23
  }
24
+ return assertNeverToken(token);
25
+ }
26
+ function assertNeverToken(token) {
27
+ throw new Error(`parseValue: unhandled token ${JSON.stringify(token)}`);
24
28
  }
25
29
  function parseKeywordValue(keyword, sink) {
26
30
  if (keyword === "true") return pdfBool(true);
@@ -225,4 +229,4 @@ function parseIndirectObject(reader, sink) {
225
229
  };
226
230
  }
227
231
  //#endregion
228
- export { parseIndirectObject, parseValue };
232
+ export { assertNeverToken, parseIndirectObject, parseValue };
package/dist/raster.cjs CHANGED
@@ -533,39 +533,18 @@ function buildTextOutlineFace(fontDict, resolver, fontResolver, fontResourceName
533
533
  const subtype = require_objects.asName(require_objects.dictGet(fontDict, "Subtype"));
534
534
  if (subtype === "Type0") {
535
535
  const encoding = resolver.resolve(require_objects.dictGet(fontDict, "Encoding"));
536
- if (encoding?.kind !== "name" || encoding.name !== "Identity-H" && encoding.name !== "Identity-V") {
537
- unavailable("a Type0 font whose /Encoding is neither Identity-H nor Identity-V (a predefined or embedded CMap this raster walk does not decode)");
538
- return;
539
- }
536
+ if (encoding?.kind !== "name" || encoding.name !== "Identity-H" && encoding.name !== "Identity-V") return unavailable("a Type0 font whose /Encoding is neither Identity-H nor Identity-V (a predefined or embedded CMap this raster walk does not decode)");
540
537
  const descendants = require_objects.asArray(require_objects.dictGet(fontDict, "DescendantFonts"));
541
538
  const descendant = descendants !== void 0 ? resolver.resolveDict(descendants[0]) : void 0;
542
- if (descendant === void 0) {
543
- unavailable("a Type0 font with no readable /DescendantFonts entry");
544
- return;
545
- }
539
+ if (descendant === void 0) return unavailable("a Type0 font with no readable /DescendantFonts entry");
546
540
  const descendantSubtype = require_objects.asName(require_objects.dictGet(descendant, "Subtype"));
547
- if (descendantSubtype === "CIDFontType0") {
548
- cff();
549
- return;
550
- }
551
- if (descendantSubtype !== "CIDFontType2") {
552
- unavailable(`a descendant font of subtype ${descendantSubtype ?? "(none)"}`);
553
- return;
554
- }
541
+ if (descendantSubtype === "CIDFontType0") return cff();
542
+ if (descendantSubtype !== "CIDFontType2") return unavailable(`a descendant font of subtype ${descendantSubtype ?? "(none)"}`);
555
543
  const cidToGidMap = resolver.resolve(require_objects.dictGet(descendant, "CIDToGIDMap"));
556
544
  const program = openEmbeddedProgram(descendant, resolver);
557
- if (program.kind === "cff") {
558
- cff();
559
- return;
560
- }
561
- if (program.kind === "absent") {
562
- unavailable("no readable /FontFile2 (or glyf-bearing /FontFile3) stream");
563
- return;
564
- }
565
- if (cidToGidMap !== void 0 && cidToGidMap.kind !== "name" && cidToGidMap.kind !== "stream") {
566
- unavailable("a /CIDToGIDMap that is neither /Identity nor a readable stream");
567
- return;
568
- }
545
+ if (program.kind === "cff") return cff();
546
+ if (program.kind === "absent") return unavailable("no readable /FontFile2 (or glyf-bearing /FontFile3) stream");
547
+ if (cidToGidMap !== void 0 && cidToGidMap.kind !== "name" && cidToGidMap.kind !== "stream") return unavailable("a /CIDToGIDMap that is neither /Identity nor a readable stream");
569
548
  if (cidToGidMap?.kind === "stream") {
570
549
  const decodedBytes = require_filters.decodeStream(cidToGidMap.raw, cidToGidMap.dict, require_diagnostics.NOOP_DIAGNOSTIC_SINK).bytes;
571
550
  const entries = [];
@@ -587,19 +566,10 @@ function buildTextOutlineFace(fontDict, resolver, fontResolver, fontResourceName
587
566
  }
588
567
  if (subtype === "TrueType") {
589
568
  const program = openEmbeddedProgram(fontDict, resolver);
590
- if (program.kind === "cff") {
591
- cff();
592
- return;
593
- }
594
- if (program.kind === "absent") {
595
- unavailable("no /FontDescriptor or no readable embedded program (a standard-14 or otherwise unembedded face states no outlines at all)");
596
- return;
597
- }
569
+ if (program.kind === "cff") return cff();
570
+ if (program.kind === "absent") return unavailable("no /FontDescriptor or no readable embedded program (a standard-14 or otherwise unembedded face states no outlines at all)");
598
571
  const cmapLookup = require_cmap_table.buildCmapLookup(program.sfnt);
599
- if (cmapLookup === void 0) {
600
- unavailable("an embedded program with no usable Unicode cmap subtable");
601
- return;
602
- }
572
+ if (cmapLookup === void 0) return unavailable("an embedded program with no usable Unicode cmap subtable");
603
573
  return {
604
574
  glyf: program.face.glyf,
605
575
  unitsPerEm: program.face.unitsPerEm,
package/dist/raster.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
2
  import { r as Matrix } from "./matrix-B7_SBKQ5.cjs";
3
- import { n as GlyphOutline } from "./glyf-contours-zRQbj-Yp.cjs";
3
+ import { n as GlyphOutline } from "./glyf-contours-BRpvd0rt.cjs";
4
4
  import { Color } from "document-schema.js";
5
5
  //#region src/raster.d.ts
6
6
  type RasterMatrix = readonly [number, number, number, number, number, number];
@@ -63,9 +63,9 @@ interface RasterPageGeometry {
63
63
  readonly heightPt: number;
64
64
  }
65
65
  interface PageRasteriser {
66
- beginPage(geometry: RasterPageGeometry): void;
67
- draw(op: RasterDrawOp): void;
68
- finish(): Uint8Array<ArrayBuffer> | Promise<Uint8Array<ArrayBuffer>>;
66
+ beginPage: (geometry: RasterPageGeometry) => void;
67
+ draw: (op: RasterDrawOp) => void;
68
+ finish: () => Uint8Array<ArrayBuffer> | Promise<Uint8Array<ArrayBuffer>>;
69
69
  }
70
70
  interface RasterRegionPt {
71
71
  readonly xPt: number;
package/dist/raster.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
2
  import { r as Matrix } from "./matrix-B7_SBKQ5.js";
3
- import { n as GlyphOutline } from "./glyf-contours-OSdG6Edr.js";
3
+ import { n as GlyphOutline } from "./glyf-contours-C0epBNqP.js";
4
4
  import { Color } from "document-schema.js";
5
5
  //#region src/raster.d.ts
6
6
  type RasterMatrix = readonly [number, number, number, number, number, number];
@@ -63,9 +63,9 @@ interface RasterPageGeometry {
63
63
  readonly heightPt: number;
64
64
  }
65
65
  interface PageRasteriser {
66
- beginPage(geometry: RasterPageGeometry): void;
67
- draw(op: RasterDrawOp): void;
68
- finish(): Uint8Array<ArrayBuffer> | Promise<Uint8Array<ArrayBuffer>>;
66
+ beginPage: (geometry: RasterPageGeometry) => void;
67
+ draw: (op: RasterDrawOp) => void;
68
+ finish: () => Uint8Array<ArrayBuffer> | Promise<Uint8Array<ArrayBuffer>>;
69
69
  }
70
70
  interface RasterRegionPt {
71
71
  readonly xPt: number;
package/dist/raster.js CHANGED
@@ -532,39 +532,18 @@ function buildTextOutlineFace(fontDict, resolver, fontResolver, fontResourceName
532
532
  const subtype = asName(dictGet(fontDict, "Subtype"));
533
533
  if (subtype === "Type0") {
534
534
  const encoding = resolver.resolve(dictGet(fontDict, "Encoding"));
535
- if (encoding?.kind !== "name" || encoding.name !== "Identity-H" && encoding.name !== "Identity-V") {
536
- unavailable("a Type0 font whose /Encoding is neither Identity-H nor Identity-V (a predefined or embedded CMap this raster walk does not decode)");
537
- return;
538
- }
535
+ if (encoding?.kind !== "name" || encoding.name !== "Identity-H" && encoding.name !== "Identity-V") return unavailable("a Type0 font whose /Encoding is neither Identity-H nor Identity-V (a predefined or embedded CMap this raster walk does not decode)");
539
536
  const descendants = asArray(dictGet(fontDict, "DescendantFonts"));
540
537
  const descendant = descendants !== void 0 ? resolver.resolveDict(descendants[0]) : void 0;
541
- if (descendant === void 0) {
542
- unavailable("a Type0 font with no readable /DescendantFonts entry");
543
- return;
544
- }
538
+ if (descendant === void 0) return unavailable("a Type0 font with no readable /DescendantFonts entry");
545
539
  const descendantSubtype = asName(dictGet(descendant, "Subtype"));
546
- if (descendantSubtype === "CIDFontType0") {
547
- cff();
548
- return;
549
- }
550
- if (descendantSubtype !== "CIDFontType2") {
551
- unavailable(`a descendant font of subtype ${descendantSubtype ?? "(none)"}`);
552
- return;
553
- }
540
+ if (descendantSubtype === "CIDFontType0") return cff();
541
+ if (descendantSubtype !== "CIDFontType2") return unavailable(`a descendant font of subtype ${descendantSubtype ?? "(none)"}`);
554
542
  const cidToGidMap = resolver.resolve(dictGet(descendant, "CIDToGIDMap"));
555
543
  const program = openEmbeddedProgram(descendant, resolver);
556
- if (program.kind === "cff") {
557
- cff();
558
- return;
559
- }
560
- if (program.kind === "absent") {
561
- unavailable("no readable /FontFile2 (or glyf-bearing /FontFile3) stream");
562
- return;
563
- }
564
- if (cidToGidMap !== void 0 && cidToGidMap.kind !== "name" && cidToGidMap.kind !== "stream") {
565
- unavailable("a /CIDToGIDMap that is neither /Identity nor a readable stream");
566
- return;
567
- }
544
+ if (program.kind === "cff") return cff();
545
+ if (program.kind === "absent") return unavailable("no readable /FontFile2 (or glyf-bearing /FontFile3) stream");
546
+ if (cidToGidMap !== void 0 && cidToGidMap.kind !== "name" && cidToGidMap.kind !== "stream") return unavailable("a /CIDToGIDMap that is neither /Identity nor a readable stream");
568
547
  if (cidToGidMap?.kind === "stream") {
569
548
  const decodedBytes = decodeStream(cidToGidMap.raw, cidToGidMap.dict, NOOP_DIAGNOSTIC_SINK).bytes;
570
549
  const entries = [];
@@ -586,19 +565,10 @@ function buildTextOutlineFace(fontDict, resolver, fontResolver, fontResourceName
586
565
  }
587
566
  if (subtype === "TrueType") {
588
567
  const program = openEmbeddedProgram(fontDict, resolver);
589
- if (program.kind === "cff") {
590
- cff();
591
- return;
592
- }
593
- if (program.kind === "absent") {
594
- unavailable("no /FontDescriptor or no readable embedded program (a standard-14 or otherwise unembedded face states no outlines at all)");
595
- return;
596
- }
568
+ if (program.kind === "cff") return cff();
569
+ if (program.kind === "absent") return unavailable("no /FontDescriptor or no readable embedded program (a standard-14 or otherwise unembedded face states no outlines at all)");
597
570
  const cmapLookup = buildCmapLookup(program.sfnt);
598
- if (cmapLookup === void 0) {
599
- unavailable("an embedded program with no usable Unicode cmap subtable");
600
- return;
601
- }
571
+ if (cmapLookup === void 0) return unavailable("an embedded program with no usable Unicode cmap subtable");
602
572
  return {
603
573
  glyf: program.face.glyf,
604
574
  unitsPerEm: program.face.unitsPerEm,
@@ -2,6 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_objects = require("./objects.cjs");
3
3
  const require_pdf_text = require("./pdf-text.cjs");
4
4
  //#region src/structure.ts
5
+ const NEVER_DICT = {
6
+ kind: "dict",
7
+ entries: /* @__PURE__ */ new Map()
8
+ };
5
9
  function readStructure(catalog, pages, resolver, sink) {
6
10
  const root = resolver.resolveDict(require_objects.dictGet(catalog, "StructTreeRoot"));
7
11
  if (root === void 0) return {
@@ -176,9 +180,5 @@ function parentTreeOwners(root, pages, resolver, idByDict, sink) {
176
180
  });
177
181
  return (pageIndex, mcid) => owners.get(`${pageIndex}:${mcid}`);
178
182
  }
179
- const NEVER_DICT = {
180
- kind: "dict",
181
- entries: /* @__PURE__ */ new Map()
182
- };
183
183
  //#endregion
184
184
  exports.readStructure = readStructure;
package/dist/structure.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { asArray, asName, asNumber, dictGet } from "./objects.js";
2
2
  import { decodePdfString } from "./pdf-text.js";
3
3
  //#region src/structure.ts
4
+ const NEVER_DICT = {
5
+ kind: "dict",
6
+ entries: /* @__PURE__ */ new Map()
7
+ };
4
8
  function readStructure(catalog, pages, resolver, sink) {
5
9
  const root = resolver.resolveDict(dictGet(catalog, "StructTreeRoot"));
6
10
  if (root === void 0) return {
@@ -175,9 +179,5 @@ function parentTreeOwners(root, pages, resolver, idByDict, sink) {
175
179
  });
176
180
  return (pageIndex, mcid) => owners.get(`${pageIndex}:${mcid}`);
177
181
  }
178
- const NEVER_DICT = {
179
- kind: "dict",
180
- entries: /* @__PURE__ */ new Map()
181
- };
182
182
  //#endregion
183
183
  export { readStructure };
package/dist/winansi.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
2
+ const require_afm_widths = require("./afm-widths-BYiX2L9D.cjs");
3
3
  exports.encodeForShow = require_afm_widths.encodeForShow;
4
4
  exports.sanitizeToWinAnsi = require_afm_widths.sanitizeToWinAnsi;
5
5
  exports.winAnsiCodeToUnicode = require_afm_widths.winAnsiCodeToUnicode;
package/dist/winansi.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as winAnsiCodeToUnicode, g as sanitizeToWinAnsi, h as encodeForShow } from "./afm-widths-De_QMWgC.js";
1
+ import { _ as winAnsiCodeToUnicode, g as sanitizeToWinAnsi, h as encodeForShow } from "./afm-widths-blUDDjlI.js";
2
2
  export { encodeForShow, sanitizeToWinAnsi, winAnsiCodeToUnicode };
package/dist/write.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
2
+ const require_afm_widths = require("./afm-widths-BYiX2L9D.cjs");
3
3
  const require_notes_annotation_author = require("./notes-annotation-author.cjs");
4
4
  const require_objects = require("./objects.cjs");
5
5
  const require_bytes_writer = require("./bytes/writer.cjs");
@@ -771,10 +771,10 @@ function writePdf(doc, options = {}) {
771
771
  });
772
772
  }
773
773
  for (const [face, alloc] of embeddedAllocs) {
774
- const usedGlyphs = require_embedded_font.collectEmbeddedGlyphs(alloc.texts, face);
775
- const subset = require_sfnt_subset.subsetSfnt(face.font, [...alloc.codePoints], [...usedGlyphs.keys()]);
774
+ const faceUsedGlyphs = require_embedded_font.collectEmbeddedGlyphs(alloc.texts, face);
775
+ const subset = require_sfnt_subset.subsetSfnt(face.font, [...alloc.codePoints], [...faceUsedGlyphs.keys()]);
776
776
  if (subset === void 0) throw new Error(`font "${face.postScriptName}" resolved to an embeddable face, but its glyph outlines could not be subsetted — only TrueType-outline ('glyf') fonts can be embedded, so supply a TrueType face for this family or drop it from the registry`);
777
- const built = require_embedded_font_write.buildEmbeddedFontObjects(face, subset, usedGlyphs, {
777
+ const built = require_embedded_font_write.buildEmbeddedFontObjects(face, subset, faceUsedGlyphs, {
778
778
  cidFontRef: require_objects.pdfRef(alloc.cidFontNum, 0),
779
779
  descriptorRef: require_objects.pdfRef(alloc.descriptorNum, 0),
780
780
  fontFileRef: require_objects.pdfRef(alloc.fontFileNum, 0),