pdf-parser.js 3.0.8 → 4.5.2

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 (240) hide show
  1. package/README.md +105 -54
  2. package/dist/{afm-widths-Dxucrg7D.js → afm-widths-BTu0IDp2.cjs} +1517 -4
  3. package/dist/{afm-widths-DyDq56Ph.d.cts → afm-widths-CneRyu5l.d.cts} +1 -1
  4. package/dist/{afm-widths-DyDq56Ph.d.ts → afm-widths-CneRyu5l.d.ts} +1 -1
  5. package/dist/{afm-widths-BoeTOK2r.cjs → afm-widths-De_QMWgC.js} +1416 -51
  6. package/dist/afm-widths.cjs +1 -1
  7. package/dist/afm-widths.d.cts +1 -1
  8. package/dist/afm-widths.d.ts +1 -1
  9. package/dist/afm-widths.js +1 -1
  10. package/dist/annotations.cjs +104 -0
  11. package/dist/annotations.d.cts +9 -0
  12. package/dist/annotations.d.ts +9 -0
  13. package/dist/annotations.js +103 -0
  14. package/dist/attachments.cjs +65 -0
  15. package/dist/attachments.d.cts +8 -0
  16. package/dist/attachments.d.ts +8 -0
  17. package/dist/attachments.js +64 -0
  18. package/dist/builtin-encoding.cjs +221 -0
  19. package/dist/builtin-encoding.d.cts +8 -0
  20. package/dist/builtin-encoding.d.ts +8 -0
  21. package/dist/builtin-encoding.js +220 -0
  22. package/dist/bytes/flate.cjs +1 -1
  23. package/dist/bytes/flate.js +1 -1
  24. package/dist/cff.cjs +14 -0
  25. package/dist/cff.d.cts +4 -1
  26. package/dist/cff.d.ts +4 -1
  27. package/dist/cff.js +12 -1
  28. package/dist/cmap-table.cjs +76 -13
  29. package/dist/cmap-table.d.cts +9 -1
  30. package/dist/cmap-table.d.ts +9 -1
  31. package/dist/cmap-table.js +77 -15
  32. package/dist/codec.cjs +1 -1
  33. package/dist/codec.d.cts +134 -0
  34. package/dist/codec.d.ts +134 -0
  35. package/dist/codec.js +1 -1
  36. package/dist/content-read.cjs +1 -1
  37. package/dist/content-read.d.cts +3 -3
  38. package/dist/content-read.d.ts +3 -3
  39. package/dist/content-read.js +1 -1
  40. package/dist/content-write.cjs +32 -10
  41. package/dist/content-write.d.cts +12 -5
  42. package/dist/content-write.d.ts +12 -5
  43. package/dist/content-write.js +32 -10
  44. package/dist/crypto/random.cjs +9 -0
  45. package/dist/crypto/random.d.cts +4 -0
  46. package/dist/crypto/random.d.ts +4 -0
  47. package/dist/crypto/random.js +8 -0
  48. package/dist/diagnostics.d.cts +1 -1
  49. package/dist/diagnostics.d.ts +1 -1
  50. package/dist/document.cjs +12 -3
  51. package/dist/document.d.cts +3 -1
  52. package/dist/document.d.ts +3 -1
  53. package/dist/document.js +12 -3
  54. package/dist/{embedded-font-fREdbxnr.d.ts → embedded-font-B4p9a3O3.d.ts} +3 -1
  55. package/dist/{embedded-font-BU6Jgcof.d.cts → embedded-font-oc65VGlr.d.cts} +3 -1
  56. package/dist/embedded-font-write.cjs +1 -1
  57. package/dist/embedded-font-write.d.cts +3 -3
  58. package/dist/embedded-font-write.d.ts +3 -3
  59. package/dist/embedded-font-write.js +1 -1
  60. package/dist/embedded-font.cjs +46 -15
  61. package/dist/embedded-font.d.cts +1 -1
  62. package/dist/embedded-font.d.ts +1 -1
  63. package/dist/embedded-font.js +46 -15
  64. package/dist/encoding.cjs +10 -1
  65. package/dist/encoding.d.cts +10 -1
  66. package/dist/encoding.d.ts +10 -1
  67. package/dist/encoding.js +2 -2
  68. package/dist/encrypt-write.cjs +234 -0
  69. package/dist/encrypt-write.d.cts +31 -0
  70. package/dist/encrypt-write.d.ts +31 -0
  71. package/dist/encrypt-write.js +231 -0
  72. package/dist/encrypt.cjs +51 -21
  73. package/dist/encrypt.d.cts +19 -3
  74. package/dist/encrypt.d.ts +19 -3
  75. package/dist/encrypt.js +36 -22
  76. package/dist/filters.cjs +18 -14
  77. package/dist/filters.d.cts +1 -1
  78. package/dist/filters.d.ts +1 -1
  79. package/dist/filters.js +18 -14
  80. package/dist/font-read.cjs +68 -13
  81. package/dist/font-read.d.cts +1 -1
  82. package/dist/font-read.d.ts +1 -1
  83. package/dist/font-read.js +69 -14
  84. package/dist/font-registry.cjs +1 -1
  85. package/dist/font-registry.d.cts +4 -4
  86. package/dist/font-registry.d.ts +4 -4
  87. package/dist/font-registry.js +1 -1
  88. package/dist/font-substitutes.d.cts +1 -1
  89. package/dist/font-substitutes.d.ts +1 -1
  90. package/dist/font-tables.cjs +31 -0
  91. package/dist/font-tables.d.cts +3 -1
  92. package/dist/font-tables.d.ts +3 -1
  93. package/dist/font-tables.js +31 -2
  94. package/dist/fonts.d.cts +2 -2
  95. package/dist/fonts.d.ts +2 -2
  96. package/dist/form.cjs +138 -0
  97. package/dist/form.d.cts +9 -0
  98. package/dist/form.d.ts +9 -0
  99. package/dist/form.js +137 -0
  100. package/dist/gsub-table-BRTQ8EUW.d.ts +10 -0
  101. package/dist/gsub-table-URczLd85.d.cts +10 -0
  102. package/dist/gsub-table.cjs +225 -0
  103. package/dist/gsub-table.d.cts +2 -0
  104. package/dist/gsub-table.d.ts +2 -0
  105. package/dist/gsub-table.js +224 -0
  106. package/dist/image/ccitt-encode.cjs +119 -0
  107. package/dist/image/ccitt-encode.d.cts +9 -0
  108. package/dist/image/ccitt-encode.d.ts +9 -0
  109. package/dist/image/ccitt-encode.js +118 -0
  110. package/dist/image/ccitt.cjs +3 -0
  111. package/dist/image/ccitt.d.cts +4 -1
  112. package/dist/image/ccitt.d.ts +4 -1
  113. package/dist/image/ccitt.js +1 -1
  114. package/dist/image/jbig2-bitmap.d.cts +1 -1
  115. package/dist/image/jbig2-bitmap.d.ts +1 -1
  116. package/dist/image/jbig2.cjs +3 -1
  117. package/dist/image/jbig2.js +3 -1
  118. package/dist/image/jp2-boxes.d.cts +1 -1
  119. package/dist/image/jp2-boxes.d.ts +1 -1
  120. package/dist/image/jpeg2000-codestream.d.cts +3 -3
  121. package/dist/image/jpeg2000-codestream.d.ts +3 -3
  122. package/dist/image/jpeg2000-t1.d.cts +1 -1
  123. package/dist/image/jpeg2000-t1.d.ts +1 -1
  124. package/dist/image/jpeg2000.cjs +1 -0
  125. package/dist/image/jpeg2000.d.cts +3 -0
  126. package/dist/image/jpeg2000.d.ts +3 -0
  127. package/dist/image/jpeg2000.js +1 -0
  128. package/dist/image/png-decode.cjs +1 -1
  129. package/dist/image/png-decode.js +1 -1
  130. package/dist/image/png-filter.d.cts +1 -1
  131. package/dist/image/png-filter.d.ts +1 -1
  132. package/dist/images-read.cjs +18 -12
  133. package/dist/images-read.d.cts +2 -2
  134. package/dist/images-read.d.ts +2 -2
  135. package/dist/images-read.js +15 -9
  136. package/dist/index.cjs +17 -4
  137. package/dist/index.d.cts +7 -6
  138. package/dist/index.d.ts +7 -6
  139. package/dist/index.js +6 -5
  140. package/dist/interpret.cjs +178 -56
  141. package/dist/interpret.d.cts +27 -12
  142. package/dist/interpret.d.ts +27 -12
  143. package/dist/interpret.js +178 -56
  144. package/dist/layout.cjs +149 -2
  145. package/dist/layout.d.cts +394 -1
  146. package/dist/layout.d.ts +394 -1
  147. package/dist/layout.js +140 -4
  148. package/dist/lexer.d.cts +9 -9
  149. package/dist/lexer.d.ts +9 -9
  150. package/dist/math-content-write.cjs +1 -1
  151. package/dist/math-content-write.js +1 -1
  152. package/dist/math-font-write.cjs +1 -1
  153. package/dist/math-font-write.d.cts +1 -1
  154. package/dist/math-font-write.d.ts +1 -1
  155. package/dist/math-font-write.js +1 -1
  156. package/dist/math-font.cjs +2 -2
  157. package/dist/math-font.d.cts +1 -1
  158. package/dist/math-font.d.ts +1 -1
  159. package/dist/math-font.js +2 -2
  160. package/dist/{math-stretch-a_rHNRvc.d.ts → math-stretch-BbC2o4Br.d.ts} +1 -1
  161. package/dist/{math-stretch-E26z6byT.d.cts → math-stretch-C2JanDAz.d.cts} +1 -1
  162. package/dist/math-stretch.d.cts +1 -1
  163. package/dist/math-stretch.d.ts +1 -1
  164. package/dist/measure.cjs +1 -1
  165. package/dist/measure.d.cts +1 -1
  166. package/dist/measure.d.ts +1 -1
  167. package/dist/measure.js +1 -1
  168. package/dist/names.cjs +41 -0
  169. package/dist/names.d.cts +11 -0
  170. package/dist/names.d.ts +11 -0
  171. package/dist/names.js +40 -0
  172. package/dist/navigation.cjs +210 -0
  173. package/dist/navigation.d.cts +18 -0
  174. package/dist/navigation.d.ts +18 -0
  175. package/dist/navigation.js +207 -0
  176. package/dist/notes-annotation-author.cjs +5 -0
  177. package/dist/notes-annotation-author.d.cts +4 -0
  178. package/dist/notes-annotation-author.d.ts +4 -0
  179. package/dist/notes-annotation-author.js +4 -0
  180. package/dist/objects-B7HdMeWS.d.cts +59 -0
  181. package/dist/objects-B7HdMeWS.d.ts +59 -0
  182. package/dist/objects.d.cts +1 -58
  183. package/dist/objects.d.ts +1 -58
  184. package/dist/optional-content.cjs +63 -0
  185. package/dist/optional-content.d.cts +12 -0
  186. package/dist/optional-content.d.ts +12 -0
  187. package/dist/optional-content.js +62 -0
  188. package/dist/parse.cjs +1 -1
  189. package/dist/parse.d.cts +2 -2
  190. package/dist/parse.d.ts +2 -2
  191. package/dist/parse.js +1 -1
  192. package/dist/pdf-text.cjs +21 -0
  193. package/dist/pdf-text.d.cts +5 -0
  194. package/dist/pdf-text.d.ts +5 -0
  195. package/dist/pdf-text.js +19 -0
  196. package/dist/predictors.d.cts +1 -1
  197. package/dist/predictors.d.ts +1 -1
  198. package/dist/read.cjs +287 -72
  199. package/dist/read.d.cts +2 -4
  200. package/dist/read.d.ts +2 -4
  201. package/dist/read.js +284 -67
  202. package/dist/serialize.cjs +5 -1
  203. package/dist/serialize.d.cts +3 -2
  204. package/dist/serialize.d.ts +3 -2
  205. package/dist/serialize.js +5 -2
  206. package/dist/sfnt-subset.cjs +10 -3
  207. package/dist/sfnt-subset.d.cts +1 -1
  208. package/dist/sfnt-subset.d.ts +1 -1
  209. package/dist/sfnt-subset.js +10 -3
  210. package/dist/structure.cjs +184 -0
  211. package/dist/structure.d.cts +12 -0
  212. package/dist/structure.d.ts +12 -0
  213. package/dist/structure.js +183 -0
  214. package/dist/tounicode.cjs +8 -3
  215. package/dist/tounicode.d.cts +2 -2
  216. package/dist/tounicode.d.ts +2 -2
  217. package/dist/tounicode.js +8 -3
  218. package/dist/util/base64.cjs +4 -4
  219. package/dist/util/base64.js +4 -4
  220. package/dist/winansi.cjs +1 -1
  221. package/dist/winansi.d.cts +1 -1
  222. package/dist/winansi.d.ts +1 -1
  223. package/dist/winansi.js +1 -1
  224. package/dist/write.cjs +464 -21
  225. package/dist/write.d.cts +4 -3
  226. package/dist/write.d.ts +4 -3
  227. package/dist/write.js +464 -20
  228. package/dist/xmp.cjs +46 -0
  229. package/dist/xmp.d.cts +14 -0
  230. package/dist/xmp.d.ts +14 -0
  231. package/dist/xmp.js +45 -0
  232. package/dist/xref.cjs +2 -2
  233. package/dist/xref.d.cts +3 -3
  234. package/dist/xref.d.ts +3 -3
  235. package/dist/xref.js +2 -2
  236. package/package.json +46 -31
  237. package/dist/image/png-encode.cjs +0 -64
  238. package/dist/image/png-encode.d.cts +0 -8
  239. package/dist/image/png-encode.d.ts +0 -8
  240. package/dist/image/png-encode.js +0 -63
package/dist/index.cjs CHANGED
@@ -1,21 +1,22 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
3
- const require_layout = require("./layout.cjs");
4
- const require_diagnostics = require("./diagnostics.cjs");
2
+ const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
5
3
  const require_image_ccitt = require("./image/ccitt.cjs");
6
4
  const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
7
5
  const require_image_jbig2 = require("./image/jbig2.cjs");
8
6
  const require_image_png_filter = require("./image/png-filter.cjs");
7
+ const require_layout = require("./layout.cjs");
8
+ const require_diagnostics = require("./diagnostics.cjs");
9
9
  const require_fonts = require("./fonts.cjs");
10
10
  const require_image_jpeg2000_errors = require("./image/jpeg2000-errors.cjs");
11
11
  const require_image_jp2_boxes = require("./image/jp2-boxes.cjs");
12
12
  const require_image_jpeg2000 = require("./image/jpeg2000.cjs");
13
+ const require_read = require("./read.cjs");
14
+ const require_encrypt_write = require("./encrypt-write.cjs");
13
15
  const require_font_registry = require("./font-registry.cjs");
14
16
  const require_math_stretch = require("./math-stretch.cjs");
15
17
  const require_math_font = require("./math-font.cjs");
16
18
  const require_measure = require("./measure.cjs");
17
19
  const require_write = require("./write.cjs");
18
- const require_read = require("./read.cjs");
19
20
  const require_codec = require("./codec.cjs");
20
21
  const require_font_face = require("./font-face.cjs");
21
22
  exports.DEFAULT_VERTICAL_METRIC_POLICY = require_measure.DEFAULT_VERTICAL_METRIC_POLICY;
@@ -25,22 +26,34 @@ exports.Jbig2UnsupportedError = require_image_jbig2_errors.Jbig2UnsupportedError
25
26
  exports.Jpeg2000ParseError = require_image_jpeg2000_errors.Jpeg2000ParseError;
26
27
  exports.Jpeg2000UnsupportedError = require_image_jpeg2000_errors.Jpeg2000UnsupportedError;
27
28
  exports.LAYOUT_FORMAT_VERSION = require_layout.LAYOUT_FORMAT_VERSION;
29
+ exports.LayoutAnnotationQuadSchema = require_layout.LayoutAnnotationQuadSchema;
30
+ exports.LayoutAnnotationSchema = require_layout.LayoutAnnotationSchema;
31
+ exports.LayoutAttachmentSchema = require_layout.LayoutAttachmentSchema;
32
+ exports.LayoutDestinationSchema = require_layout.LayoutDestinationSchema;
33
+ exports.LayoutDestinationTargetSchema = require_layout.LayoutDestinationTargetSchema;
28
34
  exports.LayoutDocumentSchema = require_layout.LayoutDocumentSchema;
29
35
  exports.LayoutEllipseSchema = require_layout.LayoutEllipseSchema;
36
+ exports.LayoutFormFieldSchema = require_layout.LayoutFormFieldSchema;
37
+ exports.LayoutFormWidgetSchema = require_layout.LayoutFormWidgetSchema;
30
38
  exports.LayoutImageAssetSchema = require_layout.LayoutImageAssetSchema;
31
39
  exports.LayoutImageSchema = require_layout.LayoutImageSchema;
40
+ exports.LayoutInternalLinkSchema = require_layout.LayoutInternalLinkSchema;
32
41
  exports.LayoutItemSchema = require_layout.LayoutItemSchema;
42
+ exports.LayoutLayerSchema = require_layout.LayoutLayerSchema;
33
43
  exports.LayoutLineSchema = require_layout.LayoutLineSchema;
34
44
  exports.LayoutLinkSchema = require_layout.LayoutLinkSchema;
45
+ exports.LayoutOutlineItemSchema = require_layout.LayoutOutlineItemSchema;
35
46
  exports.LayoutPageSchema = require_layout.LayoutPageSchema;
36
47
  exports.LayoutPathSchema = require_layout.LayoutPathSchema;
37
48
  exports.LayoutPathSegmentSchema = require_layout.LayoutPathSegmentSchema;
38
49
  exports.LayoutRectSchema = require_layout.LayoutRectSchema;
50
+ exports.LayoutStructureElementSchema = require_layout.LayoutStructureElementSchema;
39
51
  exports.LayoutSubpathSchema = require_layout.LayoutSubpathSchema;
40
52
  exports.LayoutTextSchema = require_layout.LayoutTextSchema;
41
53
  exports.NOOP_DIAGNOSTIC_SINK = require_diagnostics.NOOP_DIAGNOSTIC_SINK;
42
54
  exports.PdfBytesSchema = require_codec.PdfBytesSchema;
43
55
  exports.PdfEncryptedError = require_diagnostics.PdfEncryptedError;
56
+ exports.PdfEncryptionError = require_encrypt_write.PdfEncryptionError;
44
57
  exports.PdfParseError = require_diagnostics.PdfParseError;
45
58
  exports.PdfPasswordRequiredError = require_diagnostics.PdfPasswordRequiredError;
46
59
  exports.STANDARD_METRICS = require_afm_widths.STANDARD_METRICS;
package/dist/index.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-DyDq56Ph.cjs";
2
- import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
1
+ import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-CneRyu5l.cjs";
3
2
  import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.cjs";
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
+ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
4
5
  import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
5
- import { LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutItem, LayoutItemSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.cjs";
6
- import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-BU6Jgcof.cjs";
6
+ import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-oc65VGlr.cjs";
7
7
  import { WinAnsiSubstitution } from "./winansi.cjs";
8
+ import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.cjs";
8
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.cjs";
9
10
  import { FontRegistry, ResolvedFace, createFontRegistry, resolveFaceWithRegistry } from "./font-registry.cjs";
10
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.cjs";
@@ -19,9 +20,9 @@ import { filterScanlines, unfilterScanlines } from "./image/png-filter.cjs";
19
20
  import { ReadPdfOptions, readPdf } from "./read.cjs";
20
21
  import { WritePdfOptions, writePdf } from "./write.cjs";
21
22
  import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-gFNB8DmQ.cjs";
22
- import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-E26z6byT.cjs";
23
+ import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-C2JanDAz.cjs";
23
24
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.cjs";
24
25
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.cjs";
25
26
  import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
26
27
  export * from "byte-codec";
27
- export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutItem, LayoutItemSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
28
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, 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, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-DyDq56Ph.js";
2
- import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
1
+ import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-CneRyu5l.js";
3
2
  import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
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
+ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
4
5
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
5
- import { LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutItem, LayoutItemSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.js";
6
- import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-fREdbxnr.js";
6
+ import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-B4p9a3O3.js";
7
7
  import { WinAnsiSubstitution } from "./winansi.js";
8
+ import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.js";
8
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.js";
9
10
  import { FontRegistry, ResolvedFace, createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
10
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.js";
@@ -19,9 +20,9 @@ import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
19
20
  import { ReadPdfOptions, readPdf } from "./read.js";
20
21
  import { WritePdfOptions, writePdf } from "./write.js";
21
22
  import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-DhPrNoPa.js";
22
- import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-a_rHNRvc.js";
23
+ import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-BbC2o4Br.js";
23
24
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.js";
24
25
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
25
26
  import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
26
27
  export * from "byte-codec";
27
- export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutItem, LayoutItemSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
28
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, 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, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.js CHANGED
@@ -1,21 +1,22 @@
1
- import { t as STANDARD_METRICS } from "./afm-widths-Dxucrg7D.js";
2
- import { LAYOUT_FORMAT_VERSION, LayoutDocumentSchema, LayoutEllipseSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutItemSchema, LayoutLineSchema, LayoutLinkSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutSubpathSchema, LayoutTextSchema } from "./layout.js";
3
- import { NOOP_DIAGNOSTIC_SINK, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
1
+ import { t as STANDARD_METRICS } from "./afm-widths-De_QMWgC.js";
4
2
  import { decodeCcittFax } from "./image/ccitt.js";
5
3
  import { Jbig2ParseError, Jbig2UnsupportedError } from "./image/jbig2-errors.js";
6
4
  import { decodeJbig2Embedded } from "./image/jbig2.js";
7
5
  import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
6
+ import { LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema } from "./layout.js";
7
+ import { NOOP_DIAGNOSTIC_SINK, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
8
8
  import { resolveStandardFont } from "./fonts.js";
9
9
  import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.js";
10
10
  import { looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.js";
11
11
  import { decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
12
+ import { readPdf } from "./read.js";
13
+ import { PdfEncryptionError } from "./encrypt-write.js";
12
14
  import { createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
13
15
  import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stretch.js";
14
16
  import { loadMathFont } from "./math-font.js";
15
17
  import { DEFAULT_VERTICAL_METRIC_POLICY, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
16
18
  import { writePdf } from "./write.js";
17
- import { readPdf } from "./read.js";
18
19
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
19
20
  import { FontFaceParseError, readFontFace } from "./font-face.js";
20
21
  export * from "byte-codec";
21
- export { DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutDocumentSchema, LayoutEllipseSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutItemSchema, LayoutLineSchema, LayoutLinkSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
22
+ export { DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfEncryptionError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
@@ -1,17 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_objects = require("./objects.cjs");
3
- const require_filters = require("./filters.cjs");
3
+ const require_pdf_text = require("./pdf-text.cjs");
4
4
  const require_matrix = require("./matrix.cjs");
5
+ const require_filters = require("./filters.cjs");
5
6
  const require_content_read = require("./content-read.cjs");
6
7
  let document_schema_js = require("document-schema.js");
7
8
  //#region src/interpret.ts
8
9
  const MAX_FORM_XOBJECT_DEPTH = 12;
9
10
  const FALLBACK_GLYPH_WIDTH_PER_1000 = 500;
10
11
  const DEFAULT_LINE_WIDTH_PT = 1;
11
- function defaultTextState() {
12
+ function initialTextParameters() {
12
13
  return {
13
- tm: require_matrix.IDENTITY_MATRIX,
14
- tlm: require_matrix.IDENTITY_MATRIX,
15
14
  fontResourceName: void 0,
16
15
  fontSizePt: 0,
17
16
  charSpace: 0,
@@ -21,20 +20,44 @@ function defaultTextState() {
21
20
  rise: 0
22
21
  };
23
22
  }
24
- function computeTrm(ctm, ts) {
23
+ function defaultTextObjectState() {
24
+ return {
25
+ tm: require_matrix.IDENTITY_MATRIX,
26
+ tlm: require_matrix.IDENTITY_MATRIX
27
+ };
28
+ }
29
+ function computeTrm(gs, text) {
25
30
  const fontMatrix = [
26
- ts.fontSizePt * ts.horizScale,
31
+ gs.fontSizePt * gs.horizScale,
27
32
  0,
28
33
  0,
29
- ts.fontSizePt,
34
+ gs.fontSizePt,
30
35
  0,
31
- ts.rise
36
+ gs.rise
32
37
  ];
33
- return require_matrix.multiplyMatrices(require_matrix.multiplyMatrices(fontMatrix, ts.tm), ctm);
38
+ return require_matrix.multiplyMatrices(require_matrix.multiplyMatrices(fontMatrix, text.tm), gs.ctm);
34
39
  }
35
40
  function numAt(operands, index) {
36
41
  return require_objects.asNumber(operands[index]) ?? 0;
37
42
  }
43
+ function markedContentProperties(operand, resources, resolver) {
44
+ if (operand?.kind === "dict") return operand;
45
+ if (operand?.kind === "name") {
46
+ const properties = resolver.resolveDict(require_objects.dictGet(resources, "Properties"));
47
+ return properties === void 0 ? void 0 : resolver.resolveDict(require_objects.dictGet(properties, operand.name));
48
+ }
49
+ }
50
+ function markedContentScopeProps(props) {
51
+ if (props === void 0) return {};
52
+ const actualTextObj = require_objects.dictGet(props, "ActualText");
53
+ const altObj = require_objects.dictGet(props, "Alt");
54
+ const mcid = require_objects.asNumber(require_objects.dictGet(props, "MCID"));
55
+ return {
56
+ ...actualTextObj?.kind === "string" ? { actualText: require_pdf_text.decodePdfString(actualTextObj.bytes) } : {},
57
+ ...altObj?.kind === "string" ? { alt: require_pdf_text.decodePdfString(altObj.bytes) } : {},
58
+ ...mcid !== void 0 && mcid >= 0 ? { mcid } : {}
59
+ };
60
+ }
38
61
  function grayColor(value) {
39
62
  return {
40
63
  r: value,
@@ -227,7 +250,11 @@ function detectEllipse(subpath, paint) {
227
250
  stroke: paint.stroke
228
251
  };
229
252
  }
230
- function detectLine(subpath, paint) {
253
+ function strokeStyleFromDashArray(dashArray) {
254
+ if (dashArray.length === 0) return;
255
+ return dashArray.length === 2 && dashArray[0] === 0 ? "dotted" : "dashed";
256
+ }
257
+ function detectLine(subpath, paint, style) {
231
258
  const segment = subpath.segments[0];
232
259
  if (subpath.closed || subpath.segments.length !== 1 || segment?.kind !== "line") return;
233
260
  if (paint.fill !== void 0 || paint.stroke === void 0) return;
@@ -238,13 +265,14 @@ function detectLine(subpath, paint) {
238
265
  x2Pt: segment.xPt,
239
266
  y2Pt: segment.yPt,
240
267
  color: paint.stroke.color,
241
- widthPt: paint.stroke.widthPt
268
+ widthPt: paint.stroke.widthPt,
269
+ ...style !== void 0 ? { style } : {}
242
270
  };
243
271
  }
244
- function classifyShape(subpaths, paint) {
272
+ function classifyShape(subpaths, paint, style) {
245
273
  const subpath = subpaths[0];
246
274
  if (subpaths.length !== 1 || subpath === void 0) return;
247
- return detectRect(subpath, paint) ?? detectEllipse(subpath, paint) ?? detectLine(subpath, paint);
275
+ return detectRect(subpath, paint) ?? detectEllipse(subpath, paint) ?? detectLine(subpath, paint, style);
248
276
  }
249
277
  function interpretContentStream(bytes, resources, context) {
250
278
  const items = [];
@@ -252,8 +280,10 @@ function interpretContentStream(bytes, resources, context) {
252
280
  ctm: require_matrix.IDENTITY_MATRIX,
253
281
  fillColor: document_schema_js.COLOR_BLACK,
254
282
  strokeColor: document_schema_js.COLOR_BLACK,
255
- lineWidth: DEFAULT_LINE_WIDTH_PT
256
- }, context, items, 0);
283
+ lineWidth: DEFAULT_LINE_WIDTH_PT,
284
+ dashArray: [],
285
+ ...initialTextParameters()
286
+ }, context, items, 0, []);
257
287
  return items;
258
288
  }
259
289
  function lastPointOf(subpath) {
@@ -266,13 +296,45 @@ function lastPointOf(subpath) {
266
296
  y: last.yPt
267
297
  };
268
298
  }
269
- function runContentStream(bytes, resources, initialState, context, items, depth) {
299
+ function runContentStream(bytes, resources, initialState, context, items, depth, markedContent) {
270
300
  const operations = require_content_read.readContentStream(bytes, context.sink);
271
301
  const gsStack = [];
272
302
  let gs = initialState;
273
- let ts = defaultTextState();
303
+ let text = defaultTextObjectState();
274
304
  let pathSubpaths = [];
275
305
  let currentSubpath;
306
+ const inScope = (key) => {
307
+ for (let i = markedContent.length - 1; i >= 0; i--) {
308
+ const frame = markedContent[i];
309
+ if (frame !== void 0 && key in frame) return frame[key];
310
+ }
311
+ };
312
+ const pushItem = (item) => {
313
+ if (item.kind === "text") {
314
+ const layer = item.layerName ?? inScope("layerName");
315
+ const actualText = inScope("actualText");
316
+ const alt = inScope("alt");
317
+ const mcid = inScope("mcid");
318
+ items.push({
319
+ ...item,
320
+ ...layer !== void 0 ? { layerName: layer } : {},
321
+ ...actualText !== void 0 ? { actualText } : {},
322
+ ...alt !== void 0 ? { alt } : {},
323
+ ...mcid !== void 0 ? { mcid } : {}
324
+ });
325
+ return;
326
+ }
327
+ const layer = item.layerName ?? inScope("layerName");
328
+ const layerStamped = layer === void 0 ? item : {
329
+ ...item,
330
+ layerName: layer
331
+ };
332
+ const mcid = inScope("mcid");
333
+ items.push(mcid === void 0 ? layerStamped : {
334
+ ...layerStamped,
335
+ mcid
336
+ });
337
+ };
276
338
  const finalizeCurrentSubpath = () => {
277
339
  if (currentSubpath !== void 0) {
278
340
  pathSubpaths.push(currentSubpath);
@@ -346,36 +408,40 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
346
408
  widthPt: gs.lineWidth
347
409
  } : void 0
348
410
  };
349
- items.push(classifyShape(pathSubpaths, paint) ?? {
411
+ const strokeStyle = isStrokeOp ? strokeStyleFromDashArray(gs.dashArray) : void 0;
412
+ pushItem(classifyShape(pathSubpaths, paint, strokeStyle) ?? {
350
413
  kind: "path",
351
414
  subpaths: pathSubpaths,
352
415
  fillRule: paintFillRuleFor(operator),
353
- ...paint
416
+ ...paint,
417
+ ...strokeStyle !== void 0 ? { style: strokeStyle } : {}
354
418
  });
355
419
  }
356
420
  resetPath();
357
421
  };
358
422
  const advanceThroughString = (codes) => {
359
- if (ts.fontResourceName === void 0) return;
423
+ const fontResourceName = gs.fontResourceName;
424
+ if (fontResourceName === void 0) return;
360
425
  let offset = 0;
361
426
  while (offset < codes.length) {
362
- const glyph = context.fontMetrics.glyphAdvance(ts.fontResourceName, resources, codes, offset);
427
+ const glyph = context.fontMetrics.glyphAdvance(fontResourceName, resources, codes, offset);
363
428
  if (glyph === void 0) context.sink({
364
429
  code: "pdf/font-not-resolved",
365
430
  severity: "warning",
366
- message: `could not resolve font resource /${ts.fontResourceName} to compute a glyph advance; assuming a fallback width`
431
+ message: `could not resolve font resource /${fontResourceName} to compute a glyph advance; assuming a fallback width`
367
432
  });
368
433
  const widthPer1000 = glyph?.widthPer1000 ?? FALLBACK_GLYPH_WIDTH_PER_1000;
369
434
  const byteLength = glyph?.byteLengthConsumed ?? 1;
370
435
  const isSingleByteSpace = byteLength === 1 && codes[offset] === 32;
371
- const tx = (widthPer1000 / 1e3 * ts.fontSizePt + ts.charSpace + (isSingleByteSpace ? ts.wordSpace : 0)) * ts.horizScale;
372
- ts.tm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(tx, 0), ts.tm);
436
+ const tx = (widthPer1000 / 1e3 * gs.fontSizePt + gs.charSpace + (isSingleByteSpace ? gs.wordSpace : 0)) * gs.horizScale;
437
+ text.tm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(tx, 0), text.tm);
373
438
  offset += byteLength;
374
439
  }
375
440
  };
376
441
  const showTextArray = (elements) => {
377
- if (ts.fontResourceName === void 0) return;
378
- const startMatrix = computeTrm(gs.ctm, ts);
442
+ const fontResourceName = gs.fontResourceName;
443
+ if (fontResourceName === void 0) return;
444
+ const startMatrix = computeTrm(gs, text);
379
445
  const chunks = [];
380
446
  let totalLength = 0;
381
447
  for (const el of elements) if (el.kind === "string") {
@@ -383,8 +449,8 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
383
449
  totalLength += el.bytes.length;
384
450
  advanceThroughString(el.bytes);
385
451
  } else if (el.kind === "number") {
386
- const adjustment = -(el.value / 1e3) * ts.fontSizePt * ts.horizScale;
387
- ts.tm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(adjustment, 0), ts.tm);
452
+ const adjustment = -(el.value / 1e3) * gs.fontSizePt * gs.horizScale;
453
+ text.tm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(adjustment, 0), text.tm);
388
454
  }
389
455
  if (totalLength === 0) return;
390
456
  const combined = new Uint8Array(totalLength);
@@ -393,15 +459,15 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
393
459
  combined.set(chunk, at);
394
460
  at += chunk.length;
395
461
  }
396
- const endMatrix = computeTrm(gs.ctm, ts);
397
- items.push({
462
+ const endMatrix = computeTrm(gs, text);
463
+ pushItem({
398
464
  kind: "text",
399
465
  codes: combined,
400
- fontResourceName: ts.fontResourceName,
466
+ fontResourceName,
401
467
  resources,
402
468
  startMatrix,
403
469
  endMatrix,
404
- sizePt: ts.fontSizePt,
470
+ sizePt: gs.fontSizePt,
405
471
  color: gs.fillColor
406
472
  });
407
473
  };
@@ -413,8 +479,8 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
413
479
  }]);
414
480
  };
415
481
  const nextLine = () => {
416
- ts.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(0, -ts.leading), ts.tlm);
417
- ts.tm = ts.tlm;
482
+ text.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(0, -gs.leading), text.tlm);
483
+ text.tm = text.tlm;
418
484
  };
419
485
  const handleDo = (name) => {
420
486
  if (name === void 0) return;
@@ -429,12 +495,14 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
429
495
  return;
430
496
  }
431
497
  const subtype = require_objects.asName(require_objects.dictGet(xobj.dict, "Subtype"));
498
+ const ownLayer = context.layerNameOf?.(require_objects.dictGet(xobj.dict, "OC"));
432
499
  if (subtype === "Image") {
433
- items.push({
500
+ pushItem({
434
501
  kind: "image",
435
502
  resourceName: name,
436
503
  resources,
437
- matrix: gs.ctm
504
+ matrix: gs.ctm,
505
+ ...ownLayer !== void 0 ? { layerName: ownLayer } : {}
438
506
  });
439
507
  return;
440
508
  }
@@ -455,12 +523,17 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
455
523
  ...gs,
456
524
  ctm: require_matrix.multiplyMatrices(formMatrix, gs.ctm)
457
525
  };
458
- runContentStream(decoded.bytes, formResources, formState, context, items, depth + 1);
526
+ const formLayer = ownLayer ?? inScope("layerName");
527
+ const formMcid = require_objects.dictGet(xobj.dict, "StructParents") !== void 0 ? void 0 : inScope("mcid");
528
+ runContentStream(decoded.bytes, formResources, formState, context, items, depth + 1, [{
529
+ ...formLayer !== void 0 ? { layerName: formLayer } : {},
530
+ ...formMcid !== void 0 ? { mcid: formMcid } : {}
531
+ }]);
459
532
  }
460
533
  };
461
534
  for (const token of operations) {
462
535
  if (token.kind === "inlineImage") {
463
- items.push({
536
+ pushItem({
464
537
  kind: "inlineImage",
465
538
  dict: token.image.dict,
466
539
  data: token.image.data,
@@ -640,6 +713,12 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
640
713
  lineWidth: numAt(operands, 0)
641
714
  };
642
715
  break;
716
+ case "d":
717
+ gs = {
718
+ ...gs,
719
+ dashArray: (require_objects.asArray(operands[0]) ?? []).map((entry) => require_objects.asNumber(entry) ?? 0)
720
+ };
721
+ break;
643
722
  case "f":
644
723
  case "F":
645
724
  case "f*":
@@ -653,39 +732,60 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
653
732
  emitPaint(operator);
654
733
  break;
655
734
  case "BT":
656
- ts = defaultTextState();
735
+ text = defaultTextObjectState();
657
736
  break;
658
737
  case "Tf":
659
- ts.fontResourceName = require_objects.asName(operands[0]);
660
- ts.fontSizePt = numAt(operands, 1);
738
+ gs = {
739
+ ...gs,
740
+ fontResourceName: require_objects.asName(operands[0]),
741
+ fontSizePt: numAt(operands, 1)
742
+ };
661
743
  break;
662
744
  case "Tc":
663
- ts.charSpace = numAt(operands, 0);
745
+ gs = {
746
+ ...gs,
747
+ charSpace: numAt(operands, 0)
748
+ };
664
749
  break;
665
750
  case "Tw":
666
- ts.wordSpace = numAt(operands, 0);
751
+ gs = {
752
+ ...gs,
753
+ wordSpace: numAt(operands, 0)
754
+ };
667
755
  break;
668
756
  case "Tz":
669
- ts.horizScale = numAt(operands, 0) / 100;
757
+ gs = {
758
+ ...gs,
759
+ horizScale: numAt(operands, 0) / 100
760
+ };
670
761
  break;
671
762
  case "TL":
672
- ts.leading = numAt(operands, 0);
763
+ gs = {
764
+ ...gs,
765
+ leading: numAt(operands, 0)
766
+ };
673
767
  break;
674
768
  case "Ts":
675
- ts.rise = numAt(operands, 0);
769
+ gs = {
770
+ ...gs,
771
+ rise: numAt(operands, 0)
772
+ };
676
773
  break;
677
774
  case "Td":
678
- ts.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(numAt(operands, 0), numAt(operands, 1)), ts.tlm);
679
- ts.tm = ts.tlm;
775
+ text.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(numAt(operands, 0), numAt(operands, 1)), text.tlm);
776
+ text.tm = text.tlm;
680
777
  break;
681
778
  case "TD":
682
- ts.leading = -numAt(operands, 1);
683
- ts.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(numAt(operands, 0), numAt(operands, 1)), ts.tlm);
684
- ts.tm = ts.tlm;
779
+ gs = {
780
+ ...gs,
781
+ leading: -numAt(operands, 1)
782
+ };
783
+ text.tlm = require_matrix.multiplyMatrices(require_matrix.translationMatrix(numAt(operands, 0), numAt(operands, 1)), text.tlm);
784
+ text.tm = text.tlm;
685
785
  break;
686
786
  case "Tm":
687
- ts.tlm = matrixFromOperands(operands);
688
- ts.tm = ts.tlm;
787
+ text.tlm = matrixFromOperands(operands);
788
+ text.tm = text.tlm;
689
789
  break;
690
790
  case "T*":
691
791
  nextLine();
@@ -702,8 +802,11 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
702
802
  break;
703
803
  }
704
804
  case "\"": {
705
- ts.wordSpace = numAt(operands, 0);
706
- ts.charSpace = numAt(operands, 1);
805
+ gs = {
806
+ ...gs,
807
+ wordSpace: numAt(operands, 0),
808
+ charSpace: numAt(operands, 1)
809
+ };
707
810
  nextLine();
708
811
  const str = operands[2];
709
812
  if (str?.kind === "string") showText(str.bytes);
@@ -714,7 +817,26 @@ function runContentStream(bytes, resources, initialState, context, items, depth)
714
817
  if (array !== void 0) showTextArray(array);
715
818
  break;
716
819
  }
717
- case "Do": handleDo(require_objects.asName(operands[0]));
820
+ case "Do":
821
+ handleDo(require_objects.asName(operands[0]));
822
+ break;
823
+ case "BDC": {
824
+ const props = markedContentProperties(operands[1], resources, context.resolver);
825
+ const layerName = context.layerNameOf?.(props === void 0 ? void 0 : require_objects.dictGet(props, "OC"));
826
+ const scopeProps = {
827
+ ...layerName !== void 0 ? { layerName } : {},
828
+ ...markedContentScopeProps(props)
829
+ };
830
+ markedContent.push(depth === 0 ? scopeProps : {
831
+ ...scopeProps,
832
+ mcid: void 0
833
+ });
834
+ break;
835
+ }
836
+ case "BMC":
837
+ markedContent.push({});
838
+ break;
839
+ case "EMC": markedContent.pop();
718
840
  }
719
841
  }
720
842
  }