pdf-parser.js 3.0.7 → 4.5.1

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/layout.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { ColorSchema, ContentStrokeStyleSchema, LayoutFontSchema, LayoutMetadataSchema } from "document-schema.js";
2
+ import { ColorSchema, ContentStrokeStyleSchema, LayoutFontSchema, LayoutMetadataSchema, SourceResidueSchema } from "document-schema.js";
3
3
  //#region src/layout.ts
4
4
  const LAYOUT_FORMAT_VERSION = 1;
5
5
  const LayoutTextSchema = z.object({
@@ -13,6 +13,10 @@ const LayoutTextSchema = z.object({
13
13
  widthPt: z.number().nonnegative().optional(),
14
14
  rotationDeg: z.number().optional(),
15
15
  underline: z.boolean().optional(),
16
+ layer: z.string().optional(),
17
+ actualText: z.string().optional(),
18
+ alt: z.string().optional(),
19
+ structure: z.string().optional(),
16
20
  sourcePath: z.string().optional()
17
21
  });
18
22
  const LayoutImageSchema = z.object({
@@ -23,6 +27,8 @@ const LayoutImageSchema = z.object({
23
27
  widthPt: z.number().positive(),
24
28
  heightPt: z.number().positive(),
25
29
  rotationDeg: z.number().optional(),
30
+ layer: z.string().optional(),
31
+ structure: z.string().optional(),
26
32
  sourcePath: z.string().optional()
27
33
  });
28
34
  const LayoutRectSchema = z.object({
@@ -36,6 +42,8 @@ const LayoutRectSchema = z.object({
36
42
  color: ColorSchema,
37
43
  widthPt: z.number().positive()
38
44
  }).optional(),
45
+ layer: z.string().optional(),
46
+ structure: z.string().optional(),
39
47
  sourcePath: z.string().optional()
40
48
  });
41
49
  const LayoutLineSchema = z.object({
@@ -47,6 +55,8 @@ const LayoutLineSchema = z.object({
47
55
  color: ColorSchema,
48
56
  widthPt: z.number().positive(),
49
57
  style: ContentStrokeStyleSchema.optional(),
58
+ layer: z.string().optional(),
59
+ structure: z.string().optional(),
50
60
  sourcePath: z.string().optional()
51
61
  });
52
62
  const LayoutEllipseSchema = z.object({
@@ -60,6 +70,8 @@ const LayoutEllipseSchema = z.object({
60
70
  color: ColorSchema,
61
71
  widthPt: z.number().positive()
62
72
  }).optional(),
73
+ layer: z.string().optional(),
74
+ structure: z.string().optional(),
63
75
  sourcePath: z.string().optional()
64
76
  });
65
77
  const LayoutPathSegmentSchema = z.discriminatedUnion("kind", [z.object({
@@ -91,6 +103,8 @@ const LayoutPathSchema = z.object({
91
103
  widthPt: z.number().positive()
92
104
  }).optional(),
93
105
  style: ContentStrokeStyleSchema.optional(),
106
+ layer: z.string().optional(),
107
+ structure: z.string().optional(),
94
108
  sourcePath: z.string().optional()
95
109
  });
96
110
  const LayoutLinkSchema = z.object({
@@ -100,8 +114,18 @@ const LayoutLinkSchema = z.object({
100
114
  yPt: z.number(),
101
115
  widthPt: z.number().nonnegative(),
102
116
  heightPt: z.number().nonnegative(),
117
+ title: z.string().optional(),
103
118
  sourcePath: z.string().optional()
104
119
  });
120
+ const LayoutInternalLinkSchema = z.object({
121
+ kind: z.literal("internalLink"),
122
+ destination: z.string(),
123
+ xPt: z.number(),
124
+ yPt: z.number(),
125
+ widthPt: z.number().nonnegative(),
126
+ heightPt: z.number().nonnegative(),
127
+ title: z.string().optional()
128
+ });
105
129
  const LayoutItemSchema = z.discriminatedUnion("kind", [
106
130
  LayoutTextSchema,
107
131
  LayoutImageSchema,
@@ -109,12 +133,44 @@ const LayoutItemSchema = z.discriminatedUnion("kind", [
109
133
  LayoutLineSchema,
110
134
  LayoutEllipseSchema,
111
135
  LayoutPathSchema,
112
- LayoutLinkSchema
136
+ LayoutLinkSchema,
137
+ LayoutInternalLinkSchema
113
138
  ]);
139
+ const LayoutAnnotationQuadSchema = z.tuple([
140
+ z.object({
141
+ xPt: z.number(),
142
+ yPt: z.number()
143
+ }),
144
+ z.object({
145
+ xPt: z.number(),
146
+ yPt: z.number()
147
+ }),
148
+ z.object({
149
+ xPt: z.number(),
150
+ yPt: z.number()
151
+ }),
152
+ z.object({
153
+ xPt: z.number(),
154
+ yPt: z.number()
155
+ })
156
+ ]);
157
+ const LayoutAnnotationSchema = z.object({
158
+ subtype: z.string(),
159
+ xPt: z.number(),
160
+ yPt: z.number(),
161
+ widthPt: z.number().nonnegative(),
162
+ heightPt: z.number().nonnegative(),
163
+ contents: z.string().optional(),
164
+ author: z.string().optional(),
165
+ modifiedIso: z.string().optional(),
166
+ quads: z.array(LayoutAnnotationQuadSchema).optional(),
167
+ source: SourceResidueSchema.optional()
168
+ });
114
169
  const LayoutPageSchema = z.object({
115
170
  widthPt: z.number().positive(),
116
171
  heightPt: z.number().positive(),
117
172
  items: z.array(LayoutItemSchema),
173
+ annotations: z.array(LayoutAnnotationSchema).optional(),
118
174
  notes: z.string().optional()
119
175
  });
120
176
  const LayoutImageAssetSchema = z.object({
@@ -123,11 +179,91 @@ const LayoutImageAssetSchema = z.object({
123
179
  widthPx: z.number().int().positive(),
124
180
  heightPx: z.number().int().positive()
125
181
  });
182
+ const LayoutDestinationTargetSchema = z.object({
183
+ kind: z.enum([
184
+ "xyz",
185
+ "fit",
186
+ "fitH",
187
+ "fitV",
188
+ "fitR",
189
+ "fitB",
190
+ "fitBH",
191
+ "fitBV"
192
+ ]),
193
+ leftPt: z.number().optional(),
194
+ topPt: z.number().optional(),
195
+ bottomPt: z.number().optional(),
196
+ rightPt: z.number().optional(),
197
+ zoom: z.number().optional()
198
+ });
199
+ const LayoutDestinationSchema = z.object({
200
+ name: z.string(),
201
+ pageIndex: z.number().int().nonnegative(),
202
+ target: LayoutDestinationTargetSchema
203
+ });
204
+ const LayoutOutlineItemSchema = z.lazy(() => z.object({
205
+ title: z.string(),
206
+ destination: z.string().optional(),
207
+ children: z.array(LayoutOutlineItemSchema)
208
+ }));
209
+ const LayoutAttachmentSchema = z.object({
210
+ name: z.string(),
211
+ description: z.string().optional(),
212
+ mimeType: z.string().optional(),
213
+ base64: z.string()
214
+ });
215
+ const LayoutFormWidgetSchema = z.object({
216
+ pageIndex: z.number().int().nonnegative(),
217
+ xPt: z.number(),
218
+ yPt: z.number(),
219
+ widthPt: z.number().nonnegative(),
220
+ heightPt: z.number().nonnegative()
221
+ });
222
+ const LayoutFormFieldSchema = z.lazy(() => z.object({
223
+ name: z.string(),
224
+ fieldType: z.enum([
225
+ "text",
226
+ "checkbox",
227
+ "radio",
228
+ "button",
229
+ "listbox",
230
+ "combobox",
231
+ "signature",
232
+ "group"
233
+ ]),
234
+ value: z.string().optional(),
235
+ checked: z.boolean().optional(),
236
+ options: z.array(z.string()).optional(),
237
+ alias: z.string().optional(),
238
+ readOnly: z.boolean().optional(),
239
+ widgets: z.array(LayoutFormWidgetSchema),
240
+ children: z.array(LayoutFormFieldSchema)
241
+ }));
242
+ const LayoutLayerSchema = z.object({
243
+ name: z.string(),
244
+ visible: z.boolean()
245
+ });
246
+ const LayoutStructureElementSchema = z.lazy(() => z.object({
247
+ id: z.string(),
248
+ type: z.string(),
249
+ title: z.string().optional(),
250
+ language: z.string().optional(),
251
+ alt: z.string().optional(),
252
+ actualText: z.string().optional(),
253
+ children: z.array(LayoutStructureElementSchema)
254
+ }));
126
255
  const LayoutDocumentSchema = z.object({
127
256
  formatVersion: z.literal(1),
128
257
  metadata: LayoutMetadataSchema,
129
258
  pages: z.array(LayoutPageSchema),
130
- images: z.record(z.string(), LayoutImageAssetSchema)
259
+ images: z.record(z.string(), LayoutImageAssetSchema),
260
+ destinations: z.array(LayoutDestinationSchema).optional(),
261
+ outline: z.array(LayoutOutlineItemSchema).optional(),
262
+ attachments: z.array(LayoutAttachmentSchema).optional(),
263
+ layers: z.array(LayoutLayerSchema).optional(),
264
+ structure: z.array(LayoutStructureElementSchema).optional(),
265
+ form: z.array(LayoutFormFieldSchema).optional(),
266
+ source: z.record(z.string(), SourceResidueSchema).optional()
131
267
  });
132
268
  //#endregion
133
- export { LAYOUT_FORMAT_VERSION, LayoutDocumentSchema, LayoutEllipseSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutItemSchema, LayoutLineSchema, LayoutLinkSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutSubpathSchema, LayoutTextSchema };
269
+ export { 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 };
package/dist/lexer.d.cts CHANGED
@@ -1,27 +1,27 @@
1
1
  import { ByteReader } from "./bytes/reader.cjs";
2
2
  //#region src/lexer.d.ts
3
3
  type Token = {
4
- readonly kind: 'number';
4
+ readonly kind: "number";
5
5
  readonly value: number;
6
6
  } | {
7
- readonly kind: 'name';
7
+ readonly kind: "name";
8
8
  readonly value: string;
9
9
  } | {
10
- readonly kind: 'literalString';
10
+ readonly kind: "literalString";
11
11
  readonly value: Uint8Array<ArrayBuffer>;
12
12
  } | {
13
- readonly kind: 'hexString';
13
+ readonly kind: "hexString";
14
14
  readonly value: Uint8Array<ArrayBuffer>;
15
15
  } | {
16
- readonly kind: 'arrayStart';
16
+ readonly kind: "arrayStart";
17
17
  } | {
18
- readonly kind: 'arrayEnd';
18
+ readonly kind: "arrayEnd";
19
19
  } | {
20
- readonly kind: 'dictStart';
20
+ readonly kind: "dictStart";
21
21
  } | {
22
- readonly kind: 'dictEnd';
22
+ readonly kind: "dictEnd";
23
23
  } | {
24
- readonly kind: 'keyword';
24
+ readonly kind: "keyword";
25
25
  readonly value: string;
26
26
  };
27
27
  declare function nextToken(reader: ByteReader): Token | undefined;
package/dist/lexer.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  import { ByteReader } from "./bytes/reader.js";
2
2
  //#region src/lexer.d.ts
3
3
  type Token = {
4
- readonly kind: 'number';
4
+ readonly kind: "number";
5
5
  readonly value: number;
6
6
  } | {
7
- readonly kind: 'name';
7
+ readonly kind: "name";
8
8
  readonly value: string;
9
9
  } | {
10
- readonly kind: 'literalString';
10
+ readonly kind: "literalString";
11
11
  readonly value: Uint8Array<ArrayBuffer>;
12
12
  } | {
13
- readonly kind: 'hexString';
13
+ readonly kind: "hexString";
14
14
  readonly value: Uint8Array<ArrayBuffer>;
15
15
  } | {
16
- readonly kind: 'arrayStart';
16
+ readonly kind: "arrayStart";
17
17
  } | {
18
- readonly kind: 'arrayEnd';
18
+ readonly kind: "arrayEnd";
19
19
  } | {
20
- readonly kind: 'dictStart';
20
+ readonly kind: "dictStart";
21
21
  } | {
22
- readonly kind: 'dictEnd';
22
+ readonly kind: "dictEnd";
23
23
  } | {
24
- readonly kind: 'keyword';
24
+ readonly kind: "keyword";
25
25
  readonly value: string;
26
26
  };
27
27
  declare function nextToken(reader: ByteReader): Token | undefined;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_bytes_writer = require("./bytes/writer.cjs");
3
2
  const require_objects = require("./objects.cjs");
3
+ const require_bytes_writer = require("./bytes/writer.cjs");
4
4
  const require_serialize = require("./serialize.cjs");
5
5
  //#region src/math-content-write.ts
6
6
  function toPdfX(positioned, itemXPt) {
@@ -1,5 +1,5 @@
1
- import { ByteWriter } from "./bytes/writer.js";
2
1
  import { pdfDict, pdfHexString, pdfName } from "./objects.js";
2
+ import { ByteWriter } from "./bytes/writer.js";
3
3
  import { formatNumber, writeObject } from "./serialize.js";
4
4
  //#region src/math-content-write.ts
5
5
  function toPdfX(positioned, itemXPt) {
@@ -40,7 +40,7 @@ function buildFontFileStream(font, compress) {
40
40
  }
41
41
  function toUnicodeEntries(usedGlyphs) {
42
42
  const entries = /* @__PURE__ */ new Map();
43
- for (const [glyphId, codePoint] of usedGlyphs) if (codePoint !== void 0) entries.set(glyphId, codePoint);
43
+ for (const [glyphId, codePoint] of usedGlyphs) if (codePoint !== void 0) entries.set(glyphId, [codePoint]);
44
44
  return entries;
45
45
  }
46
46
  function buildMathFontObjects(font, usedGlyphs, refs, compress) {
@@ -1,4 +1,4 @@
1
- import { PdfDict, PdfObject } from "./objects.cjs";
1
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
2
2
  import { MathFont } from "./math-font.cjs";
3
3
  //#region src/math-font-write.d.ts
4
4
  interface MathFontObjectRefs {
@@ -1,4 +1,4 @@
1
- import { PdfDict, PdfObject } from "./objects.js";
1
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
2
2
  import { MathFont } from "./math-font.js";
3
3
  //#region src/math-font-write.d.ts
4
4
  interface MathFontObjectRefs {
@@ -39,7 +39,7 @@ function buildFontFileStream(font, compress) {
39
39
  }
40
40
  function toUnicodeEntries(usedGlyphs) {
41
41
  const entries = /* @__PURE__ */ new Map();
42
- for (const [glyphId, codePoint] of usedGlyphs) if (codePoint !== void 0) entries.set(glyphId, codePoint);
42
+ for (const [glyphId, codePoint] of usedGlyphs) if (codePoint !== void 0) entries.set(glyphId, [codePoint]);
43
43
  return entries;
44
44
  }
45
45
  function buildMathFontObjects(font, usedGlyphs, refs, compress) {
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_util_base64 = require("./util/base64.cjs");
2
3
  const require_sfnt = require("./sfnt.cjs");
3
- const require_cff_bounds = require("./cff-bounds.cjs");
4
4
  const require_cmap_table = require("./cmap-table.cjs");
5
- const require_util_base64 = require("./util/base64.cjs");
5
+ const require_cff_bounds = require("./cff-bounds.cjs");
6
6
  const require_hmtx_table = require("./hmtx-table.cjs");
7
7
  const require_assets_stix_two_math_font = require("./assets/stix-two-math-font.cjs");
8
8
  const require_math_stretch = require("./math-stretch.cjs");
@@ -1,6 +1,6 @@
1
1
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
2
2
  import { r as MathGlyphConstruction } from "./math-table-gFNB8DmQ.cjs";
3
- import { t as MathStretchConstruction } from "./math-stretch-E26z6byT.cjs";
3
+ import { t as MathStretchConstruction } from "./math-stretch-C2JanDAz.cjs";
4
4
  import { MathFontMetrics, MathStretchAxis } from "document-schema.js";
5
5
  //#region src/math-font.d.ts
6
6
  interface MathFontDescriptorMetrics {
@@ -1,6 +1,6 @@
1
1
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
2
2
  import { r as MathGlyphConstruction } from "./math-table-DhPrNoPa.js";
3
- import { t as MathStretchConstruction } from "./math-stretch-a_rHNRvc.js";
3
+ import { t as MathStretchConstruction } from "./math-stretch-BbC2o4Br.js";
4
4
  import { MathFontMetrics, MathStretchAxis } from "document-schema.js";
5
5
  //#region src/math-font.d.ts
6
6
  interface MathFontDescriptorMetrics {
package/dist/math-font.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { base64ToBytes } from "./util/base64.js";
1
2
  import { i16, parseSfnt, sfntTableBytes, u16 } from "./sfnt.js";
2
- import { parseCffGlyphBounds } from "./cff-bounds.js";
3
3
  import { buildCmapLookup } from "./cmap-table.js";
4
- import { base64ToBytes } from "./util/base64.js";
4
+ import { parseCffGlyphBounds } from "./cff-bounds.js";
5
5
  import { parseHmtx } from "./hmtx-table.js";
6
6
  import { STIX_TWO_MATH_FONT_BASE64 } from "./assets/stix-two-math-font.js";
7
7
  import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stretch.js";
@@ -7,7 +7,7 @@ interface MathStretchPlacement {
7
7
  readonly advance: number;
8
8
  }
9
9
  interface MathStretchConstruction {
10
- readonly kind: 'base' | 'variant' | 'assembly';
10
+ readonly kind: "base" | "variant" | "assembly";
11
11
  readonly axis: MathStretchAxis;
12
12
  readonly size: number;
13
13
  readonly italicsCorrection: number;
@@ -7,7 +7,7 @@ interface MathStretchPlacement {
7
7
  readonly advance: number;
8
8
  }
9
9
  interface MathStretchConstruction {
10
- readonly kind: 'base' | 'variant' | 'assembly';
10
+ readonly kind: "base" | "variant" | "assembly";
11
11
  readonly axis: MathStretchAxis;
12
12
  readonly size: number;
13
13
  readonly italicsCorrection: number;
@@ -1,2 +1,2 @@
1
- import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-E26z6byT.cjs";
1
+ import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-C2JanDAz.cjs";
2
2
  export { MathStretchConstruction, MathStretchOptions, MathStretchPlacement, assembleStretchyGlyph, scaleMathStretchConstruction };
@@ -1,2 +1,2 @@
1
- import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-a_rHNRvc.js";
1
+ import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-BbC2o4Br.js";
2
2
  export { MathStretchConstruction, MathStretchOptions, MathStretchPlacement, assembleStretchyGlyph, scaleMathStretchConstruction };
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-BoeTOK2r.cjs");
2
+ const require_afm_widths = require("./afm-widths-BTu0IDp2.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
@@ -1,7 +1,7 @@
1
1
  import { FontRegistry } from "./font-registry.cjs";
2
2
  import { TextMeasurer } from "document-schema.js";
3
3
  //#region src/measure.d.ts
4
- type VerticalMetricPolicy = 'hhea' | 'os2Typo' | 'os2Win';
4
+ type VerticalMetricPolicy = "hhea" | "os2Typo" | "os2Win";
5
5
  declare const DEFAULT_VERTICAL_METRIC_POLICY: VerticalMetricPolicy;
6
6
  interface StandardFontMeasurerOptions {
7
7
  readonly widthCorrectionByFamily?: Readonly<Record<string, number>>;
package/dist/measure.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FontRegistry } from "./font-registry.js";
2
2
  import { TextMeasurer } from "document-schema.js";
3
3
  //#region src/measure.d.ts
4
- type VerticalMetricPolicy = 'hhea' | 'os2Typo' | 'os2Win';
4
+ type VerticalMetricPolicy = "hhea" | "os2Typo" | "os2Win";
5
5
  declare const DEFAULT_VERTICAL_METRIC_POLICY: VerticalMetricPolicy;
6
6
  interface StandardFontMeasurerOptions {
7
7
  readonly widthCorrectionByFamily?: Readonly<Record<string, number>>;
package/dist/measure.js CHANGED
@@ -1,4 +1,4 @@
1
- import { o as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-Dxucrg7D.js";
1
+ import { h as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-De_QMWgC.js";
2
2
  import { encodeForShowEmbedded } from "./embedded-font.js";
3
3
  import { resolveFaceWithRegistry } from "./font-registry.js";
4
4
  //#region src/measure.ts
package/dist/names.cjs ADDED
@@ -0,0 +1,41 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_objects = require("./objects.cjs");
3
+ const require_pdf_text = require("./pdf-text.cjs");
4
+ //#region src/names.ts
5
+ function walkNameTree(root, resolver, sink) {
6
+ const entries = [];
7
+ collectNameTreeEntries(root, resolver, sink, entries, /* @__PURE__ */ new Set());
8
+ return entries;
9
+ }
10
+ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
11
+ const dict = require_objects.asDict(resolver.resolve(node));
12
+ if (dict === void 0) {
13
+ if (node !== void 0) sink({
14
+ code: "pdf/name-tree-node-invalid",
15
+ severity: "warning",
16
+ message: "a name tree node did not resolve to a dictionary; skipping it"
17
+ });
18
+ return;
19
+ }
20
+ if (visited.has(dict)) {
21
+ sink({
22
+ code: "pdf/name-tree-cycle",
23
+ severity: "warning",
24
+ message: "the name tree contains a cycle; stopping descent at the repeated node"
25
+ });
26
+ return;
27
+ }
28
+ visited.add(dict);
29
+ const names = require_objects.asArray(require_objects.dictGet(dict, "Names"));
30
+ if (names !== void 0) for (let i = 0; i + 1 < names.length; i += 2) {
31
+ const key = names[i];
32
+ if (key?.kind === "string") entries.push({
33
+ name: require_pdf_text.decodePdfString(key.bytes),
34
+ value: names[i + 1]
35
+ });
36
+ }
37
+ const kids = require_objects.asArray(require_objects.dictGet(dict, "Kids"));
38
+ if (kids !== void 0) for (const kid of kids) collectNameTreeEntries(kid, resolver, sink, entries, visited);
39
+ }
40
+ //#endregion
41
+ exports.walkNameTree = walkNameTree;
@@ -0,0 +1,11 @@
1
+ import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
+ import { PdfObjectResolver } from "./interpret.cjs";
4
+ //#region src/names.d.ts
5
+ interface NameTreeEntry {
6
+ readonly name: string;
7
+ readonly value: PdfObject;
8
+ }
9
+ declare function walkNameTree(root: PdfObject | undefined, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): NameTreeEntry[];
10
+ //#endregion
11
+ export { NameTreeEntry, walkNameTree };
@@ -0,0 +1,11 @@
1
+ import { PdfDiagnosticSink } from "./diagnostics.js";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.js";
3
+ import { PdfObjectResolver } from "./interpret.js";
4
+ //#region src/names.d.ts
5
+ interface NameTreeEntry {
6
+ readonly name: string;
7
+ readonly value: PdfObject;
8
+ }
9
+ declare function walkNameTree(root: PdfObject | undefined, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): NameTreeEntry[];
10
+ //#endregion
11
+ export { NameTreeEntry, walkNameTree };
package/dist/names.js ADDED
@@ -0,0 +1,40 @@
1
+ import { asArray, asDict, dictGet } from "./objects.js";
2
+ import { decodePdfString } from "./pdf-text.js";
3
+ //#region src/names.ts
4
+ function walkNameTree(root, resolver, sink) {
5
+ const entries = [];
6
+ collectNameTreeEntries(root, resolver, sink, entries, /* @__PURE__ */ new Set());
7
+ return entries;
8
+ }
9
+ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
10
+ const dict = asDict(resolver.resolve(node));
11
+ if (dict === void 0) {
12
+ if (node !== void 0) sink({
13
+ code: "pdf/name-tree-node-invalid",
14
+ severity: "warning",
15
+ message: "a name tree node did not resolve to a dictionary; skipping it"
16
+ });
17
+ return;
18
+ }
19
+ if (visited.has(dict)) {
20
+ sink({
21
+ code: "pdf/name-tree-cycle",
22
+ severity: "warning",
23
+ message: "the name tree contains a cycle; stopping descent at the repeated node"
24
+ });
25
+ return;
26
+ }
27
+ visited.add(dict);
28
+ const names = asArray(dictGet(dict, "Names"));
29
+ if (names !== void 0) for (let i = 0; i + 1 < names.length; i += 2) {
30
+ const key = names[i];
31
+ if (key?.kind === "string") entries.push({
32
+ name: decodePdfString(key.bytes),
33
+ value: names[i + 1]
34
+ });
35
+ }
36
+ const kids = asArray(dictGet(dict, "Kids"));
37
+ if (kids !== void 0) for (const kid of kids) collectNameTreeEntries(kid, resolver, sink, entries, visited);
38
+ }
39
+ //#endregion
40
+ export { walkNameTree };