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/codec.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_layout = require("./layout.cjs");
3
- const require_write = require("./write.cjs");
4
3
  const require_read = require("./read.cjs");
4
+ const require_write = require("./write.cjs");
5
5
  let zod = require("zod");
6
6
  //#region src/codec.ts
7
7
  const PDF_HEADER = [
package/dist/codec.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { LayoutFormField, LayoutOutlineItem, LayoutStructureElement } from "./layout.cjs";
1
2
  import { z } from "zod";
2
3
  //#region src/codec.d.ts
3
4
  declare const PdfBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
@@ -12,6 +13,19 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
12
13
  producer: z.ZodOptional<z.ZodString>;
13
14
  createdIso: z.ZodOptional<z.ZodString>;
14
15
  modifiedIso: z.ZodOptional<z.ZodString>;
16
+ lastPrintedIso: z.ZodOptional<z.ZodString>;
17
+ language: z.ZodOptional<z.ZodString>;
18
+ direction: z.ZodOptional<z.ZodEnum<{
19
+ ltr: "ltr";
20
+ rtl: "rtl";
21
+ }>>;
22
+ publisher: z.ZodOptional<z.ZodString>;
23
+ contributor: z.ZodOptional<z.ZodString>;
24
+ rights: z.ZodOptional<z.ZodString>;
25
+ identifier: z.ZodOptional<z.ZodString>;
26
+ comments: z.ZodOptional<z.ZodString>;
27
+ company: z.ZodOptional<z.ZodString>;
28
+ manager: z.ZodOptional<z.ZodString>;
15
29
  }, z.core.$strip>;
16
30
  pages: z.ZodArray<z.ZodObject<{
17
31
  widthPt: z.ZodNumber;
@@ -41,6 +55,10 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
41
55
  widthPt: z.ZodOptional<z.ZodNumber>;
42
56
  rotationDeg: z.ZodOptional<z.ZodNumber>;
43
57
  underline: z.ZodOptional<z.ZodBoolean>;
58
+ layer: z.ZodOptional<z.ZodString>;
59
+ actualText: z.ZodOptional<z.ZodString>;
60
+ alt: z.ZodOptional<z.ZodString>;
61
+ structure: z.ZodOptional<z.ZodString>;
44
62
  sourcePath: z.ZodOptional<z.ZodString>;
45
63
  }, z.core.$strip>, z.ZodObject<{
46
64
  kind: z.ZodLiteral<"image">;
@@ -50,6 +68,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
50
68
  widthPt: z.ZodNumber;
51
69
  heightPt: z.ZodNumber;
52
70
  rotationDeg: z.ZodOptional<z.ZodNumber>;
71
+ layer: z.ZodOptional<z.ZodString>;
72
+ structure: z.ZodOptional<z.ZodString>;
53
73
  sourcePath: z.ZodOptional<z.ZodString>;
54
74
  }, z.core.$strip>, z.ZodObject<{
55
75
  kind: z.ZodLiteral<"rect">;
@@ -70,6 +90,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
70
90
  }, z.core.$strip>;
71
91
  widthPt: z.ZodNumber;
72
92
  }, z.core.$strip>>;
93
+ layer: z.ZodOptional<z.ZodString>;
94
+ structure: z.ZodOptional<z.ZodString>;
73
95
  sourcePath: z.ZodOptional<z.ZodString>;
74
96
  }, z.core.$strip>, z.ZodObject<{
75
97
  kind: z.ZodLiteral<"line">;
@@ -89,6 +111,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
89
111
  dotted: "dotted";
90
112
  double: "double";
91
113
  }>>;
114
+ layer: z.ZodOptional<z.ZodString>;
115
+ structure: z.ZodOptional<z.ZodString>;
92
116
  sourcePath: z.ZodOptional<z.ZodString>;
93
117
  }, z.core.$strip>, z.ZodObject<{
94
118
  kind: z.ZodLiteral<"ellipse">;
@@ -109,6 +133,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
109
133
  }, z.core.$strip>;
110
134
  widthPt: z.ZodNumber;
111
135
  }, z.core.$strip>>;
136
+ layer: z.ZodOptional<z.ZodString>;
137
+ structure: z.ZodOptional<z.ZodString>;
112
138
  sourcePath: z.ZodOptional<z.ZodString>;
113
139
  }, z.core.$strip>, z.ZodObject<{
114
140
  kind: z.ZodLiteral<"path">;
@@ -153,6 +179,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
153
179
  dotted: "dotted";
154
180
  double: "double";
155
181
  }>>;
182
+ layer: z.ZodOptional<z.ZodString>;
183
+ structure: z.ZodOptional<z.ZodString>;
156
184
  sourcePath: z.ZodOptional<z.ZodString>;
157
185
  }, z.core.$strip>, z.ZodObject<{
158
186
  kind: z.ZodLiteral<"link">;
@@ -161,8 +189,60 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
161
189
  yPt: z.ZodNumber;
162
190
  widthPt: z.ZodNumber;
163
191
  heightPt: z.ZodNumber;
192
+ title: z.ZodOptional<z.ZodString>;
164
193
  sourcePath: z.ZodOptional<z.ZodString>;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ kind: z.ZodLiteral<"internalLink">;
196
+ destination: z.ZodString;
197
+ xPt: z.ZodNumber;
198
+ yPt: z.ZodNumber;
199
+ widthPt: z.ZodNumber;
200
+ heightPt: z.ZodNumber;
201
+ title: z.ZodOptional<z.ZodString>;
165
202
  }, z.core.$strip>], "kind">>;
203
+ annotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
204
+ subtype: z.ZodString;
205
+ xPt: z.ZodNumber;
206
+ yPt: z.ZodNumber;
207
+ widthPt: z.ZodNumber;
208
+ heightPt: z.ZodNumber;
209
+ contents: z.ZodOptional<z.ZodString>;
210
+ author: z.ZodOptional<z.ZodString>;
211
+ modifiedIso: z.ZodOptional<z.ZodString>;
212
+ quads: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodObject<{
213
+ xPt: z.ZodNumber;
214
+ yPt: z.ZodNumber;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ xPt: z.ZodNumber;
217
+ yPt: z.ZodNumber;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ xPt: z.ZodNumber;
220
+ yPt: z.ZodNumber;
221
+ }, z.core.$strip>, z.ZodObject<{
222
+ xPt: z.ZodNumber;
223
+ yPt: z.ZodNumber;
224
+ }, z.core.$strip>], null>>>;
225
+ source: z.ZodOptional<z.ZodObject<{
226
+ format: z.ZodEnum<{
227
+ docx: "docx";
228
+ pptx: "pptx";
229
+ xlsx: "xlsx";
230
+ odt: "odt";
231
+ ods: "ods";
232
+ odp: "odp";
233
+ odg: "odg";
234
+ odm: "odm";
235
+ odb: "odb";
236
+ odf: "odf";
237
+ markdown: "markdown";
238
+ pdf: "pdf";
239
+ epub: "epub";
240
+ rtf: "rtf";
241
+ wpd: "wpd";
242
+ }>;
243
+ xml: z.ZodString;
244
+ }, z.core.$strict>>;
245
+ }, z.core.$strip>>>;
166
246
  notes: z.ZodOptional<z.ZodString>;
167
247
  }, z.core.$strip>>;
168
248
  images: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -174,6 +254,60 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
174
254
  widthPx: z.ZodNumber;
175
255
  heightPx: z.ZodNumber;
176
256
  }, z.core.$strip>>;
257
+ destinations: z.ZodOptional<z.ZodArray<z.ZodObject<{
258
+ name: z.ZodString;
259
+ pageIndex: z.ZodNumber;
260
+ target: z.ZodObject<{
261
+ kind: z.ZodEnum<{
262
+ xyz: "xyz";
263
+ fit: "fit";
264
+ fitH: "fitH";
265
+ fitV: "fitV";
266
+ fitR: "fitR";
267
+ fitB: "fitB";
268
+ fitBH: "fitBH";
269
+ fitBV: "fitBV";
270
+ }>;
271
+ leftPt: z.ZodOptional<z.ZodNumber>;
272
+ topPt: z.ZodOptional<z.ZodNumber>;
273
+ bottomPt: z.ZodOptional<z.ZodNumber>;
274
+ rightPt: z.ZodOptional<z.ZodNumber>;
275
+ zoom: z.ZodOptional<z.ZodNumber>;
276
+ }, z.core.$strip>;
277
+ }, z.core.$strip>>>;
278
+ outline: z.ZodOptional<z.ZodArray<z.ZodType<LayoutOutlineItem, LayoutOutlineItem, z.core.$ZodTypeInternals<LayoutOutlineItem, LayoutOutlineItem>>>>;
279
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
280
+ name: z.ZodString;
281
+ description: z.ZodOptional<z.ZodString>;
282
+ mimeType: z.ZodOptional<z.ZodString>;
283
+ base64: z.ZodString;
284
+ }, z.core.$strip>>>;
285
+ layers: z.ZodOptional<z.ZodArray<z.ZodObject<{
286
+ name: z.ZodString;
287
+ visible: z.ZodBoolean;
288
+ }, z.core.$strip>>>;
289
+ structure: z.ZodOptional<z.ZodArray<z.ZodType<LayoutStructureElement, LayoutStructureElement, z.core.$ZodTypeInternals<LayoutStructureElement, LayoutStructureElement>>>>;
290
+ form: z.ZodOptional<z.ZodArray<z.ZodType<LayoutFormField, LayoutFormField, z.core.$ZodTypeInternals<LayoutFormField, LayoutFormField>>>>;
291
+ source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
292
+ format: z.ZodEnum<{
293
+ docx: "docx";
294
+ pptx: "pptx";
295
+ xlsx: "xlsx";
296
+ odt: "odt";
297
+ ods: "ods";
298
+ odp: "odp";
299
+ odg: "odg";
300
+ odm: "odm";
301
+ odb: "odb";
302
+ odf: "odf";
303
+ markdown: "markdown";
304
+ pdf: "pdf";
305
+ epub: "epub";
306
+ rtf: "rtf";
307
+ wpd: "wpd";
308
+ }>;
309
+ xml: z.ZodString;
310
+ }, z.core.$strict>>>;
177
311
  }, z.core.$strip>>;
178
312
  //#endregion
179
313
  export { PdfBytesSchema, pdfCodec };
package/dist/codec.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { LayoutFormField, LayoutOutlineItem, LayoutStructureElement } from "./layout.js";
1
2
  import { z } from "zod";
2
3
  //#region src/codec.d.ts
3
4
  declare const PdfBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
@@ -12,6 +13,19 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
12
13
  producer: z.ZodOptional<z.ZodString>;
13
14
  createdIso: z.ZodOptional<z.ZodString>;
14
15
  modifiedIso: z.ZodOptional<z.ZodString>;
16
+ lastPrintedIso: z.ZodOptional<z.ZodString>;
17
+ language: z.ZodOptional<z.ZodString>;
18
+ direction: z.ZodOptional<z.ZodEnum<{
19
+ ltr: "ltr";
20
+ rtl: "rtl";
21
+ }>>;
22
+ publisher: z.ZodOptional<z.ZodString>;
23
+ contributor: z.ZodOptional<z.ZodString>;
24
+ rights: z.ZodOptional<z.ZodString>;
25
+ identifier: z.ZodOptional<z.ZodString>;
26
+ comments: z.ZodOptional<z.ZodString>;
27
+ company: z.ZodOptional<z.ZodString>;
28
+ manager: z.ZodOptional<z.ZodString>;
15
29
  }, z.core.$strip>;
16
30
  pages: z.ZodArray<z.ZodObject<{
17
31
  widthPt: z.ZodNumber;
@@ -41,6 +55,10 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
41
55
  widthPt: z.ZodOptional<z.ZodNumber>;
42
56
  rotationDeg: z.ZodOptional<z.ZodNumber>;
43
57
  underline: z.ZodOptional<z.ZodBoolean>;
58
+ layer: z.ZodOptional<z.ZodString>;
59
+ actualText: z.ZodOptional<z.ZodString>;
60
+ alt: z.ZodOptional<z.ZodString>;
61
+ structure: z.ZodOptional<z.ZodString>;
44
62
  sourcePath: z.ZodOptional<z.ZodString>;
45
63
  }, z.core.$strip>, z.ZodObject<{
46
64
  kind: z.ZodLiteral<"image">;
@@ -50,6 +68,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
50
68
  widthPt: z.ZodNumber;
51
69
  heightPt: z.ZodNumber;
52
70
  rotationDeg: z.ZodOptional<z.ZodNumber>;
71
+ layer: z.ZodOptional<z.ZodString>;
72
+ structure: z.ZodOptional<z.ZodString>;
53
73
  sourcePath: z.ZodOptional<z.ZodString>;
54
74
  }, z.core.$strip>, z.ZodObject<{
55
75
  kind: z.ZodLiteral<"rect">;
@@ -70,6 +90,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
70
90
  }, z.core.$strip>;
71
91
  widthPt: z.ZodNumber;
72
92
  }, z.core.$strip>>;
93
+ layer: z.ZodOptional<z.ZodString>;
94
+ structure: z.ZodOptional<z.ZodString>;
73
95
  sourcePath: z.ZodOptional<z.ZodString>;
74
96
  }, z.core.$strip>, z.ZodObject<{
75
97
  kind: z.ZodLiteral<"line">;
@@ -89,6 +111,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
89
111
  dotted: "dotted";
90
112
  double: "double";
91
113
  }>>;
114
+ layer: z.ZodOptional<z.ZodString>;
115
+ structure: z.ZodOptional<z.ZodString>;
92
116
  sourcePath: z.ZodOptional<z.ZodString>;
93
117
  }, z.core.$strip>, z.ZodObject<{
94
118
  kind: z.ZodLiteral<"ellipse">;
@@ -109,6 +133,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
109
133
  }, z.core.$strip>;
110
134
  widthPt: z.ZodNumber;
111
135
  }, z.core.$strip>>;
136
+ layer: z.ZodOptional<z.ZodString>;
137
+ structure: z.ZodOptional<z.ZodString>;
112
138
  sourcePath: z.ZodOptional<z.ZodString>;
113
139
  }, z.core.$strip>, z.ZodObject<{
114
140
  kind: z.ZodLiteral<"path">;
@@ -153,6 +179,8 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
153
179
  dotted: "dotted";
154
180
  double: "double";
155
181
  }>>;
182
+ layer: z.ZodOptional<z.ZodString>;
183
+ structure: z.ZodOptional<z.ZodString>;
156
184
  sourcePath: z.ZodOptional<z.ZodString>;
157
185
  }, z.core.$strip>, z.ZodObject<{
158
186
  kind: z.ZodLiteral<"link">;
@@ -161,8 +189,60 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
161
189
  yPt: z.ZodNumber;
162
190
  widthPt: z.ZodNumber;
163
191
  heightPt: z.ZodNumber;
192
+ title: z.ZodOptional<z.ZodString>;
164
193
  sourcePath: z.ZodOptional<z.ZodString>;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ kind: z.ZodLiteral<"internalLink">;
196
+ destination: z.ZodString;
197
+ xPt: z.ZodNumber;
198
+ yPt: z.ZodNumber;
199
+ widthPt: z.ZodNumber;
200
+ heightPt: z.ZodNumber;
201
+ title: z.ZodOptional<z.ZodString>;
165
202
  }, z.core.$strip>], "kind">>;
203
+ annotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
204
+ subtype: z.ZodString;
205
+ xPt: z.ZodNumber;
206
+ yPt: z.ZodNumber;
207
+ widthPt: z.ZodNumber;
208
+ heightPt: z.ZodNumber;
209
+ contents: z.ZodOptional<z.ZodString>;
210
+ author: z.ZodOptional<z.ZodString>;
211
+ modifiedIso: z.ZodOptional<z.ZodString>;
212
+ quads: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodObject<{
213
+ xPt: z.ZodNumber;
214
+ yPt: z.ZodNumber;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ xPt: z.ZodNumber;
217
+ yPt: z.ZodNumber;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ xPt: z.ZodNumber;
220
+ yPt: z.ZodNumber;
221
+ }, z.core.$strip>, z.ZodObject<{
222
+ xPt: z.ZodNumber;
223
+ yPt: z.ZodNumber;
224
+ }, z.core.$strip>], null>>>;
225
+ source: z.ZodOptional<z.ZodObject<{
226
+ format: z.ZodEnum<{
227
+ docx: "docx";
228
+ pptx: "pptx";
229
+ xlsx: "xlsx";
230
+ odt: "odt";
231
+ ods: "ods";
232
+ odp: "odp";
233
+ odg: "odg";
234
+ odm: "odm";
235
+ odb: "odb";
236
+ odf: "odf";
237
+ markdown: "markdown";
238
+ pdf: "pdf";
239
+ epub: "epub";
240
+ rtf: "rtf";
241
+ wpd: "wpd";
242
+ }>;
243
+ xml: z.ZodString;
244
+ }, z.core.$strict>>;
245
+ }, z.core.$strip>>>;
166
246
  notes: z.ZodOptional<z.ZodString>;
167
247
  }, z.core.$strip>>;
168
248
  images: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -174,6 +254,60 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
174
254
  widthPx: z.ZodNumber;
175
255
  heightPx: z.ZodNumber;
176
256
  }, z.core.$strip>>;
257
+ destinations: z.ZodOptional<z.ZodArray<z.ZodObject<{
258
+ name: z.ZodString;
259
+ pageIndex: z.ZodNumber;
260
+ target: z.ZodObject<{
261
+ kind: z.ZodEnum<{
262
+ xyz: "xyz";
263
+ fit: "fit";
264
+ fitH: "fitH";
265
+ fitV: "fitV";
266
+ fitR: "fitR";
267
+ fitB: "fitB";
268
+ fitBH: "fitBH";
269
+ fitBV: "fitBV";
270
+ }>;
271
+ leftPt: z.ZodOptional<z.ZodNumber>;
272
+ topPt: z.ZodOptional<z.ZodNumber>;
273
+ bottomPt: z.ZodOptional<z.ZodNumber>;
274
+ rightPt: z.ZodOptional<z.ZodNumber>;
275
+ zoom: z.ZodOptional<z.ZodNumber>;
276
+ }, z.core.$strip>;
277
+ }, z.core.$strip>>>;
278
+ outline: z.ZodOptional<z.ZodArray<z.ZodType<LayoutOutlineItem, LayoutOutlineItem, z.core.$ZodTypeInternals<LayoutOutlineItem, LayoutOutlineItem>>>>;
279
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
280
+ name: z.ZodString;
281
+ description: z.ZodOptional<z.ZodString>;
282
+ mimeType: z.ZodOptional<z.ZodString>;
283
+ base64: z.ZodString;
284
+ }, z.core.$strip>>>;
285
+ layers: z.ZodOptional<z.ZodArray<z.ZodObject<{
286
+ name: z.ZodString;
287
+ visible: z.ZodBoolean;
288
+ }, z.core.$strip>>>;
289
+ structure: z.ZodOptional<z.ZodArray<z.ZodType<LayoutStructureElement, LayoutStructureElement, z.core.$ZodTypeInternals<LayoutStructureElement, LayoutStructureElement>>>>;
290
+ form: z.ZodOptional<z.ZodArray<z.ZodType<LayoutFormField, LayoutFormField, z.core.$ZodTypeInternals<LayoutFormField, LayoutFormField>>>>;
291
+ source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
292
+ format: z.ZodEnum<{
293
+ docx: "docx";
294
+ pptx: "pptx";
295
+ xlsx: "xlsx";
296
+ odt: "odt";
297
+ ods: "ods";
298
+ odp: "odp";
299
+ odg: "odg";
300
+ odm: "odm";
301
+ odb: "odb";
302
+ odf: "odf";
303
+ markdown: "markdown";
304
+ pdf: "pdf";
305
+ epub: "epub";
306
+ rtf: "rtf";
307
+ wpd: "wpd";
308
+ }>;
309
+ xml: z.ZodString;
310
+ }, z.core.$strict>>>;
177
311
  }, z.core.$strip>>;
178
312
  //#endregion
179
313
  export { PdfBytesSchema, pdfCodec };
package/dist/codec.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LayoutDocumentSchema } from "./layout.js";
2
- import { writePdf } from "./write.js";
3
2
  import { readPdf } from "./read.js";
3
+ import { writePdf } from "./write.js";
4
4
  import { z } from "zod";
5
5
  //#region src/codec.ts
6
6
  const PDF_HEADER = [
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_objects = require("./objects.cjs");
2
3
  const require_bytes_reader = require("./bytes/reader.cjs");
3
4
  const require_lexer = require("./lexer.cjs");
4
- const require_objects = require("./objects.cjs");
5
5
  const require_parse = require("./parse.cjs");
6
6
  //#region src/content-read.ts
7
7
  function readContentStream(bytes, sink) {
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfDict, PdfObject } from "./objects.cjs";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  //#region src/content-read.d.ts
4
4
  interface ContentOperation {
5
5
  readonly operands: readonly PdfObject[];
@@ -10,10 +10,10 @@ interface InlineImage {
10
10
  readonly data: Uint8Array<ArrayBuffer>;
11
11
  }
12
12
  type ContentToken = {
13
- readonly kind: 'operation';
13
+ readonly kind: "operation";
14
14
  readonly operation: ContentOperation;
15
15
  } | {
16
- readonly kind: 'inlineImage';
16
+ readonly kind: "inlineImage";
17
17
  readonly image: InlineImage;
18
18
  };
19
19
  declare function readContentStream(bytes: Uint8Array<ArrayBuffer>, sink: PdfDiagnosticSink): ContentToken[];
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfDict, PdfObject } from "./objects.js";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  //#region src/content-read.d.ts
4
4
  interface ContentOperation {
5
5
  readonly operands: readonly PdfObject[];
@@ -10,10 +10,10 @@ interface InlineImage {
10
10
  readonly data: Uint8Array<ArrayBuffer>;
11
11
  }
12
12
  type ContentToken = {
13
- readonly kind: 'operation';
13
+ readonly kind: "operation";
14
14
  readonly operation: ContentOperation;
15
15
  } | {
16
- readonly kind: 'inlineImage';
16
+ readonly kind: "inlineImage";
17
17
  readonly image: InlineImage;
18
18
  };
19
19
  declare function readContentStream(bytes: Uint8Array<ArrayBuffer>, sink: PdfDiagnosticSink): ContentToken[];
@@ -1,6 +1,6 @@
1
+ import { asNumber, dictGet, pdfDict } from "./objects.js";
1
2
  import { ByteReader, isAsciiWhitespace } from "./bytes/reader.js";
2
3
  import { nextToken } from "./lexer.js";
3
- import { asNumber, dictGet, pdfDict } from "./objects.js";
4
4
  import { parseValue } from "./parse.js";
5
5
  //#region src/content-read.ts
6
6
  function readContentStream(bytes, sink) {
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
3
- const require_bytes_writer = require("./bytes/writer.cjs");
2
+ const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
4
3
  const require_objects = require("./objects.cjs");
4
+ const require_bytes_writer = require("./bytes/writer.cjs");
5
+ const require_serialize = require("./serialize.cjs");
5
6
  const require_matrix = require("./matrix.cjs");
6
7
  const require_embedded_font = require("./embedded-font.cjs");
7
- const require_serialize = require("./serialize.cjs");
8
8
  //#region src/content-write.ts
9
9
  const GLYPH_SPACE_UNITS_PER_EM = 1e3;
10
10
  const EMBEDDED_HORIZONTAL_SCALE_PERCENT = 100;
@@ -313,16 +313,38 @@ function writeContentStream(items, context) {
313
313
  const writer = new require_bytes_writer.ByteWriter();
314
314
  const substitutions = [];
315
315
  const missingGlyphs = [];
316
- for (const item of items) if (item.kind === "text") writeText(writer, item, context, substitutions, missingGlyphs);
317
- else if (item.kind === "image") writeImage(writer, item, context);
318
- else if (item.kind === "rect") writeRect(writer, item);
319
- else if (item.kind === "line") writeLine(writer, item);
320
- else if (item.kind === "ellipse") writeEllipse(writer, item);
321
- else if (item.kind === "path") writePath(writer, item);
316
+ const markedStructure = [];
317
+ for (const item of items) {
318
+ const itemLayer = "layer" in item ? item.layer : void 0;
319
+ const itemStructure = "structure" in item ? item.structure : void 0;
320
+ const layerObjectNum = itemLayer !== void 0 ? context.layerObjectNumberOf?.(itemLayer) : void 0;
321
+ const marked = itemStructure !== void 0 || layerObjectNum !== void 0;
322
+ if (marked) {
323
+ writer.writeAscii("/P <<");
324
+ if (itemStructure !== void 0 && context.nextMcid !== void 0) {
325
+ const mcid = context.nextMcid();
326
+ markedStructure.push({
327
+ mcid,
328
+ structureId: itemStructure
329
+ });
330
+ writer.writeAscii(` /MCID ${mcid}`);
331
+ }
332
+ if (layerObjectNum !== void 0) writer.writeAscii(` /OC ${layerObjectNum} 0 R`);
333
+ writer.writeAscii(" >> BDC\n");
334
+ }
335
+ if (item.kind === "text") writeText(writer, item, context, substitutions, missingGlyphs);
336
+ else if (item.kind === "image") writeImage(writer, item, context);
337
+ else if (item.kind === "rect") writeRect(writer, item);
338
+ else if (item.kind === "line") writeLine(writer, item);
339
+ else if (item.kind === "ellipse") writeEllipse(writer, item);
340
+ else if (item.kind === "path") writePath(writer, item);
341
+ if (marked) writer.writeAscii("EMC\n");
342
+ }
322
343
  return {
323
344
  bytes: writer.toBytes(),
324
345
  substitutions,
325
- missingGlyphs
346
+ missingGlyphs,
347
+ markedStructure
326
348
  };
327
349
  }
328
350
  //#endregion
@@ -1,15 +1,15 @@
1
- import { r as StandardFontName } from "./afm-widths-DyDq56Ph.cjs";
1
+ import { r as StandardFontName } from "./afm-widths-CneRyu5l.cjs";
2
2
  import { LayoutItem } from "./layout.cjs";
3
- import { r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-BU6Jgcof.cjs";
3
+ import { r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-oc65VGlr.cjs";
4
4
  import { WinAnsiSubstitution } from "./winansi.cjs";
5
5
  import { LayoutFont, TextMeasurer } from "document-schema.js";
6
6
  //#region src/content-write.d.ts
7
7
  type ResolvedFontResource = {
8
- readonly kind: 'standard';
8
+ readonly kind: "standard";
9
9
  readonly resourceName: string;
10
10
  readonly standardName: StandardFontName;
11
11
  } | {
12
- readonly kind: 'embedded';
12
+ readonly kind: "embedded";
13
13
  readonly resourceName: string;
14
14
  readonly face: EmbeddedFace;
15
15
  };
@@ -20,12 +20,19 @@ interface ContentWriteContext {
20
20
  readonly measurer: TextMeasurer;
21
21
  resolveFont(font: LayoutFont): ResolvedFontResource;
22
22
  resolveImage(imageId: string): ResolvedImageResource;
23
+ readonly layerObjectNumberOf?: (name: string) => number | undefined;
24
+ readonly nextMcid?: () => number;
23
25
  }
24
26
  interface ContentStreamResult {
25
27
  readonly bytes: Uint8Array<ArrayBuffer>;
28
+ readonly markedStructure: readonly MarkedStructureItem[];
26
29
  readonly substitutions: readonly WinAnsiSubstitution[];
27
30
  readonly missingGlyphs: readonly EmbeddedFaceSubstitution[];
28
31
  }
29
32
  declare function writeContentStream(items: readonly LayoutItem[], context: ContentWriteContext): ContentStreamResult;
33
+ interface MarkedStructureItem {
34
+ readonly mcid: number;
35
+ readonly structureId: string;
36
+ }
30
37
  //#endregion
31
- export { ContentStreamResult, ContentWriteContext, ResolvedFontResource, ResolvedImageResource, writeContentStream };
38
+ export { ContentStreamResult, ContentWriteContext, MarkedStructureItem, ResolvedFontResource, ResolvedImageResource, writeContentStream };
@@ -1,15 +1,15 @@
1
- import { r as StandardFontName } from "./afm-widths-DyDq56Ph.js";
1
+ import { r as StandardFontName } from "./afm-widths-CneRyu5l.js";
2
2
  import { LayoutItem } from "./layout.js";
3
- import { r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-fREdbxnr.js";
3
+ import { r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-B4p9a3O3.js";
4
4
  import { WinAnsiSubstitution } from "./winansi.js";
5
5
  import { LayoutFont, TextMeasurer } from "document-schema.js";
6
6
  //#region src/content-write.d.ts
7
7
  type ResolvedFontResource = {
8
- readonly kind: 'standard';
8
+ readonly kind: "standard";
9
9
  readonly resourceName: string;
10
10
  readonly standardName: StandardFontName;
11
11
  } | {
12
- readonly kind: 'embedded';
12
+ readonly kind: "embedded";
13
13
  readonly resourceName: string;
14
14
  readonly face: EmbeddedFace;
15
15
  };
@@ -20,12 +20,19 @@ interface ContentWriteContext {
20
20
  readonly measurer: TextMeasurer;
21
21
  resolveFont(font: LayoutFont): ResolvedFontResource;
22
22
  resolveImage(imageId: string): ResolvedImageResource;
23
+ readonly layerObjectNumberOf?: (name: string) => number | undefined;
24
+ readonly nextMcid?: () => number;
23
25
  }
24
26
  interface ContentStreamResult {
25
27
  readonly bytes: Uint8Array<ArrayBuffer>;
28
+ readonly markedStructure: readonly MarkedStructureItem[];
26
29
  readonly substitutions: readonly WinAnsiSubstitution[];
27
30
  readonly missingGlyphs: readonly EmbeddedFaceSubstitution[];
28
31
  }
29
32
  declare function writeContentStream(items: readonly LayoutItem[], context: ContentWriteContext): ContentStreamResult;
33
+ interface MarkedStructureItem {
34
+ readonly mcid: number;
35
+ readonly structureId: string;
36
+ }
30
37
  //#endregion
31
- export { ContentStreamResult, ContentWriteContext, ResolvedFontResource, ResolvedImageResource, writeContentStream };
38
+ export { ContentStreamResult, ContentWriteContext, MarkedStructureItem, ResolvedFontResource, ResolvedImageResource, writeContentStream };