@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/NOTICE ADDED
@@ -0,0 +1,77 @@
1
+ @awacloud/pdf
2
+ Copyright (c) 2026 AwaCloud SAS
3
+ Author: Matthieu Bouilloux
4
+
5
+ Licensed under AGPL-3.0-only; see the LICENSE file.
6
+ SPDX-License-Identifier: AGPL-3.0-only
7
+
8
+ AWACLOUD and AWA are trademarks of Towards Conseil, used under licence.
9
+
10
+ This package is also available under a commercial licence from AwaCloud SAS (see https://awacloud.com/offers).
11
+ Commercial licensing: sales@awacloud.com
12
+
13
+ Additional terms (AGPL-3.0 section 7):
14
+ Scope. AwaCloud SAS, the copyright holder, adds the following terms under
15
+ section 7 of the GNU Affero General Public License version 3 (the "AGPL")
16
+ to the parts of this software of which it holds the copyright (the
17
+ "Material"). They do not apply to third-party components, which remain
18
+ under their own licences, nor to use of this software under a commercial
19
+ licence from AwaCloud SAS, which is governed by that licence alone. They
20
+ do not limit the purposes, commercial or otherwise, for which the Material
21
+ may be run, modified or conveyed. Each term is to be read as going no
22
+ further than section 7 of the AGPL permits, and each is separate from the
23
+ others.
24
+
25
+ 1. Notices and author attribution (section 7(b)). In every copy of the
26
+ Material and of modified versions of it, you must preserve: (a) in each
27
+ source file that contains the Material, the copyright notices of
28
+ AwaCloud SAS, the author attributions (such as "Author: Matthieu
29
+ Bouilloux"), the licence notices and the notice indicating where to
30
+ find these terms; and (b) when you convey the Material in a non-source
31
+ form, including bundled or minified forms, those copyright notices,
32
+ author attributions and licence notices, and these terms, in the
33
+ object code itself, in a text file or other materials provided with
34
+ it, or at the place from which it is offered. The statement that this
35
+ software is also available under a commercial licence, including the
36
+ word "Dual-licensed" in file headers, and the commercial contact need
37
+ not be preserved.
38
+
39
+ 2. Appropriate Legal Notices (section 7(b)). Where a work containing the
40
+ Material displays Appropriate Legal Notices, you must preserve in them,
41
+ as plain text, the copyright notice of AwaCloud SAS and the attribution
42
+ of the Material to its author, Matthieu Bouilloux. A list of components
43
+ reached from those notices is sufficient. No logo, link, product name,
44
+ badge or promotional statement is required, and nothing needs to be
45
+ added to documents, web pages or other output produced by running the
46
+ work.
47
+
48
+ 3. Origin and modified versions (section 7(c)). You may not misrepresent
49
+ the origin of the Material. A modified version may not be presented as
50
+ the original version published by AwaCloud SAS, or as provided,
51
+ endorsed or supported by it. It must be marked in reasonable ways as
52
+ different from the original; the notices required by section 5(a) of
53
+ the AGPL, together with a statement in the NOTICE file, a change log or
54
+ another text file conveyed with it that it has been modified and when,
55
+ are sufficient. Keeping the original import paths, file headers,
56
+ copyright notices and author attributions is not a misrepresentation
57
+ of origin.
58
+
59
+ 4. Publicity (section 7(d)). The names of AwaCloud SAS and of Matthieu
60
+ Bouilloux may not be used to endorse or promote a product or service
61
+ derived from the Material without prior written permission from
62
+ AwaCloud SAS or, for his name, from him. This does not limit accurate
63
+ statements of origin or the notices required by these terms.
64
+
65
+ 5. Trademarks (section 7(e)). AwaCloud SAS declines to grant, under the
66
+ AGPL, any rights under trademark law in the names AWA and AWACLOUD, in
67
+ any spelling or case, which are trademarks of Towards Conseil used by
68
+ AwaCloud SAS under licence, or in the trade name AwaCloud and related
69
+ logos. This does not prevent you from preserving the notices required
70
+ by these terms, keeping the original import paths, or stating
71
+ accurately that your work is based on or uses the Material.
72
+
73
+ 6. Indemnification (section 7(f)). Anyone who conveys the Material, or a
74
+ modified version of it, with contractual assumptions of liability to
75
+ the recipient must indemnify AwaCloud SAS and Matthieu Bouilloux for
76
+ any liability that those contractual assumptions directly impose on
77
+ them.
package/README.md CHANGED
@@ -1,3 +1,364 @@
1
- # Temporary Holding Version
1
+ # @awacloud/pdf
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pure JavaScript library to read and write PDF documents in the browser, with
4
+ no runtime dependency beyond
5
+ [`@awacloud/fw`](https://github.com/awacloud/awa/tree/@awacloud/pdf@1.0.0/packages/front/fw)
6
+ and
7
+ [`@awacloud/fonts`](https://github.com/awacloud/awa/tree/@awacloud/pdf@1.0.0/packages/front/office/fonts).
8
+ The reference is ISO 32000-2:2020 (PDF 2.0); PDF 1.x files
9
+ are read too. `pdf.write` emits a `%PDF-2.0` header; `pdfBuilder.setVersion`
10
+ and `pdfWriter.writeDocument({ version })` emit the header they are given
11
+ (for example `%PDF-1.7`). Objects are re-emitted as read, not converted.
12
+
13
+ The core reads the file structure (classical cross-reference tables,
14
+ cross-reference streams, object streams, incremental updates) into a typed
15
+ object graph, and types the document layer on top of it: pages, resources,
16
+ content streams, fonts (parsing delegated to `@awacloud/fonts`), AcroForm,
17
+ annotations, Tagged PDF, optional content, outlines, actions, destinations,
18
+ embedded files, metadata and prepress boxes. It writes documents from a read
19
+ model or from scratch (`pdfBuilder`), as an incremental update, with
20
+ cross-reference streams, or encrypted with the standard security handler. It signs and verifies
21
+ PKCS#7 / PAdES signatures (levels B, T, LT, LTA) with public-key verification
22
+ through `@awacloud/fw/crypto/*` (synchronous, worker-safe, no Web Crypto). An
23
+ opt-in layer (`extra/*`) adds the long tail of PDF 2.0 and PDF 1.7 legacy
24
+ reading, grouped into the bundles `pdf-large`, `pdf-full` and `pdf-legacy`.
25
+
26
+ Known limits, so they are not a surprise:
27
+
28
+ - The whole file must be in memory as a `Uint8Array`; there is no streaming
29
+ reader.
30
+ - An encrypted file is refused by `read` (`pdf/document/encrypted`) unless
31
+ you opt in to the raw container; decryption is done by calling the
32
+ security-handler modules (`pdfSecurity`, `pdfStandardV4/V5/V6`) yourself.
33
+ - Content streams are parsed to an operator list, not rendered.
34
+ - `write` re-emits the objects it is given: it does not convert legacy
35
+ content (XFA, RC4 encryption, LZW streams, Sound / Movie annotations) to
36
+ PDF 2.0 equivalents.
37
+ - JBIG2 is read at the segment-header level only (no image decode), and the
38
+ linearization extra builds the linearization dictionary and a hint-stream
39
+ placeholder, not a linearized file.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install @awacloud/pdf
45
+ ```
46
+
47
+ In the browser, via import map:
48
+
49
+ ```html
50
+ <script type="importmap">
51
+ { "imports": {
52
+ "@awacloud/fw": "/node_modules/@awacloud/fw/src/main.js",
53
+ "@awacloud/fw/": "/node_modules/@awacloud/fw/src/",
54
+ "@awacloud/fonts": "/node_modules/@awacloud/fonts/src/main.js",
55
+ "@awacloud/fonts/": "/node_modules/@awacloud/fonts/src/",
56
+ "@awacloud/pdf": "/node_modules/@awacloud/pdf/src/main.js",
57
+ "@awacloud/pdf/": "/node_modules/@awacloud/pdf/src/"
58
+ }}
59
+ </script>
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ In the snippets below, `bytes` is a `Uint8Array` holding a PDF file.
65
+
66
+ ### Stand-alone (without the `@awacloud/fw` runtime)
67
+
68
+ `pdf` (`src/pdf.js`) is a factory descriptor whose `factory` takes its
69
+ dependencies as positional arguments, so `import { pdf } from '@awacloud/pdf'`
70
+ cannot be invoked on its own. The zero-ceremony path is the committed
71
+ `dist/standalone` build, whose `pdf` root has every dependency inlined and is
72
+ invocable with no arguments:
73
+
74
+ ```js
75
+ import { pdfBundled } from '@awacloud/pdf/standalone/pdf.js';
76
+
77
+ const api = pdfBundled.factory();
78
+ const doc = api.read(bytes); // Uint8Array → typed model
79
+ console.log(doc.version); // header version, e.g. "1.5" or "2.0"
80
+ console.log(doc.pages.length); // number of pages
81
+ console.log(doc.pages[0].mediaBox); // the page's own /MediaBox, or null when inherited
82
+
83
+ const out = api.write(doc); // → Uint8Array, %PDF-2.0
84
+ console.log(api.read(out).pages.length); // the written file reads back
85
+ ```
86
+
87
+ `api.write(doc)` re-emits the read model's indirect object graph in canonical
88
+ form: `%PDF-2.0` header, sequential objects, classical cross-reference table,
89
+ trailer. The layered `dist/standalone` roots (`pdf-large`, `pdf-full`,
90
+ `pdf-legacy` and the four `-rw` roots) are invocable the same way — see
91
+ [Committed dist](#committed-dist--two-build-surfaces) below.
92
+
93
+ ### With the `@awacloud/fw` runtime
94
+
95
+ ```js
96
+ import { ModuleRuntime } from '@awacloud/fw/core/runtime.js';
97
+ import { fw_require, modules } from '@awacloud/pdf';
98
+
99
+ const rt = new ModuleRuntime();
100
+ for (const m of fw_require) rt.register(m);
101
+ for (const m of modules) rt.register(m);
102
+
103
+ const api = rt.resolve('pdf');
104
+ const doc = api.read(bytes);
105
+ console.log(doc.pages.length);
106
+ ```
107
+
108
+ ### `.use(...)` hook (idempotent extension)
109
+
110
+ ```js
111
+ import { pdfBundled } from '@awacloud/pdf/standalone/pdf.js';
112
+
113
+ const api = pdfBundled.factory();
114
+ api.use({
115
+ name: 'my-extra',
116
+ register(self) {
117
+ return {
118
+ countAnnots: (b) => self.read(b).pages
119
+ .reduce((n, p) => n + p.annots.length, 0)
120
+ };
121
+ }
122
+ });
123
+ console.log(api.countAnnots(bytes));
124
+ console.log(api.usedExtension('my-extra')); // true
125
+ ```
126
+
127
+ `.use()` is **idempotent by name**: applying the same extension twice is a
128
+ no-op.
129
+
130
+ ### With a bundle (extras wired automatically)
131
+
132
+ Bundles are module descriptors, consumed through a `ModuleRuntime`:
133
+
134
+ ```js
135
+ import { ModuleRuntime } from '@awacloud/fw/core/runtime.js';
136
+ import { fw_require, pkg_require, modules, extras, bundle } from '@awacloud/pdf';
137
+
138
+ const rt = new ModuleRuntime();
139
+ for (const m of fw_require) rt.register(m);
140
+ for (const m of pkg_require) rt.register(m);
141
+ for (const m of modules) rt.register(m);
142
+ for (const m of extras) rt.register(m);
143
+ for (const m of bundle) rt.register(m);
144
+
145
+ const api = rt.resolve('pdfLargeBundle');
146
+ const doc = api.read(bytes);
147
+ console.log(doc.pages.length);
148
+
149
+ // Each wired extra is reachable under its factory name:
150
+ console.log(api.usedExtension('pdfAOutputIntent')); // true
151
+ console.log(api.pdfAOutputIntent.PDFA_PROFILES['2b'].iso); // 'ISO 19005-2:2011'
152
+ ```
153
+
154
+ ## Reading cross-reference forms
155
+
156
+ `api.read(bytes)` accepts classical (`xref` table) and PDF 1.5+
157
+ cross-reference-stream (`/Type /XRef`, §7.5.8) sections — mixed `/Prev`
158
+ chains and hybrid-reference files (a classical trailer carrying `/XRefStm`)
159
+ resolve end to end, and objects held in a `/Type /ObjStm` container (§7.5.7)
160
+ are materialised on demand. `/DecodeParms` (e.g. a PNG predictor on a
161
+ cross-reference stream) reach the decoders as plain parameters and are
162
+ honoured, and an indirect `/ExtGState` (or other resource category) on a page
163
+ does not drop the whole resource map. A non-catalog object that is free but
164
+ still referenced degrades to a recorded entry in `doc.losses` instead of
165
+ throwing (a free `/Root` is still refused); `appendIncremental` extends a
166
+ cross-reference-stream base with an uncompressed `/Type /XRef` section.
167
+
168
+ ## Bundles
169
+
170
+ `src/main.js` exports the five descriptor arrays (`fw_require`,
171
+ `pkg_require`, `modules`, `extras`, `bundle`) and every `modules` descriptor
172
+ by binding name; the `extras` and `bundle` descriptors are **not** exported
173
+ individually from the root, so `import { pdfLargeBundle } from '@awacloud/pdf'`
174
+ is `undefined` — register the arrays as above, or import one bundle from its
175
+ own sub-path (`@awacloud/pdf/pdf-large`, `@awacloud/pdf/pdf-full`,
176
+ `@awacloud/pdf/pdf-legacy`).
177
+
178
+ - `pdfLargeBundle` — the core plus the P0 and P1 extras (common PDF 2.0
179
+ features).
180
+ - `pdfFullBundle` — `pdf-large` plus the P2 and P3 extras, including the
181
+ opt-in action sandbox linter.
182
+ - `pdfLegacyBundle` — `pdf-full` plus the PDF 1.7 legacy readers (XFA, RC4,
183
+ deprecated filters, deprecated multimedia annotations).
184
+
185
+ Each bundle's extras are listed literally in its descriptor's
186
+ `dependencies`; see [`docs/api/bundles/`](docs/api/bundles/README.md) for the
187
+ per-bundle tables.
188
+
189
+ ## Committed dist — two build surfaces
190
+
191
+ For consumers who don't want to hand-assemble the `fw_require` / `modules`
192
+ manifest, `dist/` ships a committed, pre-generated build: an 8-root matrix
193
+ crossing the four assembly roots (`pdf`, `pdf-large`, `pdf-full`,
194
+ `pdf-legacy`, the **Read** family) with four `-rw` roots (`pdf-rw`,
195
+ `pdf-large-rw`, `pdf-full-rw`, `pdf-legacy-rw`, the **Read+Write** family —
196
+ each Read root plus the write inventory, including `pdfXrefStreamWriter`, and
197
+ the signature verifier `pdfSignature` beside the signer), in two
198
+ path-discriminated surfaces:
199
+
200
+ | Surface | Path | Contents |
201
+ |---|---|---|
202
+ | `dist/build/` | `@awacloud/pdf/build/<root>` | fw-mode: declares its `@awacloud/fw` modules as `dependencies` (DI-injected), needs an `@awacloud/fw` runtime |
203
+ | `dist/standalone/` | `@awacloud/pdf/standalone/<root>` | framework-free: every reachable fw factory inlined in the body, zero runtime dependency (Worker-serializable) |
204
+
205
+ Each root emits a `.js` / `.min.js` / `.meta.json` triplet (e.g.
206
+ `dist/build/pdf-large.js`, `pdf-large.min.js`, `pdf-large.meta.json`), plus a
207
+ single `dist/build/index.js` barrel re-exporting the whole `src/main.js`
208
+ namespace (the five registration arrays and every named descriptor) for
209
+ registration on an `@awacloud/fw` runtime. Each `.meta.json` sidecar records
210
+ the root's `modules`, `fwDependencies` (read back from the generated
211
+ descriptor, never hardcoded) and build byte sizes. See
212
+ [`docs/api/bundles/dist-matrix.md`](docs/api/bundles/dist-matrix.md) for the
213
+ 8-root × 2-surface table, the `-rw` naming scheme and the write inventory.
214
+
215
+ Idempotence: `bun run gen:bundles` (`tools/generate-bundles.mjs`) produces
216
+ byte-identical output across runs (no build stamp; every `.js` / `.min.js`
217
+ opens with the `/*! … */` licence banner at byte 0). It is a thin wrapper
218
+ around `@awacloud/tool-prebuild-generator`, a build tool of the source
219
+ monorepo that is not published.
220
+
221
+ **Invocability**: every `dist/standalone` root is invocable with no
222
+ arguments, the layered ones included — each layered extra is registered
223
+ through the `{ name, register }` envelope `pdf.use()` requires, so
224
+ `pdfRwBundled.factory()` returns a core on which
225
+ `core.usedExtension('pdfSign')` and `core.usedExtension('pdfSignature')` are
226
+ both `true` and `core.pdfSignature.verifySignature` is callable. The
227
+ `dist/build` roots need an `@awacloud/fw` runtime to inject their declared
228
+ dependencies.
229
+
230
+ ## Source structure
231
+
232
+ ```
233
+ src/
234
+ ├── main.js — entry point: the five descriptor arrays + named descriptors
235
+ ├── pdf.js — top-level api (read, header, write, use, usedExtension)
236
+ ├── errors.js — `pdfErrors` (PdfError + ParseError / RenderError /
237
+ │ ContractError / EncryptionError + isPdfError)
238
+ ├── _shared/ — `pdfShared` byte constants and stateless helpers
239
+ ├── syntax/ — tokenizer, parser, serializer, xref, trailer,
240
+ │ object streams, cross-reference streams, filters/
241
+ ├── document/ — catalog, page tree, document reader, writers
242
+ │ (classical, builder, incremental, xref-stream, encrypted)
243
+ ├── content/ font/ form/ annot/ tagged/ ocg/ outline/ destination/ action/
244
+ ├── embedded/ associatedFiles/ linearization/ metadata/ prepress/
245
+ ├── crypto/ — security handlers V4 / V5 / V6, permissions, AES-GCM
246
+ ├── sig/ — signature typing + verification, signing, ByteRange,
247
+ │ RFC 3161 timestamps, certificate chains, DSS
248
+ ├── extra/ — opt-in extras (P0–P3 + legacy)
249
+ └── bundles/ — pdf-large, pdf-full, pdf-legacy descriptors
250
+ ```
251
+
252
+ ## Documentation
253
+
254
+ | Guide | Link |
255
+ |-------|------|
256
+ | Getting started | [`docs/guide/getting-started.md`](docs/guide/getting-started.md) |
257
+ | Read pipeline | [`docs/guide/read-pdf.md`](docs/guide/read-pdf.md) |
258
+ | Extending via `.use()` | [`docs/guide/extending.md`](docs/guide/extending.md) |
259
+ | Coverage | [`docs/guide/coverage.md`](docs/guide/coverage.md) |
260
+ | PDF 1.7 legacy reading | [`docs/guide/legacy-1.7.md`](docs/guide/legacy-1.7.md) |
261
+ | Crypto — risks and limitations | [`docs/guide/crypto.md`](docs/guide/crypto.md) |
262
+ | PAdES signing and verification | [`docs/guide/pades-integration.md`](docs/guide/pades-integration.md) |
263
+
264
+ API per module: [`docs/api/README.md`](docs/api/README.md). Sibling package
265
+ with the same factory + bundles layout:
266
+ [`@awacloud/ooxml`](https://github.com/awacloud/awa/tree/@awacloud/pdf@1.0.0/packages/front/office/ooxml).
267
+
268
+ ## Tests
269
+
270
+ ```
271
+ $ bun test packages/front/office/pdf/
272
+ ```
273
+
274
+ Co-located unit tests (`*.test.js` next to each source file) plus integration
275
+ suites under `tests/`, among them:
276
+
277
+ - `tests/roundtrip.integration.test.js` — wiring via the `@awacloud/fw`
278
+ `ModuleRuntime`, read → write → read, worker transportability of every
279
+ factory
280
+ - `tests/legacy-conversion.test.js` — PDF 1.x read tolerance
281
+ - `tests/fuzz.test.js` — garbage and truncated input → typed `ParseError`
282
+ - `tests/_helpers/build.js` — shared fixture builder
283
+
284
+ ## Design choices
285
+
286
+ - **Plain binary format** — no ZIP (unlike `@awacloud/ooxml` and
287
+ `@awacloud/odf`). The PDF container is its own format: `%PDF-2.0` header +
288
+ indirect objects + cross-reference section + trailer.
289
+ - **Worker-safe** — each factory is self-sufficient (serializable via
290
+ `factory.toString()`). Constants are inlined in the body, no mutable
291
+ module-level closure.
292
+ - **No external dependency** — `@awacloud/fw` and `@awacloud/fonts` only.
293
+ Codecs that `@awacloud/fw` does not provide (the simple filters, RC4, CCITT
294
+ fax) are implemented in this package.
295
+ - **Typed errors** — no raw `throw new Error(...)`; only `PdfError` and its
296
+ subclasses, with a stable kebab-case `code` and a structured `context`.
297
+ The classes are not exported at the top level: they are declared inside
298
+ the `pdfErrors` factory body, so each `pdfErrors.factory()` call creates a
299
+ fresh set of classes. Resolve `pdfErrors` through one `ModuleRuntime`
300
+ (which caches the instance) to share class identities across consumers;
301
+ across two separate `factory()` calls, `instanceof` does not hold — compare
302
+ `e.code` instead.
303
+
304
+ ## Exposed sub-paths
305
+
306
+ | Sub-path | Target | Usage |
307
+ |---|---|---|
308
+ | `@awacloud/pdf` | `src/main.js` | entry point — the five descriptor arrays + every core descriptor by name |
309
+ | `@awacloud/pdf/pdf` | `src/pdf.js` | the top-level `pdf` descriptor only |
310
+ | `@awacloud/pdf/errors` | `src/errors.js` | the `pdfErrors` descriptor (resolves `PdfError` + 4 subclasses) |
311
+ | `@awacloud/pdf/serializer` | `src/syntax/serializer.js` | the `pdfSerializer` descriptor (typed object → bytes) |
312
+ | `@awacloud/pdf/filters/*.js` | `src/syntax/filters/*.js` | stream filters by file name with the `.js` suffix, e.g. `@awacloud/pdf/filters/ascii85.js` |
313
+ | `@awacloud/pdf/filters/*` | `src/syntax/filters/*.js` | stream filters (`flate`, `asciiHex`, `ascii85`, `runLength`, `dispatch`); resolved by Bun/Node through the exports map |
314
+ | `@awacloud/pdf/annot/*.js` | `src/annot/*.js` | annotations by file name with the `.js` suffix, e.g. `@awacloud/pdf/annot/annot.js` |
315
+ | `@awacloud/pdf/annot/*` | `src/annot/*.js` | annotations (text, link, markup, widget, redact, …); resolved by Bun/Node through the exports map |
316
+ | `@awacloud/pdf/tagged/*.js` | `src/tagged/*.js` | Tagged PDF by file name with the `.js` suffix |
317
+ | `@awacloud/pdf/tagged/*` | `src/tagged/*.js` | Tagged PDF (structure tree, elements, parent tree, …); resolved by Bun/Node through the exports map |
318
+ | `@awacloud/pdf/crypto/*.js` | `src/crypto/*.js` | encryption by file name with the `.js` suffix |
319
+ | `@awacloud/pdf/crypto/*` | `src/crypto/*.js` | encryption (security handlers V4 / V5 / V6, permissions, AES-GCM); resolved by Bun/Node through the exports map |
320
+ | `@awacloud/pdf/sig/*.js` | `src/sig/*.js` | signatures by file name with the `.js` suffix |
321
+ | `@awacloud/pdf/sig/*` | `src/sig/*.js` | signatures (verify, sign, ByteRange, RFC 3161, certificate chain, DSS); resolved by Bun/Node through the exports map |
322
+ | `@awacloud/pdf/ocg/*.js` | `src/ocg/*.js` | optional content by file name with the `.js` suffix |
323
+ | `@awacloud/pdf/ocg/*` | `src/ocg/*.js` | optional content (OCG + configuration); resolved by Bun/Node through the exports map |
324
+ | `@awacloud/pdf/action/*.js` | `src/action/*.js` | actions by file name with the `.js` suffix |
325
+ | `@awacloud/pdf/action/*` | `src/action/*.js` | actions (GoTo, URI, Named, Launch, …); resolved by Bun/Node through the exports map |
326
+ | `@awacloud/pdf/embedded/*.js` | `src/embedded/*.js` | embedded files by file name with the `.js` suffix |
327
+ | `@awacloud/pdf/embedded/*` | `src/embedded/*.js` | embedded files (file specification, embedded file, collection); resolved by Bun/Node through the exports map |
328
+ | `@awacloud/pdf/metadata/*.js` | `src/metadata/*.js` | metadata by file name with the `.js` suffix |
329
+ | `@awacloud/pdf/metadata/*` | `src/metadata/*.js` | metadata (Info dictionary, XMP); resolved by Bun/Node through the exports map |
330
+ | `@awacloud/pdf/prepress/*.js` | `src/prepress/*.js` | prepress by file name with the `.js` suffix |
331
+ | `@awacloud/pdf/prepress/*` | `src/prepress/*.js` | prepress (output intents, page boundaries); resolved by Bun/Node through the exports map |
332
+ | `@awacloud/pdf/extra/*.js` | `src/extra/*.js` | opt-in extra descriptors by file name with the `.js` suffix |
333
+ | `@awacloud/pdf/extra/*` | `src/extra/*.js` | opt-in extra descriptors (P0–P3 + legacy); resolved by Bun/Node through the exports map |
334
+ | `@awacloud/pdf/bundles/*.js` | `src/bundles/*.js` | bundle descriptors by file name with the `.js` suffix |
335
+ | `@awacloud/pdf/bundles/*` | `src/bundles/*.js` | bundle descriptors (`pdf-large`, `pdf-full`, `pdf-legacy`); resolved by Bun/Node through the exports map |
336
+ | `@awacloud/pdf/pdf-large` | `src/bundles/pdf-large.js` | the `pdfLargeBundle` descriptor |
337
+ | `@awacloud/pdf/pdf-full` | `src/bundles/pdf-full.js` | the `pdfFullBundle` descriptor |
338
+ | `@awacloud/pdf/pdf-legacy` | `src/bundles/pdf-legacy.js` | the `pdfLegacyBundle` descriptor |
339
+ | `@awacloud/pdf/build/*` | `dist/build/*` | committed fw-mode build — Read roots (`pdf`, `pdf-large`, `pdf-full`, `pdf-legacy`), Read+Write roots (`pdf-rw`, `pdf-large-rw`, `pdf-full-rw`, `pdf-legacy-rw`), and the `index.js` barrel |
340
+ | `@awacloud/pdf/standalone/*` | `dist/standalone/*` | committed framework-free build, same 8 roots |
341
+
342
+ The `src/document/*` modules (writers, builder, catalog, pages, resources)
343
+ have no sub-path of their own: they are reached through the root entry's
344
+ named descriptors.
345
+
346
+ ## Maturity
347
+
348
+ L4 (`awa.maturity` in `package.json`): the package covers its declared
349
+ surface, within the limits listed above, and ships a test suite and
350
+ per-module reference pages.
351
+
352
+ ## Licence
353
+
354
+ `AGPL-3.0-only` — see [`LICENSE`](./LICENSE). The package is also available
355
+ under a commercial licence; see [`NOTICE`](./NOTICE).
356
+
357
+ Copyright (c) 2026 AwaCloud SAS
358
+
359
+ ## Project
360
+
361
+ - Website: https://awaforge.eu
362
+ - Source: [`packages/front/office/pdf`](https://github.com/awacloud/awa/tree/@awacloud/pdf@1.0.0/packages/front/office/pdf)
363
+ - Issues: https://github.com/awacloud/awa/issues
364
+ - Security policy: https://github.com/awacloud/awa/blob/@awacloud/pdf@1.0.0/SECURITY.md
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) 2026 AwaCloud SAS
3
+ * Author: Matthieu Bouilloux
4
+ * SPDX-License-Identifier: AGPL-3.0-only
5
+ * Dual-licensed; see the NOTICE file for licensing and any additional terms.
6
+ */
7
+ /* GENERATED — do not edit. Source: packages/front/office/pdf/tools/generate-bundles.mjs */
8
+
9
+ /**
10
+ * @fileoverview `@awacloud/pdf/build` — fw-mode barrel.
11
+ *
12
+ * Re-exports the whole `@awacloud/pdf` main namespace: the four registration
13
+ * arrays (`fw_require`, `pkg_require`, `modules`, `extras`, `bundle`) and
14
+ * every individual module descriptor. Consumers register these on their
15
+ * own `@awacloud/fw` runtime. The framework-free counterpart lives under
16
+ * `dist/standalone/`.
17
+ *
18
+ * @module pdf/build
19
+ */
20
+
21
+ export * from '../../src/main.js';