@awacloud/pdf 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/CHANGELOG.md +609 -0
  2. package/LICENSE +661 -0
  3. package/NOTICE +77 -0
  4. package/README.md +363 -2
  5. package/dist/build/index.js +21 -0
  6. package/dist/build/pdf-full-rw.js +10972 -0
  7. package/dist/build/pdf-full-rw.meta.json +105 -0
  8. package/dist/build/pdf-full-rw.min.js +53 -0
  9. package/dist/build/pdf-full.js +6078 -0
  10. package/dist/build/pdf-full.meta.json +90 -0
  11. package/dist/build/pdf-full.min.js +32 -0
  12. package/dist/build/pdf-large-rw.js +10367 -0
  13. package/dist/build/pdf-large-rw.meta.json +99 -0
  14. package/dist/build/pdf-large-rw.min.js +53 -0
  15. package/dist/build/pdf-large.js +5473 -0
  16. package/dist/build/pdf-large.meta.json +84 -0
  17. package/dist/build/pdf-large.min.js +32 -0
  18. package/dist/build/pdf-legacy-rw.js +12402 -0
  19. package/dist/build/pdf-legacy-rw.meta.json +110 -0
  20. package/dist/build/pdf-legacy-rw.min.js +53 -0
  21. package/dist/build/pdf-legacy.js +7508 -0
  22. package/dist/build/pdf-legacy.meta.json +95 -0
  23. package/dist/build/pdf-legacy.min.js +32 -0
  24. package/dist/build/pdf-rw.js +7578 -0
  25. package/dist/build/pdf-rw.meta.json +77 -0
  26. package/dist/build/pdf-rw.min.js +53 -0
  27. package/dist/build/pdf.js +2684 -0
  28. package/dist/build/pdf.meta.json +62 -0
  29. package/dist/build/pdf.min.js +32 -0
  30. package/dist/standalone/pdf-full-rw.js +16798 -0
  31. package/dist/standalone/pdf-full-rw.meta.json +78 -0
  32. package/dist/standalone/pdf-full-rw.min.js +56 -0
  33. package/dist/standalone/pdf-full.js +11904 -0
  34. package/dist/standalone/pdf-full.meta.json +63 -0
  35. package/dist/standalone/pdf-full.min.js +35 -0
  36. package/dist/standalone/pdf-large-rw.js +16193 -0
  37. package/dist/standalone/pdf-large-rw.meta.json +72 -0
  38. package/dist/standalone/pdf-large-rw.min.js +56 -0
  39. package/dist/standalone/pdf-large.js +11299 -0
  40. package/dist/standalone/pdf-large.meta.json +57 -0
  41. package/dist/standalone/pdf-large.min.js +35 -0
  42. package/dist/standalone/pdf-legacy-rw.js +18228 -0
  43. package/dist/standalone/pdf-legacy-rw.meta.json +83 -0
  44. package/dist/standalone/pdf-legacy-rw.min.js +56 -0
  45. package/dist/standalone/pdf-legacy.js +13334 -0
  46. package/dist/standalone/pdf-legacy.meta.json +68 -0
  47. package/dist/standalone/pdf-legacy.min.js +35 -0
  48. package/dist/standalone/pdf-rw.js +13404 -0
  49. package/dist/standalone/pdf-rw.meta.json +50 -0
  50. package/dist/standalone/pdf-rw.min.js +56 -0
  51. package/dist/standalone/pdf.js +8510 -0
  52. package/dist/standalone/pdf.meta.json +35 -0
  53. package/dist/standalone/pdf.min.js +35 -0
  54. package/docs/README.md +53 -0
  55. package/docs/api/README.md +38 -0
  56. package/docs/api/_shared/README.md +91 -0
  57. package/docs/api/action/README.md +29 -0
  58. package/docs/api/action/action.md +81 -0
  59. package/docs/api/action/goTo.md +66 -0
  60. package/docs/api/action/launch.md +58 -0
  61. package/docs/api/action/named.md +55 -0
  62. package/docs/api/action/uri.md +54 -0
  63. package/docs/api/annot/README.md +53 -0
  64. package/docs/api/annot/annot.md +114 -0
  65. package/docs/api/annot/fileAttach.md +53 -0
  66. package/docs/api/annot/freeText.md +68 -0
  67. package/docs/api/annot/ink.md +69 -0
  68. package/docs/api/annot/link.md +74 -0
  69. package/docs/api/annot/markup.md +83 -0
  70. package/docs/api/annot/popup.md +52 -0
  71. package/docs/api/annot/projection.md +56 -0
  72. package/docs/api/annot/redact.md +67 -0
  73. package/docs/api/annot/square.md +87 -0
  74. package/docs/api/annot/stamp.md +54 -0
  75. package/docs/api/annot/text.md +69 -0
  76. package/docs/api/annot/widget.md +69 -0
  77. package/docs/api/associatedFiles/README.md +9 -0
  78. package/docs/api/associatedFiles/associatedFiles.md +78 -0
  79. package/docs/api/bundles/README.md +68 -0
  80. package/docs/api/bundles/dist-matrix.md +165 -0
  81. package/docs/api/bundles/pdf-full.md +148 -0
  82. package/docs/api/bundles/pdf-large.md +144 -0
  83. package/docs/api/bundles/pdf-legacy.md +169 -0
  84. package/docs/api/content/README.md +29 -0
  85. package/docs/api/content/color.md +99 -0
  86. package/docs/api/content/graphics.md +114 -0
  87. package/docs/api/content/images.md +124 -0
  88. package/docs/api/content/ops.md +100 -0
  89. package/docs/api/content/stream.md +107 -0
  90. package/docs/api/content/text.md +98 -0
  91. package/docs/api/crypto/README.md +29 -0
  92. package/docs/api/crypto/aesGcm.md +72 -0
  93. package/docs/api/crypto/permissions.md +79 -0
  94. package/docs/api/crypto/security.md +98 -0
  95. package/docs/api/crypto/standardV4.md +104 -0
  96. package/docs/api/crypto/standardV5.md +84 -0
  97. package/docs/api/crypto/standardV6.md +93 -0
  98. package/docs/api/destination/README.md +9 -0
  99. package/docs/api/destination/destination.md +79 -0
  100. package/docs/api/document/README.md +29 -0
  101. package/docs/api/document/builder.md +281 -0
  102. package/docs/api/document/catalog.md +98 -0
  103. package/docs/api/document/document.md +187 -0
  104. package/docs/api/document/encryptedWriter.md +149 -0
  105. package/docs/api/document/incrementalWriter.md +148 -0
  106. package/docs/api/document/page.md +99 -0
  107. package/docs/api/document/pages.md +82 -0
  108. package/docs/api/document/resources.md +102 -0
  109. package/docs/api/document/writer.md +157 -0
  110. package/docs/api/document/xrefStreamWriter.md +122 -0
  111. package/docs/api/embedded/README.md +13 -0
  112. package/docs/api/embedded/collection.md +80 -0
  113. package/docs/api/embedded/embeddedFile.md +86 -0
  114. package/docs/api/embedded/fileSpec.md +87 -0
  115. package/docs/api/errors.md +110 -0
  116. package/docs/api/extra/3d-richmedia.md +76 -0
  117. package/docs/api/extra/README.md +99 -0
  118. package/docs/api/extra/annot-extended.md +71 -0
  119. package/docs/api/extra/associated-files.md +70 -0
  120. package/docs/api/extra/ccitt-fax-decoder.md +74 -0
  121. package/docs/api/extra/color-spaces-extended.md +72 -0
  122. package/docs/api/extra/content-ops-extended.md +82 -0
  123. package/docs/api/extra/document-parts.md +69 -0
  124. package/docs/api/extra/embedded-files-portfolio.md +87 -0
  125. package/docs/api/extra/font-cid-typed.md +77 -0
  126. package/docs/api/extra/font-color-tagging.md +76 -0
  127. package/docs/api/extra/form-actions-extended.md +75 -0
  128. package/docs/api/extra/info-dict-deprecated.md +72 -0
  129. package/docs/api/extra/jbig2-read.md +80 -0
  130. package/docs/api/extra/legacy-deprecated-annots.md +89 -0
  131. package/docs/api/extra/legacy-deprecated-filters.md +78 -0
  132. package/docs/api/extra/legacy-rc4-read.md +74 -0
  133. package/docs/api/extra/legacy-xfa-read.md +65 -0
  134. package/docs/api/extra/linearization-write.md +71 -0
  135. package/docs/api/extra/misc.md +93 -0
  136. package/docs/api/extra/optional-content-extended.md +83 -0
  137. package/docs/api/extra/pdf-a-output-intent.md +65 -0
  138. package/docs/api/extra/pdf-sandbox.md +76 -0
  139. package/docs/api/extra/pdf-ua-tagged.md +63 -0
  140. package/docs/api/extra/pdf-x-prepress.md +65 -0
  141. package/docs/api/extra/redaction-iso32005.md +65 -0
  142. package/docs/api/extra/shading-typed.md +73 -0
  143. package/docs/api/extra/sig-aes-gcm.md +69 -0
  144. package/docs/api/extra/sig-pades.md +103 -0
  145. package/docs/api/extra/tagged-pdf-typed.md +78 -0
  146. package/docs/api/extra/transparency-typed.md +74 -0
  147. package/docs/api/extra/well-tagged-pdf.md +61 -0
  148. package/docs/api/extra/xmp-extended.md +65 -0
  149. package/docs/api/font/README.md +25 -0
  150. package/docs/api/font/embed.md +157 -0
  151. package/docs/api/font/encoding.md +95 -0
  152. package/docs/api/font/font.md +97 -0
  153. package/docs/api/font/type3.md +89 -0
  154. package/docs/api/form/README.md +35 -0
  155. package/docs/api/form/acroform.md +88 -0
  156. package/docs/api/form/appearance.md +87 -0
  157. package/docs/api/form/button.md +97 -0
  158. package/docs/api/form/choice.md +96 -0
  159. package/docs/api/form/fieldTree.md +93 -0
  160. package/docs/api/form/signature.md +90 -0
  161. package/docs/api/form/text.md +88 -0
  162. package/docs/api/linearization/README.md +11 -0
  163. package/docs/api/linearization/linearization.md +81 -0
  164. package/docs/api/main.md +116 -0
  165. package/docs/api/metadata/README.md +10 -0
  166. package/docs/api/metadata/info.md +70 -0
  167. package/docs/api/metadata/xmp.md +62 -0
  168. package/docs/api/ocg/README.md +23 -0
  169. package/docs/api/ocg/config.md +95 -0
  170. package/docs/api/ocg/ocg.md +77 -0
  171. package/docs/api/outline/README.md +11 -0
  172. package/docs/api/outline/outline.md +107 -0
  173. package/docs/api/pdf.md +152 -0
  174. package/docs/api/prepress/README.md +10 -0
  175. package/docs/api/prepress/outputIntent.md +79 -0
  176. package/docs/api/prepress/pageBoundary.md +75 -0
  177. package/docs/api/sig/README.md +32 -0
  178. package/docs/api/sig/byteRange.md +120 -0
  179. package/docs/api/sig/certChain.md +84 -0
  180. package/docs/api/sig/dss.md +111 -0
  181. package/docs/api/sig/oids.md +76 -0
  182. package/docs/api/sig/sha1.md +72 -0
  183. package/docs/api/sig/sign.md +317 -0
  184. package/docs/api/sig/signature.md +178 -0
  185. package/docs/api/sig/timestamp.md +84 -0
  186. package/docs/api/syntax/README.md +29 -0
  187. package/docs/api/syntax/crossRefStream.md +115 -0
  188. package/docs/api/syntax/filters/README.md +50 -0
  189. package/docs/api/syntax/filters/ascii85.md +76 -0
  190. package/docs/api/syntax/filters/asciiHex.md +73 -0
  191. package/docs/api/syntax/filters/dispatch.md +125 -0
  192. package/docs/api/syntax/filters/flate.md +134 -0
  193. package/docs/api/syntax/filters/runLength.md +78 -0
  194. package/docs/api/syntax/objStream.md +88 -0
  195. package/docs/api/syntax/parser-obj.md +97 -0
  196. package/docs/api/syntax/parser.md +151 -0
  197. package/docs/api/syntax/serializer.md +109 -0
  198. package/docs/api/syntax/tokenizer.md +104 -0
  199. package/docs/api/syntax/trailer.md +85 -0
  200. package/docs/api/syntax/xref.md +139 -0
  201. package/docs/api/tagged/README.md +25 -0
  202. package/docs/api/tagged/classMap.md +67 -0
  203. package/docs/api/tagged/markedContent.md +62 -0
  204. package/docs/api/tagged/parentTree.md +67 -0
  205. package/docs/api/tagged/roleMap.md +67 -0
  206. package/docs/api/tagged/structElement.md +76 -0
  207. package/docs/api/tagged/structTree.md +75 -0
  208. package/docs/guide/coverage.md +113 -0
  209. package/docs/guide/crypto.md +121 -0
  210. package/docs/guide/extending.md +76 -0
  211. package/docs/guide/getting-started.md +75 -0
  212. package/docs/guide/legacy-1.7.md +42 -0
  213. package/docs/guide/pades-integration.md +579 -0
  214. package/docs/guide/read-pdf.md +89 -0
  215. package/package.json +97 -4
  216. package/src/_shared/index.js +179 -0
  217. package/src/action/action.js +119 -0
  218. package/src/action/goTo.js +89 -0
  219. package/src/action/launch.js +61 -0
  220. package/src/action/named.js +54 -0
  221. package/src/action/uri.js +51 -0
  222. package/src/annot/annot.js +212 -0
  223. package/src/annot/fileAttach.js +55 -0
  224. package/src/annot/freeText.js +82 -0
  225. package/src/annot/ink.js +77 -0
  226. package/src/annot/link.js +77 -0
  227. package/src/annot/markup.js +91 -0
  228. package/src/annot/popup.js +53 -0
  229. package/src/annot/projection.js +52 -0
  230. package/src/annot/redact.js +87 -0
  231. package/src/annot/square.js +132 -0
  232. package/src/annot/stamp.js +48 -0
  233. package/src/annot/text.js +54 -0
  234. package/src/annot/widget.js +61 -0
  235. package/src/associatedFiles/associatedFiles.js +86 -0
  236. package/src/bundles/pdf-full.js +91 -0
  237. package/src/bundles/pdf-large.js +81 -0
  238. package/src/bundles/pdf-legacy.js +107 -0
  239. package/src/content/color.js +114 -0
  240. package/src/content/graphics.js +192 -0
  241. package/src/content/images.js +160 -0
  242. package/src/content/ops.js +137 -0
  243. package/src/content/stream.js +154 -0
  244. package/src/content/text.js +125 -0
  245. package/src/crypto/aesGcm.js +123 -0
  246. package/src/crypto/permissions.js +112 -0
  247. package/src/crypto/security.js +327 -0
  248. package/src/crypto/standardV4.js +443 -0
  249. package/src/crypto/standardV5.js +306 -0
  250. package/src/crypto/standardV6.js +334 -0
  251. package/src/destination/destination.js +183 -0
  252. package/src/document/builder.js +618 -0
  253. package/src/document/catalog.js +100 -0
  254. package/src/document/document.js +472 -0
  255. package/src/document/encryptedWriter.js +554 -0
  256. package/src/document/incrementalWriter.js +514 -0
  257. package/src/document/page.js +131 -0
  258. package/src/document/pages.js +103 -0
  259. package/src/document/resources.js +146 -0
  260. package/src/document/writer.js +211 -0
  261. package/src/document/xrefStreamWriter.js +353 -0
  262. package/src/embedded/collection.js +102 -0
  263. package/src/embedded/embeddedFile.js +99 -0
  264. package/src/embedded/fileSpec.js +137 -0
  265. package/src/errors.js +78 -0
  266. package/src/extra/3d-richmedia.js +171 -0
  267. package/src/extra/annot-extended.js +200 -0
  268. package/src/extra/associated-files.js +131 -0
  269. package/src/extra/ccitt-fax-decoder.js +776 -0
  270. package/src/extra/color-spaces-extended.js +196 -0
  271. package/src/extra/content-ops-extended.js +153 -0
  272. package/src/extra/document-parts.js +149 -0
  273. package/src/extra/embedded-files-portfolio.js +234 -0
  274. package/src/extra/font-cid-typed.js +185 -0
  275. package/src/extra/font-color-tagging.js +144 -0
  276. package/src/extra/form-actions-extended.js +196 -0
  277. package/src/extra/info-dict-deprecated.js +137 -0
  278. package/src/extra/jbig2-read.js +169 -0
  279. package/src/extra/legacy-deprecated-annots.js +198 -0
  280. package/src/extra/legacy-deprecated-filters.js +167 -0
  281. package/src/extra/legacy-rc4-read.js +235 -0
  282. package/src/extra/legacy-xfa-read.js +104 -0
  283. package/src/extra/linearization-write.js +97 -0
  284. package/src/extra/misc.js +217 -0
  285. package/src/extra/optional-content-extended.js +142 -0
  286. package/src/extra/pdf-a-output-intent.js +112 -0
  287. package/src/extra/pdf-sandbox.js +88 -0
  288. package/src/extra/pdf-ua-tagged.js +116 -0
  289. package/src/extra/pdf-x-prepress.js +114 -0
  290. package/src/extra/redaction-iso32005.js +136 -0
  291. package/src/extra/shading-typed.js +222 -0
  292. package/src/extra/sig-aes-gcm.js +135 -0
  293. package/src/extra/sig-pades.js +242 -0
  294. package/src/extra/tagged-pdf-typed.js +203 -0
  295. package/src/extra/transparency-typed.js +135 -0
  296. package/src/extra/well-tagged-pdf.js +138 -0
  297. package/src/extra/xmp-extended.js +190 -0
  298. package/src/font/embed.js +480 -0
  299. package/src/font/encoding.js +92 -0
  300. package/src/font/font.js +101 -0
  301. package/src/font/type3.js +75 -0
  302. package/src/form/acroform.js +94 -0
  303. package/src/form/appearance.js +90 -0
  304. package/src/form/button.js +105 -0
  305. package/src/form/choice.js +152 -0
  306. package/src/form/fieldTree.js +120 -0
  307. package/src/form/signature.js +100 -0
  308. package/src/form/text.js +101 -0
  309. package/src/linearization/linearization.js +107 -0
  310. package/src/main.js +411 -0
  311. package/src/metadata/info.js +87 -0
  312. package/src/metadata/xmp.js +62 -0
  313. package/src/ocg/config.js +156 -0
  314. package/src/ocg/ocg.js +124 -0
  315. package/src/outline/outline.js +157 -0
  316. package/src/pdf.js +133 -0
  317. package/src/prepress/outputIntent.js +118 -0
  318. package/src/prepress/pageBoundary.js +108 -0
  319. package/src/sig/byteRange.js +306 -0
  320. package/src/sig/certChain.js +247 -0
  321. package/src/sig/dss.js +317 -0
  322. package/src/sig/oids.js +157 -0
  323. package/src/sig/sha1.js +142 -0
  324. package/src/sig/sign.js +1899 -0
  325. package/src/sig/signature.js +1441 -0
  326. package/src/sig/timestamp.js +236 -0
  327. package/src/syntax/crossRefStream.js +133 -0
  328. package/src/syntax/filters/ascii85.js +122 -0
  329. package/src/syntax/filters/asciiHex.js +83 -0
  330. package/src/syntax/filters/dispatch.js +176 -0
  331. package/src/syntax/filters/flate.js +316 -0
  332. package/src/syntax/filters/runLength.js +96 -0
  333. package/src/syntax/objStream.js +99 -0
  334. package/src/syntax/parser-obj.js +52 -0
  335. package/src/syntax/parser.js +321 -0
  336. package/src/syntax/serializer.js +221 -0
  337. package/src/syntax/tokenizer.js +290 -0
  338. package/src/syntax/trailer.js +76 -0
  339. package/src/syntax/xref.js +341 -0
  340. package/src/tagged/classMap.js +81 -0
  341. package/src/tagged/markedContent.js +123 -0
  342. package/src/tagged/parentTree.js +126 -0
  343. package/src/tagged/roleMap.js +107 -0
  344. package/src/tagged/structElement.js +138 -0
  345. package/src/tagged/structTree.js +94 -0
package/src/main.js ADDED
@@ -0,0 +1,411 @@
1
+ // Copyright (c) 2026 AwaCloud SAS
2
+ // Author: Matthieu Bouilloux
3
+ // SPDX-License-Identifier: AGPL-3.0-only
4
+ // Dual-licensed; see the NOTICE file for licensing and any additional terms.
5
+
6
+ // packages/front/office/pdf/src/main.js
7
+ //
8
+ // Entry point — declarative manifest of every @awacloud/pdf module descriptor.
9
+ // Exports five arrays and the named descriptors:
10
+ //
11
+ // fw_require — the fw descriptors the modules need (zlib, aes, sha256,
12
+ // asn1, …), closed over their own dependencies.
13
+ // pkg_require — the @awacloud/fonts manifest (its `fw_require` and
14
+ // `modules`) that the font modules need.
15
+ // modules — core local factories, topologically ordered (deps
16
+ // before consumers).
17
+ // extras — opt-in extras (each wired via `pdf.use(...)`).
18
+ // bundle — bundle descriptors layering core + extras for
19
+ // `runtime.resolve('pdfLargeBundle' | 'pdfFullBundle'
20
+ // | 'pdfLegacyBundle')`.
21
+ //
22
+ // Every descriptor of `modules`, `extras` and `bundle` is also exported by
23
+ // its binding name.
24
+ //
25
+ // No runtime bootstrap, no re-export of resolved instances, no import
26
+ // of built bundles. Tests materialise via `tests/_helpers/build.js`
27
+ // and production consumers use the committed two-surface bundles under
28
+ // `dist/build/` (fw-mode) and `dist/standalone/` (framework-free), plus
29
+ // the additive named descriptor exports below.
30
+ //
31
+ // Maturity progression :
32
+ // - L0 — tokenizer + parser + xref + page tree (read-only).
33
+ // - L1 — serializer + writer + filters + ObjStm/XRefStm parsers.
34
+ // - L2 — content streams + gstate + text + color + images + Resources +
35
+ // fonts (glue to @awacloud/fonts) + AcroForm baseline.
36
+ // - L3 — annotations, tagged PDF, encryption (AES-256), digital
37
+ // signatures (PKCS#7 detached), OCG, outlines/actions/destinations,
38
+ // embedded files, linearization, metadata, prepress.
39
+
40
+ // --- fw_require — external @awacloud/fw modules consumed by `fwModules` factories.
41
+ //
42
+ // Every provider's OWN transitive deps must be registered here too, not
43
+ // just the provider itself — an unregistered provider dep makes
44
+ // `ModuleRuntime.resolve` throw `Module not found: <dep>` the first time
45
+ // a consumer factory actually runs (a provider dep propagates to every
46
+ // consumer's own fw_require/modules list). Confirmed instances, all purely additive
47
+ // (no behavior change, the providers were already declared):
48
+ // - `zlib` deps `deflate`,`adler32`; `deflate` deps `bitstream`,`huffman`,`lz77`
49
+ // (`pdfFlate` throws on the first Flate stream otherwise).
50
+ // - `pem` deps `b64`.
51
+ // - `rsa` deps `bn`,`random`; `ecc` deps `hex`,`bn`,`hmac` (`bn` deps
52
+ // `random`; `random` deps `aes`,`sha256`, already present; `hmac`
53
+ // deps `utf8`,`sha256`, already present) — needed by `pdfSign`'s
54
+ // signature-generation path.
55
+
56
+ import { bitstream } from '@awacloud/fw/io/compress/bitstream.js';
57
+ import { huffman } from '@awacloud/fw/io/compress/huffman.js';
58
+ import { deflate } from '@awacloud/fw/io/compress/deflate.js';
59
+ import { lz77 } from '@awacloud/fw/io/compress/lz77.js';
60
+ import { adler32 } from '@awacloud/fw/io/calc/adler32.js';
61
+ import { b64 } from '@awacloud/fw/io/codec/b64.js';
62
+ import { hex } from '@awacloud/fw/io/codec/hex.js';
63
+ import { zlib } from '@awacloud/fw/io/compress/zlib.js';
64
+ import { lzw } from '@awacloud/fw/io/compress/lzw.js';
65
+ import { utf8 } from '@awacloud/fw/io/codec/utf8.js';
66
+ import { aes } from '@awacloud/fw/crypto/cipher/aes.js';
67
+ import { cbc } from '@awacloud/fw/crypto/mode/cbc.js';
68
+ import { gcm } from '@awacloud/fw/crypto/mode/gcm.js';
69
+ import { sha256 } from '@awacloud/fw/crypto/hash/sha256.js';
70
+ import { sha384 } from '@awacloud/fw/crypto/hash/sha384.js';
71
+ import { sha512 } from '@awacloud/fw/crypto/hash/sha512.js';
72
+ import { bitArray } from '@awacloud/fw/crypto/utils/bitArray.js';
73
+ import { asn1 } from '@awacloud/fw/crypto/utils/asn1.js';
74
+ import { asn1Oid } from '@awacloud/fw/crypto/utils/asn1-oid.js';
75
+ import { pem } from '@awacloud/fw/crypto/utils/pem.js';
76
+ import { rsa } from '@awacloud/fw/crypto/pkc/rsa.js';
77
+ import { ecc } from '@awacloud/fw/crypto/pkc/ecc.js';
78
+ import { ed25519 } from '@awacloud/fw/crypto/pkc/ed25519.js';
79
+ import { bn } from '@awacloud/fw/crypto/utils/bn.js';
80
+ import { random } from '@awacloud/fw/crypto/utils/random.js';
81
+ import { hmac } from '@awacloud/fw/crypto/hash/hmac.js';
82
+
83
+ export const fw_require = [
84
+ bitstream, huffman, lz77, deflate, adler32,
85
+ b64, hex,
86
+ zlib, lzw, utf8,
87
+ aes, cbc, gcm,
88
+ sha256, sha384, sha512, bitArray,
89
+ asn1, asn1Oid, pem,
90
+ random, bn, hmac,
91
+ rsa, ecc, ed25519
92
+ ];
93
+
94
+ // --- pkg_require — cross-package factory descriptors from sibling
95
+ // `@awacloud/*` packages. Re-uses the foreign package's full manifest so the
96
+ // runtime can transitively resolve any dep declared by the foreign
97
+ // descriptors (e.g. `pdfFontEmbed` → `embedSubsetForPdf` → `fontSfnt`
98
+ // → `fontReader` → …).
99
+ //
100
+ // Currently only `@awacloud/fonts` is consumed (by `pdfFontEmbed` for font
101
+ // subsetting / FontDescriptor / CIDSystemInfo / ToUnicode building).
102
+
103
+ import * as fontsPkg from '@awacloud/fonts';
104
+
105
+ // `embedSubsetForPdf` (one of fonts' four `embed-pdf/*` descriptors)
106
+ // declares four transitive helper descriptors (`embedClosure`,
107
+ // `embedCmapBuilder`, `embedGlyphRewriter`, `embedHash`). The fonts
108
+ // manifest registers them in its own `modules`, so `...fontsPkg.modules`
109
+ // already closes the graph and they are NOT listed again here (a second
110
+ // listing would duplicate their names in every composer that spreads
111
+ // `pkg_require`). The bindings are imported only for the additive named
112
+ // re-exports at the end of this file.
113
+ import { embedClosure } from '@awacloud/fonts/embed-pdf/subsetForPdf/closure.js';
114
+ import { embedCmapBuilder } from '@awacloud/fonts/embed-pdf/subsetForPdf/cmap-builder.js';
115
+ import { embedGlyphRewriter } from '@awacloud/fonts/embed-pdf/subsetForPdf/glyph-rewriter.js';
116
+ import { embedHash } from '@awacloud/fonts/embed-pdf/subsetForPdf/hash.js';
117
+
118
+ export const pkg_require = [
119
+ ...fontsPkg.fw_require,
120
+ ...fontsPkg.modules
121
+ ];
122
+
123
+ // --- modules — core local factories, topologically ordered.
124
+
125
+ import { pdfErrors } from './errors.js';
126
+ import { pdfShared } from './_shared/index.js';
127
+
128
+ // Syntax
129
+ import { pdfTokenizer } from './syntax/tokenizer.js';
130
+ import { pdfParserObj } from './syntax/parser-obj.js';
131
+ import { pdfParser } from './syntax/parser.js';
132
+ import { pdfXref } from './syntax/xref.js';
133
+ import { pdfTrailer } from './syntax/trailer.js';
134
+ import { pdfSerializer } from './syntax/serializer.js';
135
+ import { pdfFlate } from './syntax/filters/flate.js';
136
+ import { pdfAsciiHex } from './syntax/filters/asciiHex.js';
137
+ import { pdfAscii85 } from './syntax/filters/ascii85.js';
138
+ import { pdfRunLength } from './syntax/filters/runLength.js';
139
+ import { pdfFilterDispatch } from './syntax/filters/dispatch.js';
140
+ import { pdfObjStream } from './syntax/objStream.js';
141
+ import { pdfCrossRefStream } from './syntax/crossRefStream.js';
142
+
143
+ // Document
144
+ import { pdfCatalog } from './document/catalog.js';
145
+ import { pdfPages } from './document/pages.js';
146
+ import { pdfPage } from './document/page.js';
147
+ import { pdfDocument } from './document/document.js';
148
+ import { pdfWriter } from './document/writer.js';
149
+ import { pdfBuilder } from './document/builder.js';
150
+ import { pdfEncryptedWriter } from './document/encryptedWriter.js';
151
+ import { pdfIncrementalWriter } from './document/incrementalWriter.js';
152
+ import { pdfXrefStreamWriter } from './document/xrefStreamWriter.js';
153
+ import { pdfResources } from './document/resources.js';
154
+
155
+ // Content (L2)
156
+ import { pdfContentOps } from './content/ops.js';
157
+ import { pdfContentStream } from './content/stream.js';
158
+ import { pdfGraphics } from './content/graphics.js';
159
+ import { pdfText } from './content/text.js';
160
+ import { pdfColor } from './content/color.js';
161
+ import { pdfImages } from './content/images.js';
162
+
163
+ // Font (L2 — glue to @awacloud/fonts)
164
+ import { pdfFont } from './font/font.js';
165
+ import { pdfFontEncoding } from './font/encoding.js';
166
+ import { pdfType3 } from './font/type3.js';
167
+ import { pdfFontEmbed } from './font/embed.js';
168
+
169
+ // AcroForm (L2)
170
+ import { pdfAcroForm } from './form/acroform.js';
171
+ import { pdfFieldTree } from './form/fieldTree.js';
172
+ import { pdfButtonField } from './form/button.js';
173
+ import { pdfTextField } from './form/text.js';
174
+ import { pdfChoiceField } from './form/choice.js';
175
+ import { pdfSignatureField } from './form/signature.js';
176
+ import { pdfAppearance } from './form/appearance.js';
177
+
178
+ // Annotations (L3)
179
+ import { pdfAnnot } from './annot/annot.js';
180
+ import { pdfTextAnnot } from './annot/text.js';
181
+ import { pdfLinkAnnot } from './annot/link.js';
182
+ import { pdfMarkupAnnot } from './annot/markup.js';
183
+ import { pdfShapeAnnot } from './annot/square.js';
184
+ import { pdfFreeTextAnnot } from './annot/freeText.js';
185
+ import { pdfInkAnnot } from './annot/ink.js';
186
+ import { pdfStampAnnot } from './annot/stamp.js';
187
+ import { pdfFileAttachAnnot } from './annot/fileAttach.js';
188
+ import { pdfWidgetAnnot } from './annot/widget.js';
189
+ import { pdfPopupAnnot } from './annot/popup.js';
190
+ import { pdfProjectionAnnot } from './annot/projection.js';
191
+ import { pdfRedactAnnot } from './annot/redact.js';
192
+
193
+ // Tagged PDF (L3)
194
+ import { pdfStructTree } from './tagged/structTree.js';
195
+ import { pdfStructElement } from './tagged/structElement.js';
196
+ import { pdfRoleMap } from './tagged/roleMap.js';
197
+ import { pdfParentTree } from './tagged/parentTree.js';
198
+ import { pdfClassMap } from './tagged/classMap.js';
199
+ import { pdfMarkedContent } from './tagged/markedContent.js';
200
+
201
+ // Encryption (L3 — fw-bound)
202
+ import { pdfSecurity } from './crypto/security.js';
203
+ import { pdfStandardV4 } from './crypto/standardV4.js';
204
+ import { pdfStandardV5 } from './crypto/standardV5.js';
205
+ import { pdfStandardV6 } from './crypto/standardV6.js';
206
+ import { pdfPermissions } from './crypto/permissions.js';
207
+ import { pdfAesGcm } from './crypto/aesGcm.js';
208
+
209
+ // Digital signatures (L3 — fw-bound)
210
+ import { pdfSigOids } from './sig/oids.js';
211
+ import { pdfSha1 } from './sig/sha1.js'; // legacy SHA-1 for PDF DSS VRI keys
212
+ import { pdfSignature } from './sig/signature.js';
213
+ import { pdfByteRange } from './sig/byteRange.js';
214
+ import { pdfTimestamp } from './sig/timestamp.js';
215
+ import { pdfCertChain } from './sig/certChain.js';
216
+ import { pdfDssBuilder } from './sig/dss.js';
217
+ import { pdfSign } from './sig/sign.js';
218
+
219
+ // Optional Content (L3)
220
+ import { pdfOCG } from './ocg/ocg.js';
221
+ import { pdfOCConfig } from './ocg/config.js';
222
+
223
+ // Outlines / Destinations / Actions (L3)
224
+ import { pdfOutline } from './outline/outline.js';
225
+ import { pdfDestination } from './destination/destination.js';
226
+ import { pdfAction } from './action/action.js';
227
+ import { pdfActionGoTo } from './action/goTo.js';
228
+ import { pdfActionUri } from './action/uri.js';
229
+ import { pdfActionNamed } from './action/named.js';
230
+ import { pdfActionLaunch } from './action/launch.js';
231
+
232
+ // Embedded files (L3)
233
+ import { pdfFileSpec } from './embedded/fileSpec.js';
234
+ import { pdfEmbeddedFile } from './embedded/embeddedFile.js';
235
+ import { pdfCollection } from './embedded/collection.js';
236
+
237
+ // Linearization / Metadata / Prepress / Associated Files (L3)
238
+ import { pdfLinearization } from './linearization/linearization.js';
239
+ import { pdfInfo } from './metadata/info.js';
240
+ import { pdfXmp } from './metadata/xmp.js';
241
+ import { pdfOutputIntent } from './prepress/outputIntent.js';
242
+ import { pdfPageBoundary } from './prepress/pageBoundary.js';
243
+ import { pdfAssociatedFiles } from './associatedFiles/associatedFiles.js';
244
+
245
+ // Top-level
246
+ import { pdf } from './pdf.js';
247
+
248
+ /**
249
+ * All @awacloud/pdf core module factories, in a registration-friendly order
250
+ * (dependencies before their dependents).
251
+ */
252
+ export const modules = [
253
+ pdfErrors,
254
+ pdfShared,
255
+ // Syntax
256
+ pdfTokenizer, pdfParserObj, pdfParser, pdfXref, pdfTrailer, pdfSerializer,
257
+ pdfAsciiHex, pdfAscii85, pdfRunLength,
258
+ pdfFlate, pdfFilterDispatch,
259
+ pdfObjStream, pdfCrossRefStream,
260
+ // Document
261
+ pdfCatalog, pdfPages, pdfPage, pdfDocument, pdfWriter, pdfBuilder, pdfIncrementalWriter, pdfResources,
262
+ pdfXrefStreamWriter,
263
+ // Content
264
+ pdfContentOps, pdfContentStream, pdfGraphics, pdfText, pdfColor, pdfImages,
265
+ // Font
266
+ pdfFont, pdfFontEncoding, pdfType3, pdfFontEmbed,
267
+ // Form
268
+ pdfAcroForm, pdfFieldTree, pdfButtonField, pdfTextField,
269
+ pdfChoiceField, pdfSignatureField, pdfAppearance,
270
+ // Annotations
271
+ pdfAnnot, pdfTextAnnot, pdfLinkAnnot, pdfMarkupAnnot, pdfShapeAnnot,
272
+ pdfFreeTextAnnot, pdfInkAnnot, pdfStampAnnot, pdfFileAttachAnnot,
273
+ pdfWidgetAnnot, pdfPopupAnnot, pdfProjectionAnnot, pdfRedactAnnot,
274
+ // Tagged
275
+ pdfStructTree, pdfStructElement, pdfRoleMap, pdfParentTree,
276
+ pdfClassMap, pdfMarkedContent,
277
+ // Crypto (fw-bound)
278
+ pdfSecurity, pdfAesGcm, pdfStandardV4, pdfStandardV5, pdfStandardV6, pdfPermissions,
279
+ pdfEncryptedWriter,
280
+ // Signatures (fw-bound)
281
+ pdfSigOids, pdfSha1,
282
+ pdfByteRange, pdfSignature, pdfTimestamp, pdfCertChain, pdfDssBuilder, pdfSign,
283
+ // OCG
284
+ pdfOCG, pdfOCConfig,
285
+ // Outlines / Actions / Destinations
286
+ pdfOutline, pdfDestination,
287
+ pdfAction, pdfActionGoTo, pdfActionUri, pdfActionNamed, pdfActionLaunch,
288
+ // Embedded
289
+ pdfFileSpec, pdfEmbeddedFile, pdfCollection,
290
+ // Linearization / Metadata / Prepress / Associated
291
+ pdfLinearization, pdfInfo, pdfXmp, pdfOutputIntent, pdfPageBoundary,
292
+ pdfAssociatedFiles,
293
+ // Top-level
294
+ pdf
295
+ ];
296
+
297
+ // --- extras — opt-in P0..P3 + legacy. Tree-shaken when unused.
298
+
299
+ import { pdfContentOpsExtended } from './extra/content-ops-extended.js';
300
+ import { pdfFontCidTyped } from './extra/font-cid-typed.js';
301
+ import { pdfFontColorTagging } from './extra/font-color-tagging.js';
302
+ import { pdfTaggedPdfTyped } from './extra/tagged-pdf-typed.js';
303
+ import { pdfAnnotExtended } from './extra/annot-extended.js';
304
+ import { pdfFormActionsExtended } from './extra/form-actions-extended.js';
305
+ import { pdfColorSpacesExtended } from './extra/color-spaces-extended.js';
306
+ import { pdfShadingTyped } from './extra/shading-typed.js';
307
+ import { pdfTransparencyTyped } from './extra/transparency-typed.js';
308
+ import { pdfSigPades } from './extra/sig-pades.js';
309
+ import { pdfSigAesGcm } from './extra/sig-aes-gcm.js';
310
+ import { pdfDocumentParts } from './extra/document-parts.js';
311
+ import { pdfRedactionIso32005 } from './extra/redaction-iso32005.js';
312
+ import { pdfAOutputIntent } from './extra/pdf-a-output-intent.js';
313
+ import { pdfXPrepress } from './extra/pdf-x-prepress.js';
314
+ import { pdfUaTagged } from './extra/pdf-ua-tagged.js';
315
+ import { pdfWellTagged } from './extra/well-tagged-pdf.js';
316
+ import { pdfOptionalContentExtended } from './extra/optional-content-extended.js';
317
+ import { pdfLinearizationWrite } from './extra/linearization-write.js';
318
+ import { pdf3dRichMedia } from './extra/3d-richmedia.js';
319
+ import { pdfEmbeddedFilesPortfolio } from './extra/embedded-files-portfolio.js';
320
+ import { pdfAssociatedFiles2 } from './extra/associated-files.js';
321
+ import { pdfXmpExtended } from './extra/xmp-extended.js';
322
+ import { pdfLegacyXfaRead } from './extra/legacy-xfa-read.js';
323
+ import { pdfLegacyRc4Read } from './extra/legacy-rc4-read.js';
324
+ import { pdfLegacyDeprecatedFilters } from './extra/legacy-deprecated-filters.js';
325
+ import { pdfCcittFaxDecoder } from './extra/ccitt-fax-decoder.js';
326
+ import { pdfLegacyDeprecatedAnnots } from './extra/legacy-deprecated-annots.js';
327
+ import { pdfJbig2Read } from './extra/jbig2-read.js';
328
+ import { pdfMisc } from './extra/misc.js';
329
+ import { pdfInfoDictDeprecated } from './extra/info-dict-deprecated.js';
330
+ import { pdfSandbox } from './extra/pdf-sandbox.js';
331
+
332
+ export const extras = [
333
+ pdfContentOpsExtended, pdfFontCidTyped, pdfFontColorTagging,
334
+ pdfTaggedPdfTyped, pdfAnnotExtended, pdfAOutputIntent, pdfUaTagged,
335
+ pdfFormActionsExtended, pdfColorSpacesExtended, pdfShadingTyped,
336
+ pdfTransparencyTyped, pdfSigPades, pdfSigAesGcm, pdfDocumentParts,
337
+ pdfRedactionIso32005, pdfXPrepress, pdfWellTagged,
338
+ pdfOptionalContentExtended, pdfEmbeddedFilesPortfolio,
339
+ pdfAssociatedFiles2, pdfXmpExtended,
340
+ pdfLinearizationWrite, pdf3dRichMedia, pdfJbig2Read, pdfMisc,
341
+ pdfInfoDictDeprecated, pdfSandbox,
342
+ pdfLegacyXfaRead, pdfLegacyRc4Read,
343
+ pdfCcittFaxDecoder,
344
+ pdfLegacyDeprecatedFilters, pdfLegacyDeprecatedAnnots
345
+ ];
346
+
347
+ // --- bundle — pure fw factory descriptors layering core + extras.
348
+
349
+ import { pdfLargeBundle } from './bundles/pdf-large.js';
350
+ import { pdfFullBundle } from './bundles/pdf-full.js';
351
+ import { pdfLegacyBundle } from './bundles/pdf-legacy.js';
352
+
353
+ export const bundle = [pdfLargeBundle, pdfFullBundle, pdfLegacyBundle];
354
+
355
+ // --- Additive named descriptor re-exports ----------------------------------
356
+ //
357
+ // Every module descriptor in the `modules` array is re-exported by its
358
+ // binding name, together with the four `@awacloud/fonts` subset helper
359
+ // bindings (`embedClosure`, `embedCmapBuilder`, `embedGlyphRewriter`,
360
+ // `embedHash` — reached through `pkg_require` via the fonts manifest).
361
+ // This lets a sibling composer (e.g. `@awacloud/oconv`, `@awacloud/facturx`)
362
+ // resolve ANY pdf dependency name via the bare `@awacloud/pdf` specifier.
363
+ // Purely additive: this block does not alter the `fw_require`,
364
+ // `pkg_require`, `modules`, `extras` and `bundle` arrays above, nor the
365
+ // `@awacloud/fonts` bridge. The generated `dist/build/index.js` barrel
366
+ // re-exports this whole namespace.
367
+ export {
368
+ // Errors / shared
369
+ pdfErrors, pdfShared,
370
+ // Syntax
371
+ pdfTokenizer, pdfParserObj, pdfParser, pdfXref, pdfTrailer,
372
+ pdfSerializer, pdfFlate, pdfAsciiHex, pdfAscii85, pdfRunLength,
373
+ pdfFilterDispatch, pdfObjStream, pdfCrossRefStream,
374
+ // Document
375
+ pdfCatalog, pdfPages, pdfPage, pdfDocument, pdfWriter, pdfBuilder,
376
+ pdfEncryptedWriter, pdfIncrementalWriter, pdfXrefStreamWriter, pdfResources,
377
+ // Content
378
+ pdfContentOps, pdfContentStream, pdfGraphics, pdfText, pdfColor, pdfImages,
379
+ // Font
380
+ pdfFont, pdfFontEncoding, pdfType3, pdfFontEmbed,
381
+ // Form
382
+ pdfAcroForm, pdfFieldTree, pdfButtonField, pdfTextField, pdfChoiceField,
383
+ pdfSignatureField, pdfAppearance,
384
+ // Annotations
385
+ pdfAnnot, pdfTextAnnot, pdfLinkAnnot, pdfMarkupAnnot, pdfShapeAnnot,
386
+ pdfFreeTextAnnot, pdfInkAnnot, pdfStampAnnot, pdfFileAttachAnnot,
387
+ pdfWidgetAnnot, pdfPopupAnnot, pdfProjectionAnnot, pdfRedactAnnot,
388
+ // Tagged
389
+ pdfStructTree, pdfStructElement, pdfRoleMap, pdfParentTree, pdfClassMap,
390
+ pdfMarkedContent,
391
+ // Encryption
392
+ pdfSecurity, pdfStandardV4, pdfStandardV5, pdfStandardV6, pdfPermissions,
393
+ pdfAesGcm,
394
+ // Signatures
395
+ pdfSigOids, pdfSha1, pdfSignature, pdfByteRange, pdfTimestamp, pdfCertChain,
396
+ pdfDssBuilder, pdfSign,
397
+ // Optional Content
398
+ pdfOCG, pdfOCConfig,
399
+ // Outlines / Destinations / Actions
400
+ pdfOutline, pdfDestination, pdfAction, pdfActionGoTo, pdfActionUri,
401
+ pdfActionNamed, pdfActionLaunch,
402
+ // Embedded files
403
+ pdfFileSpec, pdfEmbeddedFile, pdfCollection,
404
+ // Linearization / Metadata / Prepress / Associated
405
+ pdfLinearization, pdfInfo, pdfXmp, pdfOutputIntent, pdfPageBoundary,
406
+ pdfAssociatedFiles,
407
+ // Top-level
408
+ pdf,
409
+ // pkg_require — @awacloud/fonts subset helper bindings
410
+ embedClosure, embedCmapBuilder, embedGlyphRewriter, embedHash
411
+ };
@@ -0,0 +1,87 @@
1
+ // Copyright (c) 2026 AwaCloud SAS
2
+ // Author: Matthieu Bouilloux
3
+ // SPDX-License-Identifier: AGPL-3.0-only
4
+ // Dual-licensed; see the NOTICE file for licensing and any additional terms.
5
+
6
+ /**
7
+ * @fileoverview Info dict typing per ISO 32000-2:2020 §14.3.3.
8
+ *
9
+ * The trailer's `/Info` entry points to the document information
10
+ * dictionary. PDF 2.0 deprecates it in favour of XMP metadata, but
11
+ * readers are expected to tolerate its presence. Standard entries:
12
+ * /Title /Author /Subject /Keywords /Creator /Producer
13
+ * /CreationDate /ModDate /Trapped.
14
+ *
15
+ * @module pdf/metadata/info
16
+ */
17
+
18
+ /**
19
+ * Module factory.
20
+ */
21
+ import { pdfErrors } from '../errors.js';
22
+ import { pdfParser } from '../syntax/parser.js';
23
+
24
+ export const pdfInfo = {
25
+ name: 'pdfInfo',
26
+ dependencies: ['pdfErrors', 'pdfParser'],
27
+ deps: [pdfErrors, pdfParser],
28
+ factory(errors, parser) {
29
+ const { ParseError } = errors;
30
+ const { isType } = parser;
31
+
32
+ const STRINGY = ['Title', 'Author', 'Subject', 'Keywords', 'Creator', 'Producer'];
33
+ const DATEY = ['CreationDate', 'ModDate'];
34
+ const KNOWN = new Set(STRINGY.concat(DATEY, ['Trapped']));
35
+
36
+ function lower(s) { return s.charAt(0).toLowerCase() + s.slice(1); }
37
+
38
+ function typeInfo(dict) {
39
+ if (!isType(dict, 'dict')) {
40
+ throw new ParseError('pdf/info/not-dict',
41
+ 'Info must be a dictionary',
42
+ { context: { type: dict && dict.type } });
43
+ }
44
+ const e = dict.entries;
45
+ const out = { raw: dict, _extras: {} };
46
+
47
+ for (const k of STRINGY) {
48
+ if (e[k] !== undefined) {
49
+ if (e[k].type !== 'string') {
50
+ throw new ParseError('pdf/info/bad-string',
51
+ '/' + k + ' must be a string',
52
+ { context: { key: k, type: e[k].type } });
53
+ }
54
+ out[lower(k)] = e[k].value;
55
+ }
56
+ }
57
+ for (const k of DATEY) {
58
+ if (e[k] !== undefined) {
59
+ if (e[k].type !== 'string') {
60
+ throw new ParseError('pdf/info/bad-date',
61
+ '/' + k + ' must be a date string',
62
+ { context: { key: k, type: e[k].type } });
63
+ }
64
+ out[lower(k)] = e[k].value;
65
+ }
66
+ }
67
+ if (e.Trapped !== undefined) {
68
+ if (e.Trapped.type === 'name') {
69
+ out.trapped = e.Trapped.value;
70
+ } else if (e.Trapped.type === 'bool') {
71
+ out.trapped = e.Trapped.value ? 'True' : 'False';
72
+ } else {
73
+ throw new ParseError('pdf/info/bad-trapped',
74
+ '/Trapped must be a name (True|False|Unknown)',
75
+ { context: { type: e.Trapped.type } });
76
+ }
77
+ }
78
+
79
+ for (const k of Object.keys(e)) {
80
+ if (!KNOWN.has(k)) out._extras[k] = e[k];
81
+ }
82
+ return out;
83
+ }
84
+
85
+ return { typeInfo };
86
+ }
87
+ };
@@ -0,0 +1,62 @@
1
+ // Copyright (c) 2026 AwaCloud SAS
2
+ // Author: Matthieu Bouilloux
3
+ // SPDX-License-Identifier: AGPL-3.0-only
4
+ // Dual-licensed; see the NOTICE file for licensing and any additional terms.
5
+
6
+ /**
7
+ * @fileoverview XMP metadata stream typing per ISO 32000-2:2020 §14.3.2.
8
+ *
9
+ * The Catalog's `/Metadata` entry points to a stream object with
10
+ * `/Type /Metadata` and `/Subtype /XML`. The stream content is an XMP
11
+ * packet (an RDF/XML document); RDF parsing is out of scope here — we
12
+ * only expose the raw bytes and the dict typing.
13
+ *
14
+ * @module pdf/metadata/xmp
15
+ */
16
+
17
+ /**
18
+ * Module factory.
19
+ */
20
+ import { pdfErrors } from '../errors.js';
21
+ import { pdfParser } from '../syntax/parser.js';
22
+
23
+ export const pdfXmp = {
24
+ name: 'pdfXmp',
25
+ dependencies: ['pdfErrors', 'pdfParser'],
26
+ deps: [pdfErrors, pdfParser],
27
+ factory(errors, parser) {
28
+ const { ParseError } = errors;
29
+ const { isType } = parser;
30
+
31
+ function typeXmpStream(stream) {
32
+ if (!isType(stream, 'stream')) {
33
+ throw new ParseError('pdf/xmp/not-stream',
34
+ 'XMP metadata must be a stream',
35
+ { context: { type: stream && stream.type } });
36
+ }
37
+ if (!stream.dict || stream.dict.type !== 'dict') {
38
+ throw new ParseError('pdf/xmp/no-dict',
39
+ 'XMP stream missing dict');
40
+ }
41
+ const e = stream.dict.entries;
42
+ if (!e.Type || e.Type.type !== 'name' || e.Type.value !== 'Metadata') {
43
+ throw new ParseError('pdf/xmp/bad-type',
44
+ '/Type must be /Metadata',
45
+ { context: { actual: e.Type && e.Type.value } });
46
+ }
47
+ if (!e.Subtype || e.Subtype.type !== 'name' || e.Subtype.value !== 'XML') {
48
+ throw new ParseError('pdf/xmp/bad-subtype',
49
+ '/Subtype must be /XML',
50
+ { context: { actual: e.Subtype && e.Subtype.value } });
51
+ }
52
+ return {
53
+ type: 'Metadata',
54
+ subtype: 'XML',
55
+ bytes: stream.raw,
56
+ raw: stream
57
+ };
58
+ }
59
+
60
+ return { typeXmpStream };
61
+ }
62
+ };