@codecloud-dev/pdf-lib-plus 0.0.0-stage → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1541) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +1528 -2
  3. package/README.zh.md +119 -0
  4. package/cjs/api/Embeddable.d.ts +8 -0
  5. package/cjs/api/Embeddable.d.ts.map +1 -0
  6. package/cjs/api/Embeddable.js +3 -0
  7. package/cjs/api/Embeddable.js.map +1 -0
  8. package/cjs/api/PDFDocument.d.ts +779 -0
  9. package/cjs/api/PDFDocument.d.ts.map +1 -0
  10. package/cjs/api/PDFDocument.js +1369 -0
  11. package/cjs/api/PDFDocument.js.map +1 -0
  12. package/cjs/api/PDFDocumentOptions.d.ts +38 -0
  13. package/cjs/api/PDFDocumentOptions.d.ts.map +1 -0
  14. package/cjs/api/PDFDocumentOptions.js +11 -0
  15. package/cjs/api/PDFDocumentOptions.js.map +1 -0
  16. package/cjs/api/PDFEmbeddedFile.d.ts +39 -0
  17. package/cjs/api/PDFEmbeddedFile.d.ts.map +1 -0
  18. package/cjs/api/PDFEmbeddedFile.js +84 -0
  19. package/cjs/api/PDFEmbeddedFile.js.map +1 -0
  20. package/cjs/api/PDFEmbeddedPage.d.ts +74 -0
  21. package/cjs/api/PDFEmbeddedPage.d.ts.map +1 -0
  22. package/cjs/api/PDFEmbeddedPage.js +95 -0
  23. package/cjs/api/PDFEmbeddedPage.js.map +1 -0
  24. package/cjs/api/PDFFont.d.ts +95 -0
  25. package/cjs/api/PDFFont.d.ts.map +1 -0
  26. package/cjs/api/PDFFont.js +143 -0
  27. package/cjs/api/PDFFont.js.map +1 -0
  28. package/cjs/api/PDFImage.d.ts +96 -0
  29. package/cjs/api/PDFImage.d.ts.map +1 -0
  30. package/cjs/api/PDFImage.js +132 -0
  31. package/cjs/api/PDFImage.js.map +1 -0
  32. package/cjs/api/PDFJavaScript.d.ts +39 -0
  33. package/cjs/api/PDFJavaScript.d.ts.map +1 -0
  34. package/cjs/api/PDFJavaScript.js +73 -0
  35. package/cjs/api/PDFJavaScript.js.map +1 -0
  36. package/cjs/api/PDFPage.d.ts +898 -0
  37. package/cjs/api/PDFPage.d.ts.map +1 -0
  38. package/cjs/api/PDFPage.js +1442 -0
  39. package/cjs/api/PDFPage.js.map +1 -0
  40. package/cjs/api/PDFPageOptions.d.ts +155 -0
  41. package/cjs/api/PDFPageOptions.d.ts.map +1 -0
  42. package/cjs/api/PDFPageOptions.js +19 -0
  43. package/cjs/api/PDFPageOptions.js.map +1 -0
  44. package/cjs/api/StandardFonts.d.ts +17 -0
  45. package/cjs/api/StandardFonts.d.ts.map +1 -0
  46. package/cjs/api/StandardFonts.js +21 -0
  47. package/cjs/api/StandardFonts.js.map +1 -0
  48. package/cjs/api/colors.d.ts +31 -0
  49. package/cjs/api/colors.d.ts.map +1 -0
  50. package/cjs/api/colors.js +59 -0
  51. package/cjs/api/colors.js.map +1 -0
  52. package/cjs/api/errors.d.ts +43 -0
  53. package/cjs/api/errors.d.ts.map +1 -0
  54. package/cjs/api/errors.js +191 -0
  55. package/cjs/api/errors.js.map +1 -0
  56. package/cjs/api/form/PDFButton.d.ts +138 -0
  57. package/cjs/api/form/PDFButton.d.ts.map +1 -0
  58. package/cjs/api/form/PDFButton.js +220 -0
  59. package/cjs/api/form/PDFButton.js.map +1 -0
  60. package/cjs/api/form/PDFCheckBox.d.ts +143 -0
  61. package/cjs/api/form/PDFCheckBox.d.ts.map +1 -0
  62. package/cjs/api/form/PDFCheckBox.js +236 -0
  63. package/cjs/api/form/PDFCheckBox.js.map +1 -0
  64. package/cjs/api/form/PDFDropdown.d.ts +403 -0
  65. package/cjs/api/form/PDFDropdown.d.ts.map +1 -0
  66. package/cjs/api/form/PDFDropdown.js +580 -0
  67. package/cjs/api/form/PDFDropdown.js.map +1 -0
  68. package/cjs/api/form/PDFField.d.ts +204 -0
  69. package/cjs/api/form/PDFField.d.ts.map +1 -0
  70. package/cjs/api/form/PDFField.js +384 -0
  71. package/cjs/api/form/PDFField.js.map +1 -0
  72. package/cjs/api/form/PDFForm.d.ts +412 -0
  73. package/cjs/api/form/PDFForm.d.ts.map +1 -0
  74. package/cjs/api/form/PDFForm.js +726 -0
  75. package/cjs/api/form/PDFForm.js.map +1 -0
  76. package/cjs/api/form/PDFOptionList.d.ts +336 -0
  77. package/cjs/api/form/PDFOptionList.d.ts.map +1 -0
  78. package/cjs/api/form/PDFOptionList.js +499 -0
  79. package/cjs/api/form/PDFOptionList.js.map +1 -0
  80. package/cjs/api/form/PDFRadioGroup.d.ts +253 -0
  81. package/cjs/api/form/PDFRadioGroup.d.ts.map +1 -0
  82. package/cjs/api/form/PDFRadioGroup.js +415 -0
  83. package/cjs/api/form/PDFRadioGroup.js.map +1 -0
  84. package/cjs/api/form/PDFSignature.d.ts +30 -0
  85. package/cjs/api/form/PDFSignature.d.ts.map +1 -0
  86. package/cjs/api/form/PDFSignature.js +43 -0
  87. package/cjs/api/form/PDFSignature.js.map +1 -0
  88. package/cjs/api/form/PDFTextField.d.ts +538 -0
  89. package/cjs/api/form/PDFTextField.d.ts.map +1 -0
  90. package/cjs/api/form/PDFTextField.js +739 -0
  91. package/cjs/api/form/PDFTextField.js.map +1 -0
  92. package/cjs/api/form/appearances.d.ts +42 -0
  93. package/cjs/api/form/appearances.d.ts.map +1 -0
  94. package/cjs/api/form/appearances.js +421 -0
  95. package/cjs/api/form/appearances.js.map +1 -0
  96. package/cjs/api/form/index.d.ts +11 -0
  97. package/cjs/api/form/index.d.ts.map +1 -0
  98. package/cjs/api/form/index.js +23 -0
  99. package/cjs/api/form/index.js.map +1 -0
  100. package/cjs/api/image/alignment.d.ts +6 -0
  101. package/cjs/api/image/alignment.d.ts.map +1 -0
  102. package/cjs/api/image/alignment.js +10 -0
  103. package/cjs/api/image/alignment.js.map +1 -0
  104. package/cjs/api/image/index.d.ts +2 -0
  105. package/cjs/api/image/index.d.ts.map +1 -0
  106. package/cjs/api/image/index.js +5 -0
  107. package/cjs/api/image/index.js.map +1 -0
  108. package/cjs/api/index.d.ts +21 -0
  109. package/cjs/api/index.d.ts.map +1 -0
  110. package/cjs/api/index.js +29 -0
  111. package/cjs/api/index.js.map +1 -0
  112. package/cjs/api/objects.d.ts +5 -0
  113. package/cjs/api/objects.d.ts.map +1 -0
  114. package/cjs/api/objects.js +14 -0
  115. package/cjs/api/objects.js.map +1 -0
  116. package/cjs/api/operations.d.ts +212 -0
  117. package/cjs/api/operations.d.ts.map +1 -0
  118. package/cjs/api/operations.js +488 -0
  119. package/cjs/api/operations.js.map +1 -0
  120. package/cjs/api/operators.d.ts +86 -0
  121. package/cjs/api/operators.d.ts.map +1 -0
  122. package/cjs/api/operators.js +231 -0
  123. package/cjs/api/operators.js.map +1 -0
  124. package/cjs/api/rotations.d.ts +39 -0
  125. package/cjs/api/rotations.d.ts.map +1 -0
  126. package/cjs/api/rotations.js +71 -0
  127. package/cjs/api/rotations.js.map +1 -0
  128. package/cjs/api/sizes.d.ts +53 -0
  129. package/cjs/api/sizes.d.ts.map +1 -0
  130. package/cjs/api/sizes.js +56 -0
  131. package/cjs/api/sizes.js.map +1 -0
  132. package/cjs/api/svgPath.d.ts +3 -0
  133. package/cjs/api/svgPath.d.ts.map +1 -0
  134. package/cjs/api/svgPath.js +384 -0
  135. package/cjs/api/svgPath.js.map +1 -0
  136. package/cjs/api/text/alignment.d.ts +6 -0
  137. package/cjs/api/text/alignment.d.ts.map +1 -0
  138. package/cjs/api/text/alignment.js +10 -0
  139. package/cjs/api/text/alignment.js.map +1 -0
  140. package/cjs/api/text/index.d.ts +3 -0
  141. package/cjs/api/text/index.d.ts.map +1 -0
  142. package/cjs/api/text/index.js +6 -0
  143. package/cjs/api/text/index.js.map +1 -0
  144. package/cjs/api/text/layout.d.ts +55 -0
  145. package/cjs/api/text/layout.d.ts.map +1 -0
  146. package/cjs/api/text/layout.js +212 -0
  147. package/cjs/api/text/layout.js.map +1 -0
  148. package/cjs/core/PDFContext.d.ts +84 -0
  149. package/cjs/core/PDFContext.d.ts.map +1 -0
  150. package/cjs/core/PDFContext.js +201 -0
  151. package/cjs/core/PDFContext.js.map +1 -0
  152. package/cjs/core/PDFObjectCopier.d.ts +38 -0
  153. package/cjs/core/PDFObjectCopier.d.ts.map +1 -0
  154. package/cjs/core/PDFObjectCopier.js +119 -0
  155. package/cjs/core/PDFObjectCopier.js.map +1 -0
  156. package/cjs/core/acroform/PDFAcroButton.d.ts +22 -0
  157. package/cjs/core/acroform/PDFAcroButton.d.ts.map +1 -0
  158. package/cjs/core/acroform/PDFAcroButton.js +96 -0
  159. package/cjs/core/acroform/PDFAcroButton.js.map +1 -0
  160. package/cjs/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  161. package/cjs/core/acroform/PDFAcroCheckBox.d.ts.map +1 -0
  162. package/cjs/core/acroform/PDFAcroCheckBox.js +50 -0
  163. package/cjs/core/acroform/PDFAcroCheckBox.js.map +1 -0
  164. package/cjs/core/acroform/PDFAcroChoice.d.ts +21 -0
  165. package/cjs/core/acroform/PDFAcroChoice.d.ts.map +1 -0
  166. package/cjs/core/acroform/PDFAcroChoice.js +127 -0
  167. package/cjs/core/acroform/PDFAcroChoice.js.map +1 -0
  168. package/cjs/core/acroform/PDFAcroComboBox.d.ts +10 -0
  169. package/cjs/core/acroform/PDFAcroComboBox.d.ts.map +1 -0
  170. package/cjs/core/acroform/PDFAcroComboBox.js +26 -0
  171. package/cjs/core/acroform/PDFAcroComboBox.js.map +1 -0
  172. package/cjs/core/acroform/PDFAcroField.d.ts +37 -0
  173. package/cjs/core/acroform/PDFAcroField.d.ts.map +1 -0
  174. package/cjs/core/acroform/PDFAcroField.js +149 -0
  175. package/cjs/core/acroform/PDFAcroField.js.map +1 -0
  176. package/cjs/core/acroform/PDFAcroForm.d.ts +21 -0
  177. package/cjs/core/acroform/PDFAcroForm.d.ts.map +1 -0
  178. package/cjs/core/acroform/PDFAcroForm.js +78 -0
  179. package/cjs/core/acroform/PDFAcroForm.js.map +1 -0
  180. package/cjs/core/acroform/PDFAcroListBox.d.ts +10 -0
  181. package/cjs/core/acroform/PDFAcroListBox.d.ts.map +1 -0
  182. package/cjs/core/acroform/PDFAcroListBox.js +24 -0
  183. package/cjs/core/acroform/PDFAcroListBox.js.map +1 -0
  184. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  185. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -0
  186. package/cjs/core/acroform/PDFAcroNonTerminal.js +34 -0
  187. package/cjs/core/acroform/PDFAcroNonTerminal.js.map +1 -0
  188. package/cjs/core/acroform/PDFAcroPushButton.d.ts +10 -0
  189. package/cjs/core/acroform/PDFAcroPushButton.d.ts.map +1 -0
  190. package/cjs/core/acroform/PDFAcroPushButton.js +26 -0
  191. package/cjs/core/acroform/PDFAcroPushButton.js.map +1 -0
  192. package/cjs/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  193. package/cjs/core/acroform/PDFAcroRadioButton.d.ts.map +1 -0
  194. package/cjs/core/acroform/PDFAcroRadioButton.js +57 -0
  195. package/cjs/core/acroform/PDFAcroRadioButton.js.map +1 -0
  196. package/cjs/core/acroform/PDFAcroSignature.d.ts +8 -0
  197. package/cjs/core/acroform/PDFAcroSignature.d.ts.map +1 -0
  198. package/cjs/core/acroform/PDFAcroSignature.js +16 -0
  199. package/cjs/core/acroform/PDFAcroSignature.js.map +1 -0
  200. package/cjs/core/acroform/PDFAcroTerminal.d.ts +17 -0
  201. package/cjs/core/acroform/PDFAcroTerminal.d.ts.map +1 -0
  202. package/cjs/core/acroform/PDFAcroTerminal.js +70 -0
  203. package/cjs/core/acroform/PDFAcroTerminal.js.map +1 -0
  204. package/cjs/core/acroform/PDFAcroText.d.ts +23 -0
  205. package/cjs/core/acroform/PDFAcroText.d.ts.map +1 -0
  206. package/cjs/core/acroform/PDFAcroText.js +73 -0
  207. package/cjs/core/acroform/PDFAcroText.js.map +1 -0
  208. package/cjs/core/acroform/flags.d.ts +142 -0
  209. package/cjs/core/acroform/flags.d.ts.map +1 -0
  210. package/cjs/core/acroform/flags.js +150 -0
  211. package/cjs/core/acroform/flags.js.map +1 -0
  212. package/cjs/core/acroform/index.d.ts +16 -0
  213. package/cjs/core/acroform/index.d.ts.map +1 -0
  214. package/cjs/core/acroform/index.js +32 -0
  215. package/cjs/core/acroform/index.js.map +1 -0
  216. package/cjs/core/acroform/utils.d.ts +7 -0
  217. package/cjs/core/acroform/utils.d.ts.map +1 -0
  218. package/cjs/core/acroform/utils.js +127 -0
  219. package/cjs/core/acroform/utils.js.map +1 -0
  220. package/cjs/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  221. package/cjs/core/annotation/AppearanceCharacteristics.d.ts.map +1 -0
  222. package/cjs/core/annotation/AppearanceCharacteristics.js +123 -0
  223. package/cjs/core/annotation/AppearanceCharacteristics.js.map +1 -0
  224. package/cjs/core/annotation/BorderStyle.d.ts +12 -0
  225. package/cjs/core/annotation/BorderStyle.d.ts.map +1 -0
  226. package/cjs/core/annotation/BorderStyle.js +29 -0
  227. package/cjs/core/annotation/BorderStyle.js.map +1 -0
  228. package/cjs/core/annotation/PDFAnnotation.d.ts +52 -0
  229. package/cjs/core/annotation/PDFAnnotation.d.ts.map +1 -0
  230. package/cjs/core/annotation/PDFAnnotation.js +123 -0
  231. package/cjs/core/annotation/PDFAnnotation.js.map +1 -0
  232. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  233. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -0
  234. package/cjs/core/annotation/PDFWidgetAnnotation.js +110 -0
  235. package/cjs/core/annotation/PDFWidgetAnnotation.js.map +1 -0
  236. package/cjs/core/annotation/flags.d.ts +80 -0
  237. package/cjs/core/annotation/flags.d.ts.map +1 -0
  238. package/cjs/core/annotation/flags.js +85 -0
  239. package/cjs/core/annotation/flags.js.map +1 -0
  240. package/cjs/core/annotation/index.d.ts +5 -0
  241. package/cjs/core/annotation/index.d.ts.map +1 -0
  242. package/cjs/core/annotation/index.js +11 -0
  243. package/cjs/core/annotation/index.js.map +1 -0
  244. package/cjs/core/document/PDFCrossRefSection.d.ts +28 -0
  245. package/cjs/core/document/PDFCrossRefSection.d.ts.map +1 -0
  246. package/cjs/core/document/PDFCrossRefSection.js +124 -0
  247. package/cjs/core/document/PDFCrossRefSection.js.map +1 -0
  248. package/cjs/core/document/PDFHeader.d.ts +11 -0
  249. package/cjs/core/document/PDFHeader.d.ts.map +1 -0
  250. package/cjs/core/document/PDFHeader.js +42 -0
  251. package/cjs/core/document/PDFHeader.js.map +1 -0
  252. package/cjs/core/document/PDFTrailer.d.ts +10 -0
  253. package/cjs/core/document/PDFTrailer.d.ts.map +1 -0
  254. package/cjs/core/document/PDFTrailer.js +43 -0
  255. package/cjs/core/document/PDFTrailer.js.map +1 -0
  256. package/cjs/core/document/PDFTrailerDict.d.ts +11 -0
  257. package/cjs/core/document/PDFTrailerDict.d.ts.map +1 -0
  258. package/cjs/core/document/PDFTrailerDict.js +32 -0
  259. package/cjs/core/document/PDFTrailerDict.js.map +1 -0
  260. package/cjs/core/embedders/CMap.d.ts +4 -0
  261. package/cjs/core/embedders/CMap.d.ts.map +1 -0
  262. package/cjs/core/embedders/CMap.js +43 -0
  263. package/cjs/core/embedders/CMap.js.map +1 -0
  264. package/cjs/core/embedders/CustomFontEmbedder.d.ts +45 -0
  265. package/cjs/core/embedders/CustomFontEmbedder.d.ts.map +1 -0
  266. package/cjs/core/embedders/CustomFontEmbedder.js +240 -0
  267. package/cjs/core/embedders/CustomFontEmbedder.js.map +1 -0
  268. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  269. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -0
  270. package/cjs/core/embedders/CustomFontSubsetEmbedder.js +68 -0
  271. package/cjs/core/embedders/CustomFontSubsetEmbedder.js.map +1 -0
  272. package/cjs/core/embedders/FileEmbedder.d.ts +34 -0
  273. package/cjs/core/embedders/FileEmbedder.d.ts.map +1 -0
  274. package/cjs/core/embedders/FileEmbedder.js +75 -0
  275. package/cjs/core/embedders/FileEmbedder.js.map +1 -0
  276. package/cjs/core/embedders/FontFlags.d.ts +14 -0
  277. package/cjs/core/embedders/FontFlags.d.ts.map +1 -0
  278. package/cjs/core/embedders/FontFlags.js +40 -0
  279. package/cjs/core/embedders/FontFlags.js.map +1 -0
  280. package/cjs/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  281. package/cjs/core/embedders/JavaScriptEmbedder.d.ts.map +1 -0
  282. package/cjs/core/embedders/JavaScriptEmbedder.js +36 -0
  283. package/cjs/core/embedders/JavaScriptEmbedder.js.map +1 -0
  284. package/cjs/core/embedders/JpegEmbedder.d.ts +24 -0
  285. package/cjs/core/embedders/JpegEmbedder.d.ts.map +1 -0
  286. package/cjs/core/embedders/JpegEmbedder.js +134 -0
  287. package/cjs/core/embedders/JpegEmbedder.js.map +1 -0
  288. package/cjs/core/embedders/PDFPageEmbedder.d.ts +38 -0
  289. package/cjs/core/embedders/PDFPageEmbedder.d.ts.map +1 -0
  290. package/cjs/core/embedders/PDFPageEmbedder.js +91 -0
  291. package/cjs/core/embedders/PDFPageEmbedder.js.map +1 -0
  292. package/cjs/core/embedders/PngEmbedder.d.ts +20 -0
  293. package/cjs/core/embedders/PngEmbedder.d.ts.map +1 -0
  294. package/cjs/core/embedders/PngEmbedder.js +69 -0
  295. package/cjs/core/embedders/PngEmbedder.js.map +1 -0
  296. package/cjs/core/embedders/StandardFontEmbedder.d.ts +37 -0
  297. package/cjs/core/embedders/StandardFontEmbedder.d.ts.map +1 -0
  298. package/cjs/core/embedders/StandardFontEmbedder.js +98 -0
  299. package/cjs/core/embedders/StandardFontEmbedder.js.map +1 -0
  300. package/cjs/core/errors.d.ts +92 -0
  301. package/cjs/core/errors.d.ts.map +1 -0
  302. package/cjs/core/errors.js +323 -0
  303. package/cjs/core/errors.js.map +1 -0
  304. package/cjs/core/index.d.ts +48 -0
  305. package/cjs/core/index.d.ts.map +1 -0
  306. package/cjs/core/index.js +100 -0
  307. package/cjs/core/index.js.map +1 -0
  308. package/cjs/core/interactive/ViewerPreferences.d.ts +348 -0
  309. package/cjs/core/interactive/ViewerPreferences.d.ts.map +1 -0
  310. package/cjs/core/interactive/ViewerPreferences.js +511 -0
  311. package/cjs/core/interactive/ViewerPreferences.js.map +1 -0
  312. package/cjs/core/objects/PDFArray.d.ts +64 -0
  313. package/cjs/core/objects/PDFArray.d.ts.map +1 -0
  314. package/cjs/core/objects/PDFArray.js +117 -0
  315. package/cjs/core/objects/PDFArray.js.map +1 -0
  316. package/cjs/core/objects/PDFBool.d.ts +14 -0
  317. package/cjs/core/objects/PDFBool.d.ts.map +1 -0
  318. package/cjs/core/objects/PDFBool.js +52 -0
  319. package/cjs/core/objects/PDFBool.js.map +1 -0
  320. package/cjs/core/objects/PDFDict.d.ts +62 -0
  321. package/cjs/core/objects/PDFDict.d.ts.map +1 -0
  322. package/cjs/core/objects/PDFDict.js +138 -0
  323. package/cjs/core/objects/PDFDict.js.map +1 -0
  324. package/cjs/core/objects/PDFHexString.d.ts +17 -0
  325. package/cjs/core/objects/PDFHexString.d.ts.map +1 -0
  326. package/cjs/core/objects/PDFHexString.js +74 -0
  327. package/cjs/core/objects/PDFHexString.js.map +1 -0
  328. package/cjs/core/objects/PDFInvalidObject.d.ts +12 -0
  329. package/cjs/core/objects/PDFInvalidObject.d.ts.map +1 -0
  330. package/cjs/core/objects/PDFInvalidObject.js +32 -0
  331. package/cjs/core/objects/PDFInvalidObject.js.map +1 -0
  332. package/cjs/core/objects/PDFName.d.ts +42 -0
  333. package/cjs/core/objects/PDFName.d.ts.map +1 -0
  334. package/cjs/core/objects/PDFName.js +138 -0
  335. package/cjs/core/objects/PDFName.js.map +1 -0
  336. package/cjs/core/objects/PDFNull.d.ts +11 -0
  337. package/cjs/core/objects/PDFNull.d.ts.map +1 -0
  338. package/cjs/core/objects/PDFNull.js +33 -0
  339. package/cjs/core/objects/PDFNull.js.map +1 -0
  340. package/cjs/core/objects/PDFNumber.d.ts +16 -0
  341. package/cjs/core/objects/PDFNumber.d.ts.map +1 -0
  342. package/cjs/core/objects/PDFNumber.js +38 -0
  343. package/cjs/core/objects/PDFNumber.js.map +1 -0
  344. package/cjs/core/objects/PDFObject.d.ts +9 -0
  345. package/cjs/core/objects/PDFObject.d.ts.map +1 -0
  346. package/cjs/core/objects/PDFObject.js +22 -0
  347. package/cjs/core/objects/PDFObject.js.map +1 -0
  348. package/cjs/core/objects/PDFRawStream.d.ts +15 -0
  349. package/cjs/core/objects/PDFRawStream.d.ts.map +1 -0
  350. package/cjs/core/objects/PDFRawStream.js +34 -0
  351. package/cjs/core/objects/PDFRawStream.js.map +1 -0
  352. package/cjs/core/objects/PDFRef.d.ts +14 -0
  353. package/cjs/core/objects/PDFRef.d.ts.map +1 -0
  354. package/cjs/core/objects/PDFRef.js +47 -0
  355. package/cjs/core/objects/PDFRef.js.map +1 -0
  356. package/cjs/core/objects/PDFStream.d.ts +17 -0
  357. package/cjs/core/objects/PDFStream.d.ts.map +1 -0
  358. package/cjs/core/objects/PDFStream.js +75 -0
  359. package/cjs/core/objects/PDFStream.js.map +1 -0
  360. package/cjs/core/objects/PDFString.d.ts +17 -0
  361. package/cjs/core/objects/PDFString.d.ts.map +1 -0
  362. package/cjs/core/objects/PDFString.js +116 -0
  363. package/cjs/core/objects/PDFString.js.map +1 -0
  364. package/cjs/core/operators/PDFOperator.d.ts +20 -0
  365. package/cjs/core/operators/PDFOperator.d.ts.map +1 -0
  366. package/cjs/core/operators/PDFOperator.js +58 -0
  367. package/cjs/core/operators/PDFOperator.js.map +1 -0
  368. package/cjs/core/operators/PDFOperatorNames.d.ts +77 -0
  369. package/cjs/core/operators/PDFOperatorNames.d.ts.map +1 -0
  370. package/cjs/core/operators/PDFOperatorNames.js +88 -0
  371. package/cjs/core/operators/PDFOperatorNames.js.map +1 -0
  372. package/cjs/core/parser/BaseParser.d.ts +15 -0
  373. package/cjs/core/parser/BaseParser.d.ts.map +1 -0
  374. package/cjs/core/parser/BaseParser.js +110 -0
  375. package/cjs/core/parser/BaseParser.js.map +1 -0
  376. package/cjs/core/parser/ByteStream.d.ts +27 -0
  377. package/cjs/core/parser/ByteStream.d.ts.map +1 -0
  378. package/cjs/core/parser/ByteStream.js +64 -0
  379. package/cjs/core/parser/ByteStream.js.map +1 -0
  380. package/cjs/core/parser/PDFObjectParser.d.ts +30 -0
  381. package/cjs/core/parser/PDFObjectParser.d.ts.map +1 -0
  382. package/cjs/core/parser/PDFObjectParser.js +233 -0
  383. package/cjs/core/parser/PDFObjectParser.js.map +1 -0
  384. package/cjs/core/parser/PDFObjectStreamParser.d.ts +14 -0
  385. package/cjs/core/parser/PDFObjectStreamParser.d.ts.map +1 -0
  386. package/cjs/core/parser/PDFObjectStreamParser.js +70 -0
  387. package/cjs/core/parser/PDFObjectStreamParser.js.map +1 -0
  388. package/cjs/core/parser/PDFParser.d.ts +46 -0
  389. package/cjs/core/parser/PDFParser.d.ts.map +1 -0
  390. package/cjs/core/parser/PDFParser.js +356 -0
  391. package/cjs/core/parser/PDFParser.js.map +1 -0
  392. package/cjs/core/parser/PDFXRefStreamParser.d.ts +22 -0
  393. package/cjs/core/parser/PDFXRefStreamParser.d.ts.map +1 -0
  394. package/cjs/core/parser/PDFXRefStreamParser.js +102 -0
  395. package/cjs/core/parser/PDFXRefStreamParser.js.map +1 -0
  396. package/cjs/core/streams/Ascii85Stream.d.ts +10 -0
  397. package/cjs/core/streams/Ascii85Stream.d.ts.map +1 -0
  398. package/cjs/core/streams/Ascii85Stream.js +87 -0
  399. package/cjs/core/streams/Ascii85Stream.js.map +1 -0
  400. package/cjs/core/streams/AsciiHexStream.d.ts +10 -0
  401. package/cjs/core/streams/AsciiHexStream.d.ts.map +1 -0
  402. package/cjs/core/streams/AsciiHexStream.js +75 -0
  403. package/cjs/core/streams/AsciiHexStream.js.map +1 -0
  404. package/cjs/core/streams/DecodeStream.d.ts +28 -0
  405. package/cjs/core/streams/DecodeStream.d.ts.map +1 -0
  406. package/cjs/core/streams/DecodeStream.js +160 -0
  407. package/cjs/core/streams/DecodeStream.js.map +1 -0
  408. package/cjs/core/streams/FlateStream.d.ts +14 -0
  409. package/cjs/core/streams/FlateStream.d.ts.map +1 -0
  410. package/cjs/core/streams/FlateStream.js +371 -0
  411. package/cjs/core/streams/FlateStream.js.map +1 -0
  412. package/cjs/core/streams/LZWStream.d.ts +13 -0
  413. package/cjs/core/streams/LZWStream.d.ts.map +1 -0
  414. package/cjs/core/streams/LZWStream.js +137 -0
  415. package/cjs/core/streams/LZWStream.js.map +1 -0
  416. package/cjs/core/streams/RunLengthStream.d.ts +9 -0
  417. package/cjs/core/streams/RunLengthStream.d.ts.map +1 -0
  418. package/cjs/core/streams/RunLengthStream.js +55 -0
  419. package/cjs/core/streams/RunLengthStream.js.map +1 -0
  420. package/cjs/core/streams/Stream.d.ts +35 -0
  421. package/cjs/core/streams/Stream.d.ts.map +1 -0
  422. package/cjs/core/streams/Stream.js +106 -0
  423. package/cjs/core/streams/Stream.js.map +1 -0
  424. package/cjs/core/streams/decode.d.ts +4 -0
  425. package/cjs/core/streams/decode.d.ts.map +1 -0
  426. package/cjs/core/streams/decode.js +59 -0
  427. package/cjs/core/streams/decode.js.map +1 -0
  428. package/cjs/core/structures/PDFCatalog.d.ts +28 -0
  429. package/cjs/core/structures/PDFCatalog.d.ts.map +1 -0
  430. package/cjs/core/structures/PDFCatalog.js +79 -0
  431. package/cjs/core/structures/PDFCatalog.js.map +1 -0
  432. package/cjs/core/structures/PDFContentStream.d.ts +16 -0
  433. package/cjs/core/structures/PDFContentStream.d.ts.map +1 -0
  434. package/cjs/core/structures/PDFContentStream.js +60 -0
  435. package/cjs/core/structures/PDFContentStream.js.map +1 -0
  436. package/cjs/core/structures/PDFCrossRefStream.d.ts +54 -0
  437. package/cjs/core/structures/PDFCrossRefStream.d.ts.map +1 -0
  438. package/cjs/core/structures/PDFCrossRefStream.js +187 -0
  439. package/cjs/core/structures/PDFCrossRefStream.js.map +1 -0
  440. package/cjs/core/structures/PDFFlateStream.d.ts +14 -0
  441. package/cjs/core/structures/PDFFlateStream.d.ts.map +1 -0
  442. package/cjs/core/structures/PDFFlateStream.js +35 -0
  443. package/cjs/core/structures/PDFFlateStream.js.map +1 -0
  444. package/cjs/core/structures/PDFObjectStream.d.ts +21 -0
  445. package/cjs/core/structures/PDFObjectStream.d.ts.map +1 -0
  446. package/cjs/core/structures/PDFObjectStream.js +77 -0
  447. package/cjs/core/structures/PDFObjectStream.js.map +1 -0
  448. package/cjs/core/structures/PDFPageLeaf.d.ts +55 -0
  449. package/cjs/core/structures/PDFPageLeaf.d.ts.map +1 -0
  450. package/cjs/core/structures/PDFPageLeaf.js +206 -0
  451. package/cjs/core/structures/PDFPageLeaf.js.map +1 -0
  452. package/cjs/core/structures/PDFPageTree.d.ts +42 -0
  453. package/cjs/core/structures/PDFPageTree.d.ts.map +1 -0
  454. package/cjs/core/structures/PDFPageTree.js +177 -0
  455. package/cjs/core/structures/PDFPageTree.js.map +1 -0
  456. package/cjs/core/syntax/CharCodes.d.ts +62 -0
  457. package/cjs/core/syntax/CharCodes.d.ts.map +1 -0
  458. package/cjs/core/syntax/CharCodes.js +65 -0
  459. package/cjs/core/syntax/CharCodes.js.map +1 -0
  460. package/cjs/core/syntax/Delimiters.d.ts +2 -0
  461. package/cjs/core/syntax/Delimiters.d.ts.map +1 -0
  462. package/cjs/core/syntax/Delimiters.js +17 -0
  463. package/cjs/core/syntax/Delimiters.js.map +1 -0
  464. package/cjs/core/syntax/Irregular.d.ts +2 -0
  465. package/cjs/core/syntax/Irregular.d.ts.map +1 -0
  466. package/cjs/core/syntax/Irregular.js +13 -0
  467. package/cjs/core/syntax/Irregular.js.map +1 -0
  468. package/cjs/core/syntax/Keywords.d.ts +23 -0
  469. package/cjs/core/syntax/Keywords.d.ts.map +1 -0
  470. package/cjs/core/syntax/Keywords.js +84 -0
  471. package/cjs/core/syntax/Keywords.js.map +1 -0
  472. package/cjs/core/syntax/Numeric.d.ts +4 -0
  473. package/cjs/core/syntax/Numeric.d.ts.map +1 -0
  474. package/cjs/core/syntax/Numeric.js +25 -0
  475. package/cjs/core/syntax/Numeric.js.map +1 -0
  476. package/cjs/core/syntax/Whitespace.d.ts +2 -0
  477. package/cjs/core/syntax/Whitespace.d.ts.map +1 -0
  478. package/cjs/core/syntax/Whitespace.js +13 -0
  479. package/cjs/core/syntax/Whitespace.js.map +1 -0
  480. package/cjs/core/writers/PDFStreamWriter.d.ts +20 -0
  481. package/cjs/core/writers/PDFStreamWriter.d.ts.map +1 -0
  482. package/cjs/core/writers/PDFStreamWriter.js +113 -0
  483. package/cjs/core/writers/PDFStreamWriter.js.map +1 -0
  484. package/cjs/core/writers/PDFWriter.d.ts +30 -0
  485. package/cjs/core/writers/PDFWriter.d.ts.map +1 -0
  486. package/cjs/core/writers/PDFWriter.js +144 -0
  487. package/cjs/core/writers/PDFWriter.js.map +1 -0
  488. package/cjs/index.d.ts +5 -0
  489. package/cjs/index.d.ts.map +1 -0
  490. package/cjs/index.js +8 -0
  491. package/cjs/index.js.map +1 -0
  492. package/cjs/types/fontkit.d.ts +582 -0
  493. package/cjs/types/fontkit.d.ts.map +1 -0
  494. package/cjs/types/fontkit.js +3 -0
  495. package/cjs/types/fontkit.js.map +1 -0
  496. package/cjs/types/index.d.ts +2 -0
  497. package/cjs/types/index.d.ts.map +1 -0
  498. package/cjs/types/index.js +3 -0
  499. package/cjs/types/index.js.map +1 -0
  500. package/cjs/types/matrix.d.ts +22 -0
  501. package/cjs/types/matrix.d.ts.map +1 -0
  502. package/cjs/types/matrix.js +5 -0
  503. package/cjs/types/matrix.js.map +1 -0
  504. package/cjs/utils/Cache.d.ts +11 -0
  505. package/cjs/utils/Cache.d.ts.map +1 -0
  506. package/cjs/utils/Cache.js +23 -0
  507. package/cjs/utils/Cache.js.map +1 -0
  508. package/cjs/utils/arrays.d.ts +16 -0
  509. package/cjs/utils/arrays.d.ts.map +1 -0
  510. package/cjs/utils/arrays.js +132 -0
  511. package/cjs/utils/arrays.js.map +1 -0
  512. package/cjs/utils/async.d.ts +6 -0
  513. package/cjs/utils/async.d.ts.map +1 -0
  514. package/cjs/utils/async.js +13 -0
  515. package/cjs/utils/async.js.map +1 -0
  516. package/cjs/utils/base64.d.ts +11 -0
  517. package/cjs/utils/base64.d.ts.map +1 -0
  518. package/cjs/utils/base64.js +87 -0
  519. package/cjs/utils/base64.js.map +1 -0
  520. package/cjs/utils/errors.d.ts +2 -0
  521. package/cjs/utils/errors.d.ts.map +1 -0
  522. package/cjs/utils/errors.js +7 -0
  523. package/cjs/utils/errors.js.map +1 -0
  524. package/cjs/utils/index.d.ts +12 -0
  525. package/cjs/utils/index.d.ts.map +1 -0
  526. package/cjs/utils/index.js +16 -0
  527. package/cjs/utils/index.js.map +1 -0
  528. package/cjs/utils/numbers.d.ts +24 -0
  529. package/cjs/utils/numbers.d.ts.map +1 -0
  530. package/cjs/utils/numbers.js +57 -0
  531. package/cjs/utils/numbers.js.map +1 -0
  532. package/cjs/utils/objects.d.ts +16 -0
  533. package/cjs/utils/objects.d.ts.map +1 -0
  534. package/cjs/utils/objects.js +11 -0
  535. package/cjs/utils/objects.js.map +1 -0
  536. package/cjs/utils/pdfDocEncoding.d.ts +8 -0
  537. package/cjs/utils/pdfDocEncoding.d.ts.map +1 -0
  538. package/cjs/utils/pdfDocEncoding.js +69 -0
  539. package/cjs/utils/pdfDocEncoding.js.map +1 -0
  540. package/cjs/utils/png.d.ts +18 -0
  541. package/cjs/utils/png.d.ts.map +1 -0
  542. package/cjs/utils/png.js +63 -0
  543. package/cjs/utils/png.js.map +1 -0
  544. package/cjs/utils/rng.d.ts +14 -0
  545. package/cjs/utils/rng.d.ts.map +1 -0
  546. package/cjs/utils/rng.js +23 -0
  547. package/cjs/utils/rng.js.map +1 -0
  548. package/cjs/utils/strings.d.ts +25 -0
  549. package/cjs/utils/strings.d.ts.map +1 -0
  550. package/cjs/utils/strings.js +219 -0
  551. package/cjs/utils/strings.js.map +1 -0
  552. package/cjs/utils/unicode.d.ts +187 -0
  553. package/cjs/utils/unicode.d.ts.map +1 -0
  554. package/cjs/utils/unicode.js +370 -0
  555. package/cjs/utils/unicode.js.map +1 -0
  556. package/cjs/utils/validators.d.ts +27 -0
  557. package/cjs/utils/validators.d.ts.map +1 -0
  558. package/cjs/utils/validators.js +183 -0
  559. package/cjs/utils/validators.js.map +1 -0
  560. package/dist/pdf-lib.esm.js +26039 -0
  561. package/dist/pdf-lib.esm.js.map +1 -0
  562. package/dist/pdf-lib.esm.min.js +16 -0
  563. package/dist/pdf-lib.esm.min.js.map +1 -0
  564. package/dist/pdf-lib.js +26339 -0
  565. package/dist/pdf-lib.js.map +1 -0
  566. package/dist/pdf-lib.min.js +16 -0
  567. package/dist/pdf-lib.min.js.map +1 -0
  568. package/es/api/Embeddable.d.ts +8 -0
  569. package/es/api/Embeddable.d.ts.map +1 -0
  570. package/es/api/Embeddable.js +1 -0
  571. package/es/api/Embeddable.js.map +1 -0
  572. package/es/api/PDFDocument.d.ts +779 -0
  573. package/es/api/PDFDocument.d.ts.map +1 -0
  574. package/es/api/PDFDocument.js +1367 -0
  575. package/es/api/PDFDocument.js.map +1 -0
  576. package/es/api/PDFDocumentOptions.d.ts +38 -0
  577. package/es/api/PDFDocumentOptions.d.ts.map +1 -0
  578. package/es/api/PDFDocumentOptions.js +8 -0
  579. package/es/api/PDFDocumentOptions.js.map +1 -0
  580. package/es/api/PDFEmbeddedFile.d.ts +39 -0
  581. package/es/api/PDFEmbeddedFile.d.ts.map +1 -0
  582. package/es/api/PDFEmbeddedFile.js +82 -0
  583. package/es/api/PDFEmbeddedFile.js.map +1 -0
  584. package/es/api/PDFEmbeddedPage.d.ts +74 -0
  585. package/es/api/PDFEmbeddedPage.d.ts.map +1 -0
  586. package/es/api/PDFEmbeddedPage.js +93 -0
  587. package/es/api/PDFEmbeddedPage.js.map +1 -0
  588. package/es/api/PDFFont.d.ts +95 -0
  589. package/es/api/PDFFont.d.ts.map +1 -0
  590. package/es/api/PDFFont.js +141 -0
  591. package/es/api/PDFFont.js.map +1 -0
  592. package/es/api/PDFImage.d.ts +96 -0
  593. package/es/api/PDFImage.d.ts.map +1 -0
  594. package/es/api/PDFImage.js +130 -0
  595. package/es/api/PDFImage.js.map +1 -0
  596. package/es/api/PDFJavaScript.d.ts +39 -0
  597. package/es/api/PDFJavaScript.d.ts.map +1 -0
  598. package/es/api/PDFJavaScript.js +71 -0
  599. package/es/api/PDFJavaScript.js.map +1 -0
  600. package/es/api/PDFPage.d.ts +898 -0
  601. package/es/api/PDFPage.d.ts.map +1 -0
  602. package/es/api/PDFPage.js +1440 -0
  603. package/es/api/PDFPage.js.map +1 -0
  604. package/es/api/PDFPageOptions.d.ts +155 -0
  605. package/es/api/PDFPageOptions.d.ts.map +1 -0
  606. package/es/api/PDFPageOptions.js +16 -0
  607. package/es/api/PDFPageOptions.js.map +1 -0
  608. package/es/api/StandardFonts.d.ts +17 -0
  609. package/es/api/StandardFonts.d.ts.map +1 -0
  610. package/es/api/StandardFonts.js +18 -0
  611. package/es/api/StandardFonts.js.map +1 -0
  612. package/es/api/colors.d.ts +31 -0
  613. package/es/api/colors.d.ts.map +1 -0
  614. package/es/api/colors.js +56 -0
  615. package/es/api/colors.js.map +1 -0
  616. package/es/api/errors.d.ts +43 -0
  617. package/es/api/errors.d.ts.map +1 -0
  618. package/es/api/errors.js +188 -0
  619. package/es/api/errors.js.map +1 -0
  620. package/es/api/form/PDFButton.d.ts +138 -0
  621. package/es/api/form/PDFButton.d.ts.map +1 -0
  622. package/es/api/form/PDFButton.js +218 -0
  623. package/es/api/form/PDFButton.js.map +1 -0
  624. package/es/api/form/PDFCheckBox.d.ts +143 -0
  625. package/es/api/form/PDFCheckBox.d.ts.map +1 -0
  626. package/es/api/form/PDFCheckBox.js +234 -0
  627. package/es/api/form/PDFCheckBox.js.map +1 -0
  628. package/es/api/form/PDFDropdown.d.ts +403 -0
  629. package/es/api/form/PDFDropdown.d.ts.map +1 -0
  630. package/es/api/form/PDFDropdown.js +578 -0
  631. package/es/api/form/PDFDropdown.js.map +1 -0
  632. package/es/api/form/PDFField.d.ts +204 -0
  633. package/es/api/form/PDFField.d.ts.map +1 -0
  634. package/es/api/form/PDFField.js +381 -0
  635. package/es/api/form/PDFField.js.map +1 -0
  636. package/es/api/form/PDFForm.d.ts +412 -0
  637. package/es/api/form/PDFForm.d.ts.map +1 -0
  638. package/es/api/form/PDFForm.js +724 -0
  639. package/es/api/form/PDFForm.js.map +1 -0
  640. package/es/api/form/PDFOptionList.d.ts +336 -0
  641. package/es/api/form/PDFOptionList.d.ts.map +1 -0
  642. package/es/api/form/PDFOptionList.js +497 -0
  643. package/es/api/form/PDFOptionList.js.map +1 -0
  644. package/es/api/form/PDFRadioGroup.d.ts +253 -0
  645. package/es/api/form/PDFRadioGroup.d.ts.map +1 -0
  646. package/es/api/form/PDFRadioGroup.js +413 -0
  647. package/es/api/form/PDFRadioGroup.js.map +1 -0
  648. package/es/api/form/PDFSignature.d.ts +30 -0
  649. package/es/api/form/PDFSignature.d.ts.map +1 -0
  650. package/es/api/form/PDFSignature.js +41 -0
  651. package/es/api/form/PDFSignature.js.map +1 -0
  652. package/es/api/form/PDFTextField.d.ts +538 -0
  653. package/es/api/form/PDFTextField.d.ts.map +1 -0
  654. package/es/api/form/PDFTextField.js +737 -0
  655. package/es/api/form/PDFTextField.js.map +1 -0
  656. package/es/api/form/appearances.d.ts +42 -0
  657. package/es/api/form/appearances.d.ts.map +1 -0
  658. package/es/api/form/appearances.js +418 -0
  659. package/es/api/form/appearances.js.map +1 -0
  660. package/es/api/form/index.d.ts +11 -0
  661. package/es/api/form/index.d.ts.map +1 -0
  662. package/es/api/form/index.js +11 -0
  663. package/es/api/form/index.js.map +1 -0
  664. package/es/api/image/alignment.d.ts +6 -0
  665. package/es/api/image/alignment.d.ts.map +1 -0
  666. package/es/api/image/alignment.js +7 -0
  667. package/es/api/image/alignment.js.map +1 -0
  668. package/es/api/image/index.d.ts +2 -0
  669. package/es/api/image/index.d.ts.map +1 -0
  670. package/es/api/image/index.js +2 -0
  671. package/es/api/image/index.js.map +1 -0
  672. package/es/api/index.d.ts +21 -0
  673. package/es/api/index.d.ts.map +1 -0
  674. package/es/api/index.js +20 -0
  675. package/es/api/index.js.map +1 -0
  676. package/es/api/objects.d.ts +5 -0
  677. package/es/api/objects.d.ts.map +1 -0
  678. package/es/api/objects.js +11 -0
  679. package/es/api/objects.js.map +1 -0
  680. package/es/api/operations.d.ts +212 -0
  681. package/es/api/operations.d.ts.map +1 -0
  682. package/es/api/operations.js +485 -0
  683. package/es/api/operations.js.map +1 -0
  684. package/es/api/operators.d.ts +86 -0
  685. package/es/api/operators.d.ts.map +1 -0
  686. package/es/api/operators.js +228 -0
  687. package/es/api/operators.js.map +1 -0
  688. package/es/api/rotations.d.ts +39 -0
  689. package/es/api/rotations.d.ts.map +1 -0
  690. package/es/api/rotations.js +68 -0
  691. package/es/api/rotations.js.map +1 -0
  692. package/es/api/sizes.d.ts +53 -0
  693. package/es/api/sizes.d.ts.map +1 -0
  694. package/es/api/sizes.js +53 -0
  695. package/es/api/sizes.js.map +1 -0
  696. package/es/api/svgPath.d.ts +3 -0
  697. package/es/api/svgPath.d.ts.map +1 -0
  698. package/es/api/svgPath.js +381 -0
  699. package/es/api/svgPath.js.map +1 -0
  700. package/es/api/text/alignment.d.ts +6 -0
  701. package/es/api/text/alignment.d.ts.map +1 -0
  702. package/es/api/text/alignment.js +7 -0
  703. package/es/api/text/alignment.js.map +1 -0
  704. package/es/api/text/index.d.ts +3 -0
  705. package/es/api/text/index.d.ts.map +1 -0
  706. package/es/api/text/index.js +3 -0
  707. package/es/api/text/index.js.map +1 -0
  708. package/es/api/text/layout.d.ts +55 -0
  709. package/es/api/text/layout.d.ts.map +1 -0
  710. package/es/api/text/layout.js +209 -0
  711. package/es/api/text/layout.js.map +1 -0
  712. package/es/core/PDFContext.d.ts +84 -0
  713. package/es/core/PDFContext.d.ts.map +1 -0
  714. package/es/core/PDFContext.js +199 -0
  715. package/es/core/PDFContext.js.map +1 -0
  716. package/es/core/PDFObjectCopier.d.ts +38 -0
  717. package/es/core/PDFObjectCopier.d.ts.map +1 -0
  718. package/es/core/PDFObjectCopier.js +116 -0
  719. package/es/core/PDFObjectCopier.js.map +1 -0
  720. package/es/core/acroform/PDFAcroButton.d.ts +22 -0
  721. package/es/core/acroform/PDFAcroButton.d.ts.map +1 -0
  722. package/es/core/acroform/PDFAcroButton.js +94 -0
  723. package/es/core/acroform/PDFAcroButton.js.map +1 -0
  724. package/es/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  725. package/es/core/acroform/PDFAcroCheckBox.d.ts.map +1 -0
  726. package/es/core/acroform/PDFAcroCheckBox.js +48 -0
  727. package/es/core/acroform/PDFAcroCheckBox.js.map +1 -0
  728. package/es/core/acroform/PDFAcroChoice.d.ts +21 -0
  729. package/es/core/acroform/PDFAcroChoice.d.ts.map +1 -0
  730. package/es/core/acroform/PDFAcroChoice.js +125 -0
  731. package/es/core/acroform/PDFAcroChoice.js.map +1 -0
  732. package/es/core/acroform/PDFAcroComboBox.d.ts +10 -0
  733. package/es/core/acroform/PDFAcroComboBox.d.ts.map +1 -0
  734. package/es/core/acroform/PDFAcroComboBox.js +24 -0
  735. package/es/core/acroform/PDFAcroComboBox.js.map +1 -0
  736. package/es/core/acroform/PDFAcroField.d.ts +37 -0
  737. package/es/core/acroform/PDFAcroField.d.ts.map +1 -0
  738. package/es/core/acroform/PDFAcroField.js +146 -0
  739. package/es/core/acroform/PDFAcroField.js.map +1 -0
  740. package/es/core/acroform/PDFAcroForm.d.ts +21 -0
  741. package/es/core/acroform/PDFAcroForm.d.ts.map +1 -0
  742. package/es/core/acroform/PDFAcroForm.js +75 -0
  743. package/es/core/acroform/PDFAcroForm.js.map +1 -0
  744. package/es/core/acroform/PDFAcroListBox.d.ts +10 -0
  745. package/es/core/acroform/PDFAcroListBox.d.ts.map +1 -0
  746. package/es/core/acroform/PDFAcroListBox.js +22 -0
  747. package/es/core/acroform/PDFAcroListBox.js.map +1 -0
  748. package/es/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  749. package/es/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -0
  750. package/es/core/acroform/PDFAcroNonTerminal.js +32 -0
  751. package/es/core/acroform/PDFAcroNonTerminal.js.map +1 -0
  752. package/es/core/acroform/PDFAcroPushButton.d.ts +10 -0
  753. package/es/core/acroform/PDFAcroPushButton.d.ts.map +1 -0
  754. package/es/core/acroform/PDFAcroPushButton.js +24 -0
  755. package/es/core/acroform/PDFAcroPushButton.js.map +1 -0
  756. package/es/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  757. package/es/core/acroform/PDFAcroRadioButton.d.ts.map +1 -0
  758. package/es/core/acroform/PDFAcroRadioButton.js +55 -0
  759. package/es/core/acroform/PDFAcroRadioButton.js.map +1 -0
  760. package/es/core/acroform/PDFAcroSignature.d.ts +8 -0
  761. package/es/core/acroform/PDFAcroSignature.d.ts.map +1 -0
  762. package/es/core/acroform/PDFAcroSignature.js +14 -0
  763. package/es/core/acroform/PDFAcroSignature.js.map +1 -0
  764. package/es/core/acroform/PDFAcroTerminal.d.ts +17 -0
  765. package/es/core/acroform/PDFAcroTerminal.d.ts.map +1 -0
  766. package/es/core/acroform/PDFAcroTerminal.js +68 -0
  767. package/es/core/acroform/PDFAcroTerminal.js.map +1 -0
  768. package/es/core/acroform/PDFAcroText.d.ts +23 -0
  769. package/es/core/acroform/PDFAcroText.d.ts.map +1 -0
  770. package/es/core/acroform/PDFAcroText.js +71 -0
  771. package/es/core/acroform/PDFAcroText.js.map +1 -0
  772. package/es/core/acroform/flags.d.ts +142 -0
  773. package/es/core/acroform/flags.d.ts.map +1 -0
  774. package/es/core/acroform/flags.js +147 -0
  775. package/es/core/acroform/flags.js.map +1 -0
  776. package/es/core/acroform/index.d.ts +16 -0
  777. package/es/core/acroform/index.d.ts.map +1 -0
  778. package/es/core/acroform/index.js +16 -0
  779. package/es/core/acroform/index.js.map +1 -0
  780. package/es/core/acroform/utils.d.ts +7 -0
  781. package/es/core/acroform/utils.d.ts.map +1 -0
  782. package/es/core/acroform/utils.js +123 -0
  783. package/es/core/acroform/utils.js.map +1 -0
  784. package/es/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  785. package/es/core/annotation/AppearanceCharacteristics.d.ts.map +1 -0
  786. package/es/core/annotation/AppearanceCharacteristics.js +120 -0
  787. package/es/core/annotation/AppearanceCharacteristics.js.map +1 -0
  788. package/es/core/annotation/BorderStyle.d.ts +12 -0
  789. package/es/core/annotation/BorderStyle.d.ts.map +1 -0
  790. package/es/core/annotation/BorderStyle.js +26 -0
  791. package/es/core/annotation/BorderStyle.js.map +1 -0
  792. package/es/core/annotation/PDFAnnotation.d.ts +52 -0
  793. package/es/core/annotation/PDFAnnotation.d.ts.map +1 -0
  794. package/es/core/annotation/PDFAnnotation.js +120 -0
  795. package/es/core/annotation/PDFAnnotation.js.map +1 -0
  796. package/es/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  797. package/es/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -0
  798. package/es/core/annotation/PDFWidgetAnnotation.js +108 -0
  799. package/es/core/annotation/PDFWidgetAnnotation.js.map +1 -0
  800. package/es/core/annotation/flags.d.ts +80 -0
  801. package/es/core/annotation/flags.d.ts.map +1 -0
  802. package/es/core/annotation/flags.js +82 -0
  803. package/es/core/annotation/flags.js.map +1 -0
  804. package/es/core/annotation/index.d.ts +5 -0
  805. package/es/core/annotation/index.d.ts.map +1 -0
  806. package/es/core/annotation/index.js +5 -0
  807. package/es/core/annotation/index.js.map +1 -0
  808. package/es/core/document/PDFCrossRefSection.d.ts +28 -0
  809. package/es/core/document/PDFCrossRefSection.d.ts.map +1 -0
  810. package/es/core/document/PDFCrossRefSection.js +121 -0
  811. package/es/core/document/PDFCrossRefSection.js.map +1 -0
  812. package/es/core/document/PDFHeader.d.ts +11 -0
  813. package/es/core/document/PDFHeader.d.ts.map +1 -0
  814. package/es/core/document/PDFHeader.js +39 -0
  815. package/es/core/document/PDFHeader.js.map +1 -0
  816. package/es/core/document/PDFTrailer.d.ts +10 -0
  817. package/es/core/document/PDFTrailer.d.ts.map +1 -0
  818. package/es/core/document/PDFTrailer.js +40 -0
  819. package/es/core/document/PDFTrailer.js.map +1 -0
  820. package/es/core/document/PDFTrailerDict.d.ts +11 -0
  821. package/es/core/document/PDFTrailerDict.d.ts.map +1 -0
  822. package/es/core/document/PDFTrailerDict.js +29 -0
  823. package/es/core/document/PDFTrailerDict.js.map +1 -0
  824. package/es/core/embedders/CMap.d.ts +4 -0
  825. package/es/core/embedders/CMap.d.ts.map +1 -0
  826. package/es/core/embedders/CMap.js +40 -0
  827. package/es/core/embedders/CMap.js.map +1 -0
  828. package/es/core/embedders/CustomFontEmbedder.d.ts +45 -0
  829. package/es/core/embedders/CustomFontEmbedder.d.ts.map +1 -0
  830. package/es/core/embedders/CustomFontEmbedder.js +238 -0
  831. package/es/core/embedders/CustomFontEmbedder.js.map +1 -0
  832. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  833. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -0
  834. package/es/core/embedders/CustomFontSubsetEmbedder.js +66 -0
  835. package/es/core/embedders/CustomFontSubsetEmbedder.js.map +1 -0
  836. package/es/core/embedders/FileEmbedder.d.ts +34 -0
  837. package/es/core/embedders/FileEmbedder.d.ts.map +1 -0
  838. package/es/core/embedders/FileEmbedder.js +72 -0
  839. package/es/core/embedders/FileEmbedder.js.map +1 -0
  840. package/es/core/embedders/FontFlags.d.ts +14 -0
  841. package/es/core/embedders/FontFlags.d.ts.map +1 -0
  842. package/es/core/embedders/FontFlags.js +37 -0
  843. package/es/core/embedders/FontFlags.js.map +1 -0
  844. package/es/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  845. package/es/core/embedders/JavaScriptEmbedder.d.ts.map +1 -0
  846. package/es/core/embedders/JavaScriptEmbedder.js +34 -0
  847. package/es/core/embedders/JavaScriptEmbedder.js.map +1 -0
  848. package/es/core/embedders/JpegEmbedder.d.ts +24 -0
  849. package/es/core/embedders/JpegEmbedder.d.ts.map +1 -0
  850. package/es/core/embedders/JpegEmbedder.js +132 -0
  851. package/es/core/embedders/JpegEmbedder.js.map +1 -0
  852. package/es/core/embedders/PDFPageEmbedder.d.ts +38 -0
  853. package/es/core/embedders/PDFPageEmbedder.d.ts.map +1 -0
  854. package/es/core/embedders/PDFPageEmbedder.js +89 -0
  855. package/es/core/embedders/PDFPageEmbedder.js.map +1 -0
  856. package/es/core/embedders/PngEmbedder.d.ts +20 -0
  857. package/es/core/embedders/PngEmbedder.d.ts.map +1 -0
  858. package/es/core/embedders/PngEmbedder.js +67 -0
  859. package/es/core/embedders/PngEmbedder.js.map +1 -0
  860. package/es/core/embedders/StandardFontEmbedder.d.ts +37 -0
  861. package/es/core/embedders/StandardFontEmbedder.d.ts.map +1 -0
  862. package/es/core/embedders/StandardFontEmbedder.js +95 -0
  863. package/es/core/embedders/StandardFontEmbedder.js.map +1 -0
  864. package/es/core/errors.d.ts +92 -0
  865. package/es/core/errors.d.ts.map +1 -0
  866. package/es/core/errors.js +320 -0
  867. package/es/core/errors.js.map +1 -0
  868. package/es/core/index.d.ts +48 -0
  869. package/es/core/index.d.ts.map +1 -0
  870. package/es/core/index.js +48 -0
  871. package/es/core/index.js.map +1 -0
  872. package/es/core/interactive/ViewerPreferences.d.ts +348 -0
  873. package/es/core/interactive/ViewerPreferences.d.ts.map +1 -0
  874. package/es/core/interactive/ViewerPreferences.js +507 -0
  875. package/es/core/interactive/ViewerPreferences.js.map +1 -0
  876. package/es/core/objects/PDFArray.d.ts +64 -0
  877. package/es/core/objects/PDFArray.d.ts.map +1 -0
  878. package/es/core/objects/PDFArray.js +115 -0
  879. package/es/core/objects/PDFArray.js.map +1 -0
  880. package/es/core/objects/PDFBool.d.ts +14 -0
  881. package/es/core/objects/PDFBool.d.ts.map +1 -0
  882. package/es/core/objects/PDFBool.js +50 -0
  883. package/es/core/objects/PDFBool.js.map +1 -0
  884. package/es/core/objects/PDFDict.d.ts +62 -0
  885. package/es/core/objects/PDFDict.d.ts.map +1 -0
  886. package/es/core/objects/PDFDict.js +136 -0
  887. package/es/core/objects/PDFDict.js.map +1 -0
  888. package/es/core/objects/PDFHexString.d.ts +17 -0
  889. package/es/core/objects/PDFHexString.d.ts.map +1 -0
  890. package/es/core/objects/PDFHexString.js +72 -0
  891. package/es/core/objects/PDFHexString.js.map +1 -0
  892. package/es/core/objects/PDFInvalidObject.d.ts +12 -0
  893. package/es/core/objects/PDFInvalidObject.d.ts.map +1 -0
  894. package/es/core/objects/PDFInvalidObject.js +30 -0
  895. package/es/core/objects/PDFInvalidObject.js.map +1 -0
  896. package/es/core/objects/PDFName.d.ts +42 -0
  897. package/es/core/objects/PDFName.d.ts.map +1 -0
  898. package/es/core/objects/PDFName.js +136 -0
  899. package/es/core/objects/PDFName.js.map +1 -0
  900. package/es/core/objects/PDFNull.d.ts +11 -0
  901. package/es/core/objects/PDFNull.d.ts.map +1 -0
  902. package/es/core/objects/PDFNull.js +31 -0
  903. package/es/core/objects/PDFNull.js.map +1 -0
  904. package/es/core/objects/PDFNumber.d.ts +16 -0
  905. package/es/core/objects/PDFNumber.d.ts.map +1 -0
  906. package/es/core/objects/PDFNumber.js +36 -0
  907. package/es/core/objects/PDFNumber.js.map +1 -0
  908. package/es/core/objects/PDFObject.d.ts +9 -0
  909. package/es/core/objects/PDFObject.d.ts.map +1 -0
  910. package/es/core/objects/PDFObject.js +20 -0
  911. package/es/core/objects/PDFObject.js.map +1 -0
  912. package/es/core/objects/PDFRawStream.d.ts +15 -0
  913. package/es/core/objects/PDFRawStream.d.ts.map +1 -0
  914. package/es/core/objects/PDFRawStream.js +32 -0
  915. package/es/core/objects/PDFRawStream.js.map +1 -0
  916. package/es/core/objects/PDFRef.d.ts +14 -0
  917. package/es/core/objects/PDFRef.d.ts.map +1 -0
  918. package/es/core/objects/PDFRef.js +45 -0
  919. package/es/core/objects/PDFRef.js.map +1 -0
  920. package/es/core/objects/PDFStream.d.ts +17 -0
  921. package/es/core/objects/PDFStream.d.ts.map +1 -0
  922. package/es/core/objects/PDFStream.js +73 -0
  923. package/es/core/objects/PDFStream.js.map +1 -0
  924. package/es/core/objects/PDFString.d.ts +17 -0
  925. package/es/core/objects/PDFString.d.ts.map +1 -0
  926. package/es/core/objects/PDFString.js +114 -0
  927. package/es/core/objects/PDFString.js.map +1 -0
  928. package/es/core/operators/PDFOperator.d.ts +20 -0
  929. package/es/core/operators/PDFOperator.d.ts.map +1 -0
  930. package/es/core/operators/PDFOperator.js +55 -0
  931. package/es/core/operators/PDFOperator.js.map +1 -0
  932. package/es/core/operators/PDFOperatorNames.d.ts +77 -0
  933. package/es/core/operators/PDFOperatorNames.d.ts.map +1 -0
  934. package/es/core/operators/PDFOperatorNames.js +86 -0
  935. package/es/core/operators/PDFOperatorNames.js.map +1 -0
  936. package/es/core/parser/BaseParser.d.ts +15 -0
  937. package/es/core/parser/BaseParser.d.ts.map +1 -0
  938. package/es/core/parser/BaseParser.js +107 -0
  939. package/es/core/parser/BaseParser.js.map +1 -0
  940. package/es/core/parser/ByteStream.d.ts +27 -0
  941. package/es/core/parser/ByteStream.d.ts.map +1 -0
  942. package/es/core/parser/ByteStream.js +61 -0
  943. package/es/core/parser/ByteStream.js.map +1 -0
  944. package/es/core/parser/PDFObjectParser.d.ts +30 -0
  945. package/es/core/parser/PDFObjectParser.d.ts.map +1 -0
  946. package/es/core/parser/PDFObjectParser.js +231 -0
  947. package/es/core/parser/PDFObjectParser.js.map +1 -0
  948. package/es/core/parser/PDFObjectStreamParser.d.ts +14 -0
  949. package/es/core/parser/PDFObjectStreamParser.d.ts.map +1 -0
  950. package/es/core/parser/PDFObjectStreamParser.js +68 -0
  951. package/es/core/parser/PDFObjectStreamParser.js.map +1 -0
  952. package/es/core/parser/PDFParser.d.ts +46 -0
  953. package/es/core/parser/PDFParser.d.ts.map +1 -0
  954. package/es/core/parser/PDFParser.js +354 -0
  955. package/es/core/parser/PDFParser.js.map +1 -0
  956. package/es/core/parser/PDFXRefStreamParser.d.ts +22 -0
  957. package/es/core/parser/PDFXRefStreamParser.d.ts.map +1 -0
  958. package/es/core/parser/PDFXRefStreamParser.js +99 -0
  959. package/es/core/parser/PDFXRefStreamParser.js.map +1 -0
  960. package/es/core/streams/Ascii85Stream.d.ts +10 -0
  961. package/es/core/streams/Ascii85Stream.d.ts.map +1 -0
  962. package/es/core/streams/Ascii85Stream.js +85 -0
  963. package/es/core/streams/Ascii85Stream.js.map +1 -0
  964. package/es/core/streams/AsciiHexStream.d.ts +10 -0
  965. package/es/core/streams/AsciiHexStream.d.ts.map +1 -0
  966. package/es/core/streams/AsciiHexStream.js +73 -0
  967. package/es/core/streams/AsciiHexStream.js.map +1 -0
  968. package/es/core/streams/DecodeStream.d.ts +28 -0
  969. package/es/core/streams/DecodeStream.d.ts.map +1 -0
  970. package/es/core/streams/DecodeStream.js +157 -0
  971. package/es/core/streams/DecodeStream.js.map +1 -0
  972. package/es/core/streams/FlateStream.d.ts +14 -0
  973. package/es/core/streams/FlateStream.d.ts.map +1 -0
  974. package/es/core/streams/FlateStream.js +369 -0
  975. package/es/core/streams/FlateStream.js.map +1 -0
  976. package/es/core/streams/LZWStream.d.ts +13 -0
  977. package/es/core/streams/LZWStream.d.ts.map +1 -0
  978. package/es/core/streams/LZWStream.js +135 -0
  979. package/es/core/streams/LZWStream.js.map +1 -0
  980. package/es/core/streams/RunLengthStream.d.ts +9 -0
  981. package/es/core/streams/RunLengthStream.d.ts.map +1 -0
  982. package/es/core/streams/RunLengthStream.js +53 -0
  983. package/es/core/streams/RunLengthStream.js.map +1 -0
  984. package/es/core/streams/Stream.d.ts +35 -0
  985. package/es/core/streams/Stream.d.ts.map +1 -0
  986. package/es/core/streams/Stream.js +104 -0
  987. package/es/core/streams/Stream.js.map +1 -0
  988. package/es/core/streams/decode.d.ts +4 -0
  989. package/es/core/streams/decode.d.ts.map +1 -0
  990. package/es/core/streams/decode.js +55 -0
  991. package/es/core/streams/decode.js.map +1 -0
  992. package/es/core/structures/PDFCatalog.d.ts +28 -0
  993. package/es/core/structures/PDFCatalog.d.ts.map +1 -0
  994. package/es/core/structures/PDFCatalog.js +77 -0
  995. package/es/core/structures/PDFCatalog.js.map +1 -0
  996. package/es/core/structures/PDFContentStream.d.ts +16 -0
  997. package/es/core/structures/PDFContentStream.d.ts.map +1 -0
  998. package/es/core/structures/PDFContentStream.js +58 -0
  999. package/es/core/structures/PDFContentStream.js.map +1 -0
  1000. package/es/core/structures/PDFCrossRefStream.d.ts +54 -0
  1001. package/es/core/structures/PDFCrossRefStream.d.ts.map +1 -0
  1002. package/es/core/structures/PDFCrossRefStream.js +184 -0
  1003. package/es/core/structures/PDFCrossRefStream.js.map +1 -0
  1004. package/es/core/structures/PDFFlateStream.d.ts +14 -0
  1005. package/es/core/structures/PDFFlateStream.d.ts.map +1 -0
  1006. package/es/core/structures/PDFFlateStream.js +33 -0
  1007. package/es/core/structures/PDFFlateStream.js.map +1 -0
  1008. package/es/core/structures/PDFObjectStream.d.ts +21 -0
  1009. package/es/core/structures/PDFObjectStream.d.ts.map +1 -0
  1010. package/es/core/structures/PDFObjectStream.js +75 -0
  1011. package/es/core/structures/PDFObjectStream.js.map +1 -0
  1012. package/es/core/structures/PDFPageLeaf.d.ts +55 -0
  1013. package/es/core/structures/PDFPageLeaf.d.ts.map +1 -0
  1014. package/es/core/structures/PDFPageLeaf.js +204 -0
  1015. package/es/core/structures/PDFPageLeaf.js.map +1 -0
  1016. package/es/core/structures/PDFPageTree.d.ts +42 -0
  1017. package/es/core/structures/PDFPageTree.d.ts.map +1 -0
  1018. package/es/core/structures/PDFPageTree.js +175 -0
  1019. package/es/core/structures/PDFPageTree.js.map +1 -0
  1020. package/es/core/syntax/CharCodes.d.ts +62 -0
  1021. package/es/core/syntax/CharCodes.d.ts.map +1 -0
  1022. package/es/core/syntax/CharCodes.js +63 -0
  1023. package/es/core/syntax/CharCodes.js.map +1 -0
  1024. package/es/core/syntax/Delimiters.d.ts +2 -0
  1025. package/es/core/syntax/Delimiters.d.ts.map +1 -0
  1026. package/es/core/syntax/Delimiters.js +13 -0
  1027. package/es/core/syntax/Delimiters.js.map +1 -0
  1028. package/es/core/syntax/Irregular.d.ts +2 -0
  1029. package/es/core/syntax/Irregular.d.ts.map +1 -0
  1030. package/es/core/syntax/Irregular.js +9 -0
  1031. package/es/core/syntax/Irregular.js.map +1 -0
  1032. package/es/core/syntax/Keywords.d.ts +23 -0
  1033. package/es/core/syntax/Keywords.d.ts.map +1 -0
  1034. package/es/core/syntax/Keywords.js +81 -0
  1035. package/es/core/syntax/Keywords.js.map +1 -0
  1036. package/es/core/syntax/Numeric.d.ts +4 -0
  1037. package/es/core/syntax/Numeric.d.ts.map +1 -0
  1038. package/es/core/syntax/Numeric.js +21 -0
  1039. package/es/core/syntax/Numeric.js.map +1 -0
  1040. package/es/core/syntax/Whitespace.d.ts +2 -0
  1041. package/es/core/syntax/Whitespace.d.ts.map +1 -0
  1042. package/es/core/syntax/Whitespace.js +9 -0
  1043. package/es/core/syntax/Whitespace.js.map +1 -0
  1044. package/es/core/writers/PDFStreamWriter.d.ts +20 -0
  1045. package/es/core/writers/PDFStreamWriter.d.ts.map +1 -0
  1046. package/es/core/writers/PDFStreamWriter.js +111 -0
  1047. package/es/core/writers/PDFStreamWriter.js.map +1 -0
  1048. package/es/core/writers/PDFWriter.d.ts +30 -0
  1049. package/es/core/writers/PDFWriter.d.ts.map +1 -0
  1050. package/es/core/writers/PDFWriter.js +142 -0
  1051. package/es/core/writers/PDFWriter.js.map +1 -0
  1052. package/es/index.d.ts +5 -0
  1053. package/es/index.d.ts.map +1 -0
  1054. package/es/index.js +5 -0
  1055. package/es/index.js.map +1 -0
  1056. package/es/types/fontkit.d.ts +582 -0
  1057. package/es/types/fontkit.d.ts.map +1 -0
  1058. package/es/types/fontkit.js +1 -0
  1059. package/es/types/fontkit.js.map +1 -0
  1060. package/es/types/index.d.ts +2 -0
  1061. package/es/types/index.d.ts.map +1 -0
  1062. package/es/types/index.js +1 -0
  1063. package/es/types/index.js.map +1 -0
  1064. package/es/types/matrix.d.ts +22 -0
  1065. package/es/types/matrix.d.ts.map +1 -0
  1066. package/es/types/matrix.js +2 -0
  1067. package/es/types/matrix.js.map +1 -0
  1068. package/es/utils/Cache.d.ts +11 -0
  1069. package/es/utils/Cache.d.ts.map +1 -0
  1070. package/es/utils/Cache.js +21 -0
  1071. package/es/utils/Cache.js.map +1 -0
  1072. package/es/utils/arrays.d.ts +16 -0
  1073. package/es/utils/arrays.d.ts.map +1 -0
  1074. package/es/utils/arrays.js +129 -0
  1075. package/es/utils/arrays.js.map +1 -0
  1076. package/es/utils/async.d.ts +6 -0
  1077. package/es/utils/async.d.ts.map +1 -0
  1078. package/es/utils/async.js +10 -0
  1079. package/es/utils/async.js.map +1 -0
  1080. package/es/utils/base64.d.ts +11 -0
  1081. package/es/utils/base64.d.ts.map +1 -0
  1082. package/es/utils/base64.js +84 -0
  1083. package/es/utils/base64.js.map +1 -0
  1084. package/es/utils/errors.d.ts +2 -0
  1085. package/es/utils/errors.d.ts.map +1 -0
  1086. package/es/utils/errors.js +4 -0
  1087. package/es/utils/errors.js.map +1 -0
  1088. package/es/utils/index.d.ts +12 -0
  1089. package/es/utils/index.d.ts.map +1 -0
  1090. package/es/utils/index.js +12 -0
  1091. package/es/utils/index.js.map +1 -0
  1092. package/es/utils/numbers.d.ts +24 -0
  1093. package/es/utils/numbers.d.ts.map +1 -0
  1094. package/es/utils/numbers.js +54 -0
  1095. package/es/utils/numbers.js.map +1 -0
  1096. package/es/utils/objects.d.ts +16 -0
  1097. package/es/utils/objects.d.ts.map +1 -0
  1098. package/es/utils/objects.js +8 -0
  1099. package/es/utils/objects.js.map +1 -0
  1100. package/es/utils/pdfDocEncoding.d.ts +8 -0
  1101. package/es/utils/pdfDocEncoding.d.ts.map +1 -0
  1102. package/es/utils/pdfDocEncoding.js +66 -0
  1103. package/es/utils/pdfDocEncoding.js.map +1 -0
  1104. package/es/utils/png.d.ts +18 -0
  1105. package/es/utils/png.d.ts.map +1 -0
  1106. package/es/utils/png.js +59 -0
  1107. package/es/utils/png.js.map +1 -0
  1108. package/es/utils/rng.d.ts +14 -0
  1109. package/es/utils/rng.d.ts.map +1 -0
  1110. package/es/utils/rng.js +20 -0
  1111. package/es/utils/rng.js.map +1 -0
  1112. package/es/utils/strings.d.ts +25 -0
  1113. package/es/utils/strings.d.ts.map +1 -0
  1114. package/es/utils/strings.js +216 -0
  1115. package/es/utils/strings.js.map +1 -0
  1116. package/es/utils/unicode.d.ts +187 -0
  1117. package/es/utils/unicode.d.ts.map +1 -0
  1118. package/es/utils/unicode.js +367 -0
  1119. package/es/utils/unicode.js.map +1 -0
  1120. package/es/utils/validators.d.ts +27 -0
  1121. package/es/utils/validators.d.ts.map +1 -0
  1122. package/es/utils/validators.js +180 -0
  1123. package/es/utils/validators.js.map +1 -0
  1124. package/package.json +154 -4
  1125. package/src/api/Embeddable.ts +7 -0
  1126. package/src/api/PDFDocument.ts +1395 -0
  1127. package/src/api/PDFDocumentOptions.ts +44 -0
  1128. package/src/api/PDFEmbeddedFile.ts +90 -0
  1129. package/src/api/PDFEmbeddedPage.ts +104 -0
  1130. package/src/api/PDFFont.ts +154 -0
  1131. package/src/api/PDFImage.ts +143 -0
  1132. package/src/api/PDFJavaScript.ts +82 -0
  1133. package/src/api/PDFPage.ts +1621 -0
  1134. package/src/api/PDFPageOptions.ts +158 -0
  1135. package/src/api/StandardFonts.ts +16 -0
  1136. package/src/api/colors.ts +104 -0
  1137. package/src/api/errors.ts +135 -0
  1138. package/src/api/form/PDFButton.ts +267 -0
  1139. package/src/api/form/PDFCheckBox.ts +262 -0
  1140. package/src/api/form/PDFDropdown.ts +652 -0
  1141. package/src/api/form/PDFField.ts +521 -0
  1142. package/src/api/form/PDFForm.ts +852 -0
  1143. package/src/api/form/PDFOptionList.ts +571 -0
  1144. package/src/api/form/PDFRadioGroup.ts +471 -0
  1145. package/src/api/form/PDFSignature.ts +53 -0
  1146. package/src/api/form/PDFTextField.ts +826 -0
  1147. package/src/api/form/appearances.ts +665 -0
  1148. package/src/api/form/index.ts +10 -0
  1149. package/src/api/image/alignment.ts +5 -0
  1150. package/src/api/image/index.ts +1 -0
  1151. package/src/api/index.ts +20 -0
  1152. package/src/api/objects.ts +10 -0
  1153. package/src/api/operations.ts +800 -0
  1154. package/src/api/operators.ts +360 -0
  1155. package/src/api/rotations.ts +87 -0
  1156. package/src/api/sizes.ts +52 -0
  1157. package/src/api/svgPath.ts +493 -0
  1158. package/src/api/text/alignment.ts +5 -0
  1159. package/src/api/text/index.ts +2 -0
  1160. package/src/api/text/layout.ts +343 -0
  1161. package/src/core/PDFContext.ts +299 -0
  1162. package/src/core/PDFObjectCopier.ts +143 -0
  1163. package/src/core/acroform/PDFAcroButton.ts +114 -0
  1164. package/src/core/acroform/PDFAcroCheckBox.ts +49 -0
  1165. package/src/core/acroform/PDFAcroChoice.ts +153 -0
  1166. package/src/core/acroform/PDFAcroComboBox.ts +22 -0
  1167. package/src/core/acroform/PDFAcroField.ts +167 -0
  1168. package/src/core/acroform/PDFAcroForm.ts +102 -0
  1169. package/src/core/acroform/PDFAcroListBox.ts +20 -0
  1170. package/src/core/acroform/PDFAcroNonTerminal.ts +34 -0
  1171. package/src/core/acroform/PDFAcroPushButton.ts +22 -0
  1172. package/src/core/acroform/PDFAcroRadioButton.ts +58 -0
  1173. package/src/core/acroform/PDFAcroSignature.ts +10 -0
  1174. package/src/core/acroform/PDFAcroTerminal.ts +71 -0
  1175. package/src/core/acroform/PDFAcroText.ts +76 -0
  1176. package/src/core/acroform/flags.ts +162 -0
  1177. package/src/core/acroform/index.ts +15 -0
  1178. package/src/core/acroform/utils.ts +135 -0
  1179. package/src/core/annotation/AppearanceCharacteristics.ts +133 -0
  1180. package/src/core/annotation/BorderStyle.ts +31 -0
  1181. package/src/core/annotation/PDFAnnotation.ts +148 -0
  1182. package/src/core/annotation/PDFWidgetAnnotation.ts +112 -0
  1183. package/src/core/annotation/flags.ts +90 -0
  1184. package/src/core/annotation/index.ts +4 -0
  1185. package/src/core/document/PDFCrossRefSection.ts +173 -0
  1186. package/src/core/document/PDFHeader.ts +49 -0
  1187. package/src/core/document/PDFTrailer.ts +49 -0
  1188. package/src/core/document/PDFTrailerDict.ts +39 -0
  1189. package/src/core/embedders/CMap.ts +70 -0
  1190. package/src/core/embedders/CustomFontEmbedder.ts +249 -0
  1191. package/src/core/embedders/CustomFontSubsetEmbedder.ts +84 -0
  1192. package/src/core/embedders/FileEmbedder.ts +95 -0
  1193. package/src/core/embedders/FontFlags.ts +45 -0
  1194. package/src/core/embedders/JavaScriptEmbedder.ts +34 -0
  1195. package/src/core/embedders/JpegEmbedder.ts +179 -0
  1196. package/src/core/embedders/PDFPageEmbedder.ts +141 -0
  1197. package/src/core/embedders/PngEmbedder.ts +69 -0
  1198. package/src/core/embedders/StandardFontEmbedder.ts +130 -0
  1199. package/src/core/errors.ts +221 -0
  1200. package/src/core/index.ts +69 -0
  1201. package/src/core/interactive/ViewerPreferences.ts +579 -0
  1202. package/src/core/objects/PDFArray.ts +185 -0
  1203. package/src/core/objects/PDFBool.ts +53 -0
  1204. package/src/core/objects/PDFDict.ts +226 -0
  1205. package/src/core/objects/PDFHexString.ts +94 -0
  1206. package/src/core/objects/PDFInvalidObject.ts +34 -0
  1207. package/src/core/objects/PDFName.ts +159 -0
  1208. package/src/core/objects/PDFNull.ts +30 -0
  1209. package/src/core/objects/PDFNumber.ts +44 -0
  1210. package/src/core/objects/PDFObject.ts +22 -0
  1211. package/src/core/objects/PDFRawStream.ts +38 -0
  1212. package/src/core/objects/PDFRef.ts +55 -0
  1213. package/src/core/objects/PDFStream.ts +93 -0
  1214. package/src/core/objects/PDFString.ts +118 -0
  1215. package/src/core/operators/PDFOperator.ts +79 -0
  1216. package/src/core/operators/PDFOperatorNames.ts +92 -0
  1217. package/src/core/parser/BaseParser.ts +119 -0
  1218. package/src/core/parser/ByteStream.ts +76 -0
  1219. package/src/core/parser/PDFObjectParser.ts +274 -0
  1220. package/src/core/parser/PDFObjectStreamParser.ts +67 -0
  1221. package/src/core/parser/PDFParser.ts +364 -0
  1222. package/src/core/parser/PDFXRefStreamParser.ts +140 -0
  1223. package/src/core/streams/Ascii85Stream.ts +98 -0
  1224. package/src/core/streams/AsciiHexStream.ts +77 -0
  1225. package/src/core/streams/DecodeStream.ts +184 -0
  1226. package/src/core/streams/FlateStream.ts +407 -0
  1227. package/src/core/streams/LZWStream.ts +164 -0
  1228. package/src/core/streams/RunLengthStream.ts +55 -0
  1229. package/src/core/streams/Stream.ts +132 -0
  1230. package/src/core/streams/decode.ts +73 -0
  1231. package/src/core/structures/PDFCatalog.ts +85 -0
  1232. package/src/core/structures/PDFContentStream.ts +58 -0
  1233. package/src/core/structures/PDFCrossRefStream.ts +246 -0
  1234. package/src/core/structures/PDFFlateStream.ts +43 -0
  1235. package/src/core/structures/PDFObjectStream.ts +101 -0
  1236. package/src/core/structures/PDFPageLeaf.ts +263 -0
  1237. package/src/core/structures/PDFPageTree.ts +195 -0
  1238. package/src/core/syntax/CharCodes.ts +62 -0
  1239. package/src/core/syntax/Delimiters.ts +14 -0
  1240. package/src/core/syntax/Irregular.ts +10 -0
  1241. package/src/core/syntax/Keywords.ts +83 -0
  1242. package/src/core/syntax/Numeric.ts +26 -0
  1243. package/src/core/syntax/Whitespace.ts +10 -0
  1244. package/src/core/writers/PDFStreamWriter.ts +123 -0
  1245. package/src/core/writers/PDFWriter.ts +156 -0
  1246. package/src/index.ts +4 -0
  1247. package/src/types/fontkit.ts +640 -0
  1248. package/src/types/index.ts +1 -0
  1249. package/src/types/matrix.ts +29 -0
  1250. package/src/utils/Cache.ts +26 -0
  1251. package/src/utils/arrays.ts +146 -0
  1252. package/src/utils/async.ts +8 -0
  1253. package/src/utils/base64.ts +99 -0
  1254. package/src/utils/errors.ts +3 -0
  1255. package/src/utils/index.ts +11 -0
  1256. package/src/utils/numbers.ts +55 -0
  1257. package/src/utils/objects.ts +13 -0
  1258. package/src/utils/pdfDocEncoding.ts +69 -0
  1259. package/src/utils/png.ts +70 -0
  1260. package/src/utils/rng.ts +21 -0
  1261. package/src/utils/strings.ts +253 -0
  1262. package/src/utils/unicode.ts +386 -0
  1263. package/src/utils/validators.ts +228 -0
  1264. package/ts3.4/cjs/api/Embeddable.d.ts +8 -0
  1265. package/ts3.4/cjs/api/PDFDocument.d.ts +779 -0
  1266. package/ts3.4/cjs/api/PDFDocumentOptions.d.ts +38 -0
  1267. package/ts3.4/cjs/api/PDFEmbeddedFile.d.ts +39 -0
  1268. package/ts3.4/cjs/api/PDFEmbeddedPage.d.ts +74 -0
  1269. package/ts3.4/cjs/api/PDFFont.d.ts +95 -0
  1270. package/ts3.4/cjs/api/PDFImage.d.ts +96 -0
  1271. package/ts3.4/cjs/api/PDFJavaScript.d.ts +39 -0
  1272. package/ts3.4/cjs/api/PDFPage.d.ts +898 -0
  1273. package/ts3.4/cjs/api/PDFPageOptions.d.ts +155 -0
  1274. package/ts3.4/cjs/api/StandardFonts.d.ts +17 -0
  1275. package/ts3.4/cjs/api/colors.d.ts +31 -0
  1276. package/ts3.4/cjs/api/errors.d.ts +43 -0
  1277. package/ts3.4/cjs/api/form/PDFButton.d.ts +138 -0
  1278. package/ts3.4/cjs/api/form/PDFCheckBox.d.ts +143 -0
  1279. package/ts3.4/cjs/api/form/PDFDropdown.d.ts +403 -0
  1280. package/ts3.4/cjs/api/form/PDFField.d.ts +204 -0
  1281. package/ts3.4/cjs/api/form/PDFForm.d.ts +412 -0
  1282. package/ts3.4/cjs/api/form/PDFOptionList.d.ts +336 -0
  1283. package/ts3.4/cjs/api/form/PDFRadioGroup.d.ts +253 -0
  1284. package/ts3.4/cjs/api/form/PDFSignature.d.ts +30 -0
  1285. package/ts3.4/cjs/api/form/PDFTextField.d.ts +538 -0
  1286. package/ts3.4/cjs/api/form/appearances.d.ts +42 -0
  1287. package/ts3.4/cjs/api/form/index.d.ts +11 -0
  1288. package/ts3.4/cjs/api/image/alignment.d.ts +6 -0
  1289. package/ts3.4/cjs/api/image/index.d.ts +2 -0
  1290. package/ts3.4/cjs/api/index.d.ts +21 -0
  1291. package/ts3.4/cjs/api/objects.d.ts +5 -0
  1292. package/ts3.4/cjs/api/operations.d.ts +212 -0
  1293. package/ts3.4/cjs/api/operators.d.ts +86 -0
  1294. package/ts3.4/cjs/api/rotations.d.ts +39 -0
  1295. package/ts3.4/cjs/api/sizes.d.ts +53 -0
  1296. package/ts3.4/cjs/api/svgPath.d.ts +3 -0
  1297. package/ts3.4/cjs/api/text/alignment.d.ts +6 -0
  1298. package/ts3.4/cjs/api/text/index.d.ts +3 -0
  1299. package/ts3.4/cjs/api/text/layout.d.ts +55 -0
  1300. package/ts3.4/cjs/core/PDFContext.d.ts +84 -0
  1301. package/ts3.4/cjs/core/PDFObjectCopier.d.ts +38 -0
  1302. package/ts3.4/cjs/core/acroform/PDFAcroButton.d.ts +22 -0
  1303. package/ts3.4/cjs/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  1304. package/ts3.4/cjs/core/acroform/PDFAcroChoice.d.ts +21 -0
  1305. package/ts3.4/cjs/core/acroform/PDFAcroComboBox.d.ts +10 -0
  1306. package/ts3.4/cjs/core/acroform/PDFAcroField.d.ts +37 -0
  1307. package/ts3.4/cjs/core/acroform/PDFAcroForm.d.ts +21 -0
  1308. package/ts3.4/cjs/core/acroform/PDFAcroListBox.d.ts +10 -0
  1309. package/ts3.4/cjs/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  1310. package/ts3.4/cjs/core/acroform/PDFAcroPushButton.d.ts +10 -0
  1311. package/ts3.4/cjs/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  1312. package/ts3.4/cjs/core/acroform/PDFAcroSignature.d.ts +8 -0
  1313. package/ts3.4/cjs/core/acroform/PDFAcroTerminal.d.ts +17 -0
  1314. package/ts3.4/cjs/core/acroform/PDFAcroText.d.ts +23 -0
  1315. package/ts3.4/cjs/core/acroform/flags.d.ts +142 -0
  1316. package/ts3.4/cjs/core/acroform/index.d.ts +16 -0
  1317. package/ts3.4/cjs/core/acroform/utils.d.ts +7 -0
  1318. package/ts3.4/cjs/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  1319. package/ts3.4/cjs/core/annotation/BorderStyle.d.ts +12 -0
  1320. package/ts3.4/cjs/core/annotation/PDFAnnotation.d.ts +52 -0
  1321. package/ts3.4/cjs/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  1322. package/ts3.4/cjs/core/annotation/flags.d.ts +80 -0
  1323. package/ts3.4/cjs/core/annotation/index.d.ts +5 -0
  1324. package/ts3.4/cjs/core/document/PDFCrossRefSection.d.ts +28 -0
  1325. package/ts3.4/cjs/core/document/PDFHeader.d.ts +11 -0
  1326. package/ts3.4/cjs/core/document/PDFTrailer.d.ts +10 -0
  1327. package/ts3.4/cjs/core/document/PDFTrailerDict.d.ts +11 -0
  1328. package/ts3.4/cjs/core/embedders/CMap.d.ts +4 -0
  1329. package/ts3.4/cjs/core/embedders/CustomFontEmbedder.d.ts +45 -0
  1330. package/ts3.4/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  1331. package/ts3.4/cjs/core/embedders/FileEmbedder.d.ts +34 -0
  1332. package/ts3.4/cjs/core/embedders/FontFlags.d.ts +14 -0
  1333. package/ts3.4/cjs/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  1334. package/ts3.4/cjs/core/embedders/JpegEmbedder.d.ts +24 -0
  1335. package/ts3.4/cjs/core/embedders/PDFPageEmbedder.d.ts +38 -0
  1336. package/ts3.4/cjs/core/embedders/PngEmbedder.d.ts +20 -0
  1337. package/ts3.4/cjs/core/embedders/StandardFontEmbedder.d.ts +37 -0
  1338. package/ts3.4/cjs/core/errors.d.ts +92 -0
  1339. package/ts3.4/cjs/core/index.d.ts +48 -0
  1340. package/ts3.4/cjs/core/interactive/ViewerPreferences.d.ts +348 -0
  1341. package/ts3.4/cjs/core/objects/PDFArray.d.ts +64 -0
  1342. package/ts3.4/cjs/core/objects/PDFBool.d.ts +14 -0
  1343. package/ts3.4/cjs/core/objects/PDFDict.d.ts +62 -0
  1344. package/ts3.4/cjs/core/objects/PDFHexString.d.ts +17 -0
  1345. package/ts3.4/cjs/core/objects/PDFInvalidObject.d.ts +12 -0
  1346. package/ts3.4/cjs/core/objects/PDFName.d.ts +42 -0
  1347. package/ts3.4/cjs/core/objects/PDFNull.d.ts +11 -0
  1348. package/ts3.4/cjs/core/objects/PDFNumber.d.ts +16 -0
  1349. package/ts3.4/cjs/core/objects/PDFObject.d.ts +9 -0
  1350. package/ts3.4/cjs/core/objects/PDFRawStream.d.ts +15 -0
  1351. package/ts3.4/cjs/core/objects/PDFRef.d.ts +14 -0
  1352. package/ts3.4/cjs/core/objects/PDFStream.d.ts +17 -0
  1353. package/ts3.4/cjs/core/objects/PDFString.d.ts +17 -0
  1354. package/ts3.4/cjs/core/operators/PDFOperator.d.ts +20 -0
  1355. package/ts3.4/cjs/core/operators/PDFOperatorNames.d.ts +77 -0
  1356. package/ts3.4/cjs/core/parser/BaseParser.d.ts +15 -0
  1357. package/ts3.4/cjs/core/parser/ByteStream.d.ts +27 -0
  1358. package/ts3.4/cjs/core/parser/PDFObjectParser.d.ts +30 -0
  1359. package/ts3.4/cjs/core/parser/PDFObjectStreamParser.d.ts +14 -0
  1360. package/ts3.4/cjs/core/parser/PDFParser.d.ts +46 -0
  1361. package/ts3.4/cjs/core/parser/PDFXRefStreamParser.d.ts +22 -0
  1362. package/ts3.4/cjs/core/streams/Ascii85Stream.d.ts +10 -0
  1363. package/ts3.4/cjs/core/streams/AsciiHexStream.d.ts +10 -0
  1364. package/ts3.4/cjs/core/streams/DecodeStream.d.ts +28 -0
  1365. package/ts3.4/cjs/core/streams/FlateStream.d.ts +14 -0
  1366. package/ts3.4/cjs/core/streams/LZWStream.d.ts +13 -0
  1367. package/ts3.4/cjs/core/streams/RunLengthStream.d.ts +9 -0
  1368. package/ts3.4/cjs/core/streams/Stream.d.ts +35 -0
  1369. package/ts3.4/cjs/core/streams/decode.d.ts +4 -0
  1370. package/ts3.4/cjs/core/structures/PDFCatalog.d.ts +28 -0
  1371. package/ts3.4/cjs/core/structures/PDFContentStream.d.ts +16 -0
  1372. package/ts3.4/cjs/core/structures/PDFCrossRefStream.d.ts +54 -0
  1373. package/ts3.4/cjs/core/structures/PDFFlateStream.d.ts +14 -0
  1374. package/ts3.4/cjs/core/structures/PDFObjectStream.d.ts +21 -0
  1375. package/ts3.4/cjs/core/structures/PDFPageLeaf.d.ts +55 -0
  1376. package/ts3.4/cjs/core/structures/PDFPageTree.d.ts +42 -0
  1377. package/ts3.4/cjs/core/syntax/CharCodes.d.ts +62 -0
  1378. package/ts3.4/cjs/core/syntax/Delimiters.d.ts +2 -0
  1379. package/ts3.4/cjs/core/syntax/Irregular.d.ts +2 -0
  1380. package/ts3.4/cjs/core/syntax/Keywords.d.ts +23 -0
  1381. package/ts3.4/cjs/core/syntax/Numeric.d.ts +4 -0
  1382. package/ts3.4/cjs/core/syntax/Whitespace.d.ts +2 -0
  1383. package/ts3.4/cjs/core/writers/PDFStreamWriter.d.ts +20 -0
  1384. package/ts3.4/cjs/core/writers/PDFWriter.d.ts +30 -0
  1385. package/ts3.4/cjs/index.d.ts +5 -0
  1386. package/ts3.4/cjs/types/fontkit.d.ts +582 -0
  1387. package/ts3.4/cjs/types/index.d.ts +2 -0
  1388. package/ts3.4/cjs/types/matrix.d.ts +22 -0
  1389. package/ts3.4/cjs/utils/Cache.d.ts +11 -0
  1390. package/ts3.4/cjs/utils/arrays.d.ts +16 -0
  1391. package/ts3.4/cjs/utils/async.d.ts +6 -0
  1392. package/ts3.4/cjs/utils/base64.d.ts +11 -0
  1393. package/ts3.4/cjs/utils/errors.d.ts +2 -0
  1394. package/ts3.4/cjs/utils/index.d.ts +12 -0
  1395. package/ts3.4/cjs/utils/numbers.d.ts +24 -0
  1396. package/ts3.4/cjs/utils/objects.d.ts +16 -0
  1397. package/ts3.4/cjs/utils/pdfDocEncoding.d.ts +8 -0
  1398. package/ts3.4/cjs/utils/png.d.ts +18 -0
  1399. package/ts3.4/cjs/utils/rng.d.ts +14 -0
  1400. package/ts3.4/cjs/utils/strings.d.ts +25 -0
  1401. package/ts3.4/cjs/utils/unicode.d.ts +187 -0
  1402. package/ts3.4/cjs/utils/validators.d.ts +27 -0
  1403. package/ts3.4/es/api/Embeddable.d.ts +8 -0
  1404. package/ts3.4/es/api/PDFDocument.d.ts +779 -0
  1405. package/ts3.4/es/api/PDFDocumentOptions.d.ts +38 -0
  1406. package/ts3.4/es/api/PDFEmbeddedFile.d.ts +39 -0
  1407. package/ts3.4/es/api/PDFEmbeddedPage.d.ts +74 -0
  1408. package/ts3.4/es/api/PDFFont.d.ts +95 -0
  1409. package/ts3.4/es/api/PDFImage.d.ts +96 -0
  1410. package/ts3.4/es/api/PDFJavaScript.d.ts +39 -0
  1411. package/ts3.4/es/api/PDFPage.d.ts +898 -0
  1412. package/ts3.4/es/api/PDFPageOptions.d.ts +155 -0
  1413. package/ts3.4/es/api/StandardFonts.d.ts +17 -0
  1414. package/ts3.4/es/api/colors.d.ts +31 -0
  1415. package/ts3.4/es/api/errors.d.ts +43 -0
  1416. package/ts3.4/es/api/form/PDFButton.d.ts +138 -0
  1417. package/ts3.4/es/api/form/PDFCheckBox.d.ts +143 -0
  1418. package/ts3.4/es/api/form/PDFDropdown.d.ts +403 -0
  1419. package/ts3.4/es/api/form/PDFField.d.ts +204 -0
  1420. package/ts3.4/es/api/form/PDFForm.d.ts +412 -0
  1421. package/ts3.4/es/api/form/PDFOptionList.d.ts +336 -0
  1422. package/ts3.4/es/api/form/PDFRadioGroup.d.ts +253 -0
  1423. package/ts3.4/es/api/form/PDFSignature.d.ts +30 -0
  1424. package/ts3.4/es/api/form/PDFTextField.d.ts +538 -0
  1425. package/ts3.4/es/api/form/appearances.d.ts +42 -0
  1426. package/ts3.4/es/api/form/index.d.ts +11 -0
  1427. package/ts3.4/es/api/image/alignment.d.ts +6 -0
  1428. package/ts3.4/es/api/image/index.d.ts +2 -0
  1429. package/ts3.4/es/api/index.d.ts +21 -0
  1430. package/ts3.4/es/api/objects.d.ts +5 -0
  1431. package/ts3.4/es/api/operations.d.ts +212 -0
  1432. package/ts3.4/es/api/operators.d.ts +86 -0
  1433. package/ts3.4/es/api/rotations.d.ts +39 -0
  1434. package/ts3.4/es/api/sizes.d.ts +53 -0
  1435. package/ts3.4/es/api/svgPath.d.ts +3 -0
  1436. package/ts3.4/es/api/text/alignment.d.ts +6 -0
  1437. package/ts3.4/es/api/text/index.d.ts +3 -0
  1438. package/ts3.4/es/api/text/layout.d.ts +55 -0
  1439. package/ts3.4/es/core/PDFContext.d.ts +84 -0
  1440. package/ts3.4/es/core/PDFObjectCopier.d.ts +38 -0
  1441. package/ts3.4/es/core/acroform/PDFAcroButton.d.ts +22 -0
  1442. package/ts3.4/es/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  1443. package/ts3.4/es/core/acroform/PDFAcroChoice.d.ts +21 -0
  1444. package/ts3.4/es/core/acroform/PDFAcroComboBox.d.ts +10 -0
  1445. package/ts3.4/es/core/acroform/PDFAcroField.d.ts +37 -0
  1446. package/ts3.4/es/core/acroform/PDFAcroForm.d.ts +21 -0
  1447. package/ts3.4/es/core/acroform/PDFAcroListBox.d.ts +10 -0
  1448. package/ts3.4/es/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  1449. package/ts3.4/es/core/acroform/PDFAcroPushButton.d.ts +10 -0
  1450. package/ts3.4/es/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  1451. package/ts3.4/es/core/acroform/PDFAcroSignature.d.ts +8 -0
  1452. package/ts3.4/es/core/acroform/PDFAcroTerminal.d.ts +17 -0
  1453. package/ts3.4/es/core/acroform/PDFAcroText.d.ts +23 -0
  1454. package/ts3.4/es/core/acroform/flags.d.ts +142 -0
  1455. package/ts3.4/es/core/acroform/index.d.ts +16 -0
  1456. package/ts3.4/es/core/acroform/utils.d.ts +7 -0
  1457. package/ts3.4/es/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  1458. package/ts3.4/es/core/annotation/BorderStyle.d.ts +12 -0
  1459. package/ts3.4/es/core/annotation/PDFAnnotation.d.ts +52 -0
  1460. package/ts3.4/es/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  1461. package/ts3.4/es/core/annotation/flags.d.ts +80 -0
  1462. package/ts3.4/es/core/annotation/index.d.ts +5 -0
  1463. package/ts3.4/es/core/document/PDFCrossRefSection.d.ts +28 -0
  1464. package/ts3.4/es/core/document/PDFHeader.d.ts +11 -0
  1465. package/ts3.4/es/core/document/PDFTrailer.d.ts +10 -0
  1466. package/ts3.4/es/core/document/PDFTrailerDict.d.ts +11 -0
  1467. package/ts3.4/es/core/embedders/CMap.d.ts +4 -0
  1468. package/ts3.4/es/core/embedders/CustomFontEmbedder.d.ts +45 -0
  1469. package/ts3.4/es/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  1470. package/ts3.4/es/core/embedders/FileEmbedder.d.ts +34 -0
  1471. package/ts3.4/es/core/embedders/FontFlags.d.ts +14 -0
  1472. package/ts3.4/es/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  1473. package/ts3.4/es/core/embedders/JpegEmbedder.d.ts +24 -0
  1474. package/ts3.4/es/core/embedders/PDFPageEmbedder.d.ts +38 -0
  1475. package/ts3.4/es/core/embedders/PngEmbedder.d.ts +20 -0
  1476. package/ts3.4/es/core/embedders/StandardFontEmbedder.d.ts +37 -0
  1477. package/ts3.4/es/core/errors.d.ts +92 -0
  1478. package/ts3.4/es/core/index.d.ts +48 -0
  1479. package/ts3.4/es/core/interactive/ViewerPreferences.d.ts +348 -0
  1480. package/ts3.4/es/core/objects/PDFArray.d.ts +64 -0
  1481. package/ts3.4/es/core/objects/PDFBool.d.ts +14 -0
  1482. package/ts3.4/es/core/objects/PDFDict.d.ts +62 -0
  1483. package/ts3.4/es/core/objects/PDFHexString.d.ts +17 -0
  1484. package/ts3.4/es/core/objects/PDFInvalidObject.d.ts +12 -0
  1485. package/ts3.4/es/core/objects/PDFName.d.ts +42 -0
  1486. package/ts3.4/es/core/objects/PDFNull.d.ts +11 -0
  1487. package/ts3.4/es/core/objects/PDFNumber.d.ts +16 -0
  1488. package/ts3.4/es/core/objects/PDFObject.d.ts +9 -0
  1489. package/ts3.4/es/core/objects/PDFRawStream.d.ts +15 -0
  1490. package/ts3.4/es/core/objects/PDFRef.d.ts +14 -0
  1491. package/ts3.4/es/core/objects/PDFStream.d.ts +17 -0
  1492. package/ts3.4/es/core/objects/PDFString.d.ts +17 -0
  1493. package/ts3.4/es/core/operators/PDFOperator.d.ts +20 -0
  1494. package/ts3.4/es/core/operators/PDFOperatorNames.d.ts +77 -0
  1495. package/ts3.4/es/core/parser/BaseParser.d.ts +15 -0
  1496. package/ts3.4/es/core/parser/ByteStream.d.ts +27 -0
  1497. package/ts3.4/es/core/parser/PDFObjectParser.d.ts +30 -0
  1498. package/ts3.4/es/core/parser/PDFObjectStreamParser.d.ts +14 -0
  1499. package/ts3.4/es/core/parser/PDFParser.d.ts +46 -0
  1500. package/ts3.4/es/core/parser/PDFXRefStreamParser.d.ts +22 -0
  1501. package/ts3.4/es/core/streams/Ascii85Stream.d.ts +10 -0
  1502. package/ts3.4/es/core/streams/AsciiHexStream.d.ts +10 -0
  1503. package/ts3.4/es/core/streams/DecodeStream.d.ts +28 -0
  1504. package/ts3.4/es/core/streams/FlateStream.d.ts +14 -0
  1505. package/ts3.4/es/core/streams/LZWStream.d.ts +13 -0
  1506. package/ts3.4/es/core/streams/RunLengthStream.d.ts +9 -0
  1507. package/ts3.4/es/core/streams/Stream.d.ts +35 -0
  1508. package/ts3.4/es/core/streams/decode.d.ts +4 -0
  1509. package/ts3.4/es/core/structures/PDFCatalog.d.ts +28 -0
  1510. package/ts3.4/es/core/structures/PDFContentStream.d.ts +16 -0
  1511. package/ts3.4/es/core/structures/PDFCrossRefStream.d.ts +54 -0
  1512. package/ts3.4/es/core/structures/PDFFlateStream.d.ts +14 -0
  1513. package/ts3.4/es/core/structures/PDFObjectStream.d.ts +21 -0
  1514. package/ts3.4/es/core/structures/PDFPageLeaf.d.ts +55 -0
  1515. package/ts3.4/es/core/structures/PDFPageTree.d.ts +42 -0
  1516. package/ts3.4/es/core/syntax/CharCodes.d.ts +62 -0
  1517. package/ts3.4/es/core/syntax/Delimiters.d.ts +2 -0
  1518. package/ts3.4/es/core/syntax/Irregular.d.ts +2 -0
  1519. package/ts3.4/es/core/syntax/Keywords.d.ts +23 -0
  1520. package/ts3.4/es/core/syntax/Numeric.d.ts +4 -0
  1521. package/ts3.4/es/core/syntax/Whitespace.d.ts +2 -0
  1522. package/ts3.4/es/core/writers/PDFStreamWriter.d.ts +20 -0
  1523. package/ts3.4/es/core/writers/PDFWriter.d.ts +30 -0
  1524. package/ts3.4/es/index.d.ts +5 -0
  1525. package/ts3.4/es/types/fontkit.d.ts +582 -0
  1526. package/ts3.4/es/types/index.d.ts +2 -0
  1527. package/ts3.4/es/types/matrix.d.ts +22 -0
  1528. package/ts3.4/es/utils/Cache.d.ts +11 -0
  1529. package/ts3.4/es/utils/arrays.d.ts +16 -0
  1530. package/ts3.4/es/utils/async.d.ts +6 -0
  1531. package/ts3.4/es/utils/base64.d.ts +11 -0
  1532. package/ts3.4/es/utils/errors.d.ts +2 -0
  1533. package/ts3.4/es/utils/index.d.ts +12 -0
  1534. package/ts3.4/es/utils/numbers.d.ts +24 -0
  1535. package/ts3.4/es/utils/objects.d.ts +16 -0
  1536. package/ts3.4/es/utils/pdfDocEncoding.d.ts +8 -0
  1537. package/ts3.4/es/utils/png.d.ts +18 -0
  1538. package/ts3.4/es/utils/rng.d.ts +14 -0
  1539. package/ts3.4/es/utils/strings.d.ts +25 -0
  1540. package/ts3.4/es/utils/unicode.d.ts +187 -0
  1541. package/ts3.4/es/utils/validators.d.ts +27 -0
package/README.md CHANGED
@@ -1,3 +1,1529 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus"><img src="https://raw.githubusercontent.com/Hopding/pdf-lib-docs/master/assets/logo-full.svg?sanitize=true" height="150" alt="pdf-lib-plus"></a>
3
+ </p>
2
4
 
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.
5
+ <p align="center">
6
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus"><img src="https://img.shields.io/badge/pdf--lib--plus-%E7%A4%BE%E5%8C%BA%E7%BB%B4%E6%8A%A4%E5%88%86%E6%94%AF-8a7bff?style=for-the-badge&logo=github&logoColor=white" alt="pdf-lib-plus: 社区维护分支"></a>
7
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/blob/master/README.md"><img src="https://img.shields.io/badge/TypeScript-3.9-14181A?style=for-the-badge&logo=typescript&logoColor=3178C6" alt="TypeScript: 3.9"></a>
8
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/blob/master/README.md"><img src="https://img.shields.io/badge/MIT-%E8%AE%B8%E5%8F%AF%E4%B8%8D%E5%8F%98-14181A?style=for-the-badge&logo=open-source-initiative&logoColor=3DDC84" alt="MIT: 许可不变"></a>
9
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/blob/master/README.md"><img src="https://img.shields.io/badge/tests-654-14181A?style=for-the-badge&logo=jest&logoColor=C21325" alt="tests: 654"></a>
10
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/blob/master/README.md"><img src="https://img.shields.io/badge/docs-%E4%B8%AD%E6%96%87_%2F_EN-14181A?style=for-the-badge&logo=gitbook&logoColor=2088FF" alt="docs: 中文 / EN"></a>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/codecloud-dev/pdf-lib-plus/ci.yml?branch=master&style=flat-square&label=CI" alt="CI"></a>
15
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/blob/master/LICENSE.md"><img src="https://img.shields.io/github/license/codecloud-dev/pdf-lib-plus?style=flat-square&color=37d5d3" alt="License"></a>
16
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/stargazers"><img src="https://img.shields.io/github/stars/codecloud-dev/pdf-lib-plus?style=flat-square&color=ff7ac3" alt="Stars"></a>
17
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/commits/master"><img src="https://img.shields.io/github/last-commit/codecloud-dev/pdf-lib-plus?style=flat-square&color=8a7bff" alt="Last commit"></a>
18
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus"><img src="https://img.shields.io/badge/tests-654_passed-3DDC84?style=flat-square" alt="tests: 654 passed"></a>
19
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus"><img src="https://img.shields.io/badge/since-upstream_2022-ff7ac3?style=flat-square" alt="since: upstream 2022"></a>
20
+ <a href="https://github.com/codecloud-dev/pdf-lib-plus/pulls"><img src="https://img.shields.io/badge/PRs-welcome-8a7bff?style=flat-square&logo=github&logoColor=white" alt="PRs welcome"></a>
21
+ </p>
22
+
23
+ <h1 align="center">pdf-lib-plus</h1>
24
+
25
+ <p align="center"><b>pdf-lib 的社区维护分支 · Community-maintained fork of pdf-lib</b><br>
26
+ 公开 API 不变 · MIT 许可不变 · 先把上游遗留的安全问题修掉<br>
27
+ <em>Same public API, same MIT license — upstream security issues, actually fixed.</em></p>
28
+
29
+ <p align="center">
30
+ <a href="README.md">中文 / EN</a> ·
31
+ <a href="README.zh.md">📖 完整中文说明</a> ·
32
+ <a href="CHANGELOG.md">更新日志</a> ·
33
+ <a href="SECURITY.md">安全政策</a> ·
34
+ <a href="CONTRIBUTING.md">贡献指南</a>
35
+ </p>
36
+
37
+ ---
38
+
39
+ ## 🇨🇳 三分钟看懂(中文导读)
40
+
41
+ > 上游 [pdf-lib](https://github.com/Hopding/pdf-lib) 自 2022 年起没有再发布版本,
42
+ > 一批被报告过的解析 / 解码安全问题一直停在 issue 和 PR 里没进发行版。
43
+ > **pdf-lib-plus** 就是为这件事存在的:保持公开 API 与 MIT 许可**完全不变**,
44
+ > 把那些修复真正合进代码、配上回归测试、跑完 654 个用例再发版。
45
+
46
+ | 你关心什么 | 答案 |
47
+ | --- | --- |
48
+ | 老项目要改代码吗 | **几乎不用**。公开 API 与 `pdf-lib` 完全一致,只把包名换成 `@codecloud-dev/pdf-lib-plus` |
49
+ | 修了什么 | 日期解析 ReDoS、JPEG marker 越界/死循环、xref `/W` 宽度、解码流解压炸弹,以及本轮新增的 SVG / JPEG 视图 / Error 原型链等修复,见 [CHANGELOG.md](CHANGELOG.md) |
50
+ | 测试覆盖 | 69 套件 / **654 用例**,`typecheck` + `test` + 全格式 `build` 全绿 |
51
+ | 中文文档 | [README.zh.md](README.zh.md) 有完整的中文安装、示例与工具链说明 |
52
+ | 许可证 | MIT,保留原作者全部版权声明 |
53
+
54
+ **安装 / Install**
55
+
56
+ ```bash
57
+ npm install @codecloud-dev/pdf-lib-plus # 或 yarn add @codecloud-dev/pdf-lib-plus
58
+ ```
59
+
60
+ ```js
61
+ import { PDFDocument, StandardFonts, rgb } from '@codecloud-dev/pdf-lib-plus';
62
+ const doc = await PDFDocument.create();
63
+ const page = doc.addPage([550, 750]);
64
+ page.drawText('Hello PDF', { x: 50, y: 700, size: 30, color: rgb(0, 0.15, 0.35) });
65
+ const bytes = await doc.save();
66
+ ```
67
+
68
+ > 中文字符需自行嵌入 CJK 字体(标准 14 字体不含中文字形),这是 pdf-lib 原有行为,本分支未改。
69
+ > 完整 API 文档、表单 / 图片 / 附件 / 加密等示例见下方英文正文。
70
+
71
+ > **Docs / 文档**:[中文说明 README.zh.md](README.zh.md) · [Contributing](CONTRIBUTING.md) ·
72
+ > [Code of Conduct](CODE_OF_CONDUCT.md) · [Security Policy](SECURITY.md)
73
+
74
+ ---
75
+
76
+ ## Table of Contents
77
+
78
+ - [Features](#features)
79
+ - [Motivation](#motivation)
80
+ - [Usage Examples](#usage-examples)
81
+ - [Create Document](#create-document)
82
+ - [Modify Document](#modify-document)
83
+ - [Create Form](#create-form)
84
+ - [Fill Form](#fill-form)
85
+ - [Flatten Form](#flatten-form)
86
+ - [Copy Pages](#copy-pages)
87
+ - [Embed PNG and JPEG Images](#embed-png-and-jpeg-images)
88
+ - [Embed PDF Pages](#embed-pdf-pages)
89
+ - [Embed Font and Measure Text](#embed-font-and-measure-text)
90
+ - [Add Attachments](#add-attachments)
91
+ - [Set Document Metadata](#set-document-metadata)
92
+ - [Read Document Metadata](#read-document-metadata)
93
+ - [Set Viewer Preferences](#set-viewer-preferences)
94
+ - [Read Viewer Preferences](#read-viewer-preferences)
95
+ - [Draw SVG Paths](#draw-svg-paths)
96
+ - [Deno Usage](#deno-usage)
97
+ - [Complete Examples](#complete-examples)
98
+ - [Installation](#installation)
99
+ - [Documentation](#documentation)
100
+ - [Fonts and Unicode](#fonts-and-unicode)
101
+ - [Creating and Filling Forms](#creating-and-filling-forms)
102
+ - [Limitations](#limitations)
103
+ - [Help and Discussion](#help-and-discussion)
104
+ - [Encryption Handling](#encryption-handling)
105
+ - [Migrating to v1.0.0](docs/MIGRATION.md)
106
+ - [Contributing](#contributing)
107
+ - [Maintainership](#maintainership)
108
+ - [Tutorials and Cool Stuff](#tutorials-and-cool-stuff)
109
+ - [Prior Art](#prior-art)
110
+ - [Git History Rewrite](#git-history-rewrite)
111
+ - [License](#license)
112
+
113
+ ## Features
114
+
115
+ - Create new PDFs
116
+ - Modify existing PDFs
117
+ - Create forms
118
+ - Fill forms
119
+ - Flatten forms
120
+ - Add Pages
121
+ - Insert Pages
122
+ - Remove Pages
123
+ - Copy pages between PDFs
124
+ - Draw Text
125
+ - Draw Images
126
+ - Draw PDF Pages
127
+ - Draw Vector Graphics
128
+ - Draw SVG Paths
129
+ - Measure width and height of text
130
+ - Embed Fonts (supports UTF-8 and UTF-16 character sets)
131
+ - Set document metadata
132
+ - Read document metadata
133
+ - Set viewer preferences
134
+ - Read viewer preferences
135
+ - Add attachments
136
+
137
+ ## Motivation
138
+
139
+ `pdf-lib` was created to address the JavaScript ecosystem's lack of robust support for PDF manipulation (especially for PDF _modification_).
140
+
141
+ Two of `pdf-lib`'s distinguishing features are:
142
+
143
+ 1. Supporting modification (editing) of existing documents.
144
+ 2. Working in all JavaScript environments - not just in Node or the Browser.
145
+
146
+ There are [other](#prior-art) good open source JavaScript PDF libraries available. However, most of them can only _create_ documents, they cannot _modify_ existing ones. And many of them only work in particular environments.
147
+
148
+ ## Usage Examples
149
+
150
+ ### Create Document
151
+
152
+ _This example produces [this PDF](assets/pdfs/examples/create_document.pdf)._
153
+
154
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/rxwsc8f5/13/)
155
+
156
+ <!-- prettier-ignore -->
157
+ ```js
158
+ import { PDFDocument, StandardFonts, rgb } from 'pdf-lib'
159
+
160
+ // Create a new PDFDocument
161
+ const pdfDoc = await PDFDocument.create()
162
+
163
+ // Embed the Times Roman font
164
+ const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
165
+
166
+ // Add a blank page to the document
167
+ const page = pdfDoc.addPage()
168
+
169
+ // Get the width and height of the page
170
+ const { width, height } = page.getSize()
171
+
172
+ // Draw a string of text toward the top of the page
173
+ const fontSize = 30
174
+ page.drawText('Creating PDFs in JavaScript is awesome!', {
175
+ x: 50,
176
+ y: height - 4 * fontSize,
177
+ size: fontSize,
178
+ font: timesRomanFont,
179
+ color: rgb(0, 0.53, 0.71),
180
+ })
181
+
182
+ // Serialize the PDFDocument to bytes (a Uint8Array)
183
+ const pdfBytes = await pdfDoc.save()
184
+
185
+ // For example, `pdfBytes` can be:
186
+ // • Written to a file in Node
187
+ // • Downloaded from the browser
188
+ // • Rendered in an <iframe>
189
+ ```
190
+
191
+ ### Modify Document
192
+
193
+ _This example produces [this PDF](assets/pdfs/examples/modify_document.pdf)_ (when [this PDF](assets/pdfs/with_update_sections.pdf) is used for the `existingPdfBytes` variable).
194
+
195
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/64zajhge/1/)
196
+
197
+ <!-- prettier-ignore -->
198
+ ```js
199
+ import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib';
200
+
201
+ // This should be a Uint8Array or ArrayBuffer
202
+ // This data can be obtained in a number of different ways
203
+ // If your running in a Node environment, you could use fs.readFile()
204
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
205
+ const existingPdfBytes = ...
206
+
207
+ // Load a PDFDocument from the existing PDF bytes
208
+ const pdfDoc = await PDFDocument.load(existingPdfBytes)
209
+
210
+ // Embed the Helvetica font
211
+ const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)
212
+
213
+ // Get the first page of the document
214
+ const pages = pdfDoc.getPages()
215
+ const firstPage = pages[0]
216
+
217
+ // Get the width and height of the first page
218
+ const { width, height } = firstPage.getSize()
219
+
220
+ // Draw a string of text diagonally across the first page
221
+ firstPage.drawText('This text was added with JavaScript!', {
222
+ x: 5,
223
+ y: height / 2 + 300,
224
+ size: 50,
225
+ font: helveticaFont,
226
+ color: rgb(0.95, 0.1, 0.1),
227
+ rotate: degrees(-45),
228
+ })
229
+
230
+
231
+ // Serialize the PDFDocument to bytes (a Uint8Array)
232
+ const pdfBytes = await pdfDoc.save()
233
+
234
+ // For example, `pdfBytes` can be:
235
+ // • Written to a file in Node
236
+ // • Downloaded from the browser
237
+ // • Rendered in an <iframe>
238
+ ```
239
+
240
+ ### Create Form
241
+
242
+ _This example produces [this PDF](assets/pdfs/examples/create_form.pdf)._
243
+
244
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/bct7vngL/4/)
245
+
246
+ > See also [Creating and Filling Forms](#creating-and-filling-forms)
247
+
248
+ <!-- prettier-ignore -->
249
+ ```js
250
+ import { PDFDocument } from 'pdf-lib'
251
+
252
+ // Create a new PDFDocument
253
+ const pdfDoc = await PDFDocument.create()
254
+
255
+ // Add a blank page to the document
256
+ const page = pdfDoc.addPage([550, 750])
257
+
258
+ // Get the form so we can add fields to it
259
+ const form = pdfDoc.getForm()
260
+
261
+ // Add the superhero text field and description
262
+ page.drawText('Enter your favorite superhero:', { x: 50, y: 700, size: 20 })
263
+
264
+ const superheroField = form.createTextField('favorite.superhero')
265
+ superheroField.setText('One Punch Man')
266
+ superheroField.addToPage(page, { x: 55, y: 640 })
267
+
268
+ // Add the rocket radio group, labels, and description
269
+ page.drawText('Select your favorite rocket:', { x: 50, y: 600, size: 20 })
270
+
271
+ page.drawText('Falcon Heavy', { x: 120, y: 560, size: 18 })
272
+ page.drawText('Saturn IV', { x: 120, y: 500, size: 18 })
273
+ page.drawText('Delta IV Heavy', { x: 340, y: 560, size: 18 })
274
+ page.drawText('Space Launch System', { x: 340, y: 500, size: 18 })
275
+
276
+ const rocketField = form.createRadioGroup('favorite.rocket')
277
+ rocketField.addOptionToPage('Falcon Heavy', page, { x: 55, y: 540 })
278
+ rocketField.addOptionToPage('Saturn IV', page, { x: 55, y: 480 })
279
+ rocketField.addOptionToPage('Delta IV Heavy', page, { x: 275, y: 540 })
280
+ rocketField.addOptionToPage('Space Launch System', page, { x: 275, y: 480 })
281
+ rocketField.select('Saturn IV')
282
+
283
+ // Add the gundam check boxes, labels, and description
284
+ page.drawText('Select your favorite gundams:', { x: 50, y: 440, size: 20 })
285
+
286
+ page.drawText('Exia', { x: 120, y: 400, size: 18 })
287
+ page.drawText('Kyrios', { x: 120, y: 340, size: 18 })
288
+ page.drawText('Virtue', { x: 340, y: 400, size: 18 })
289
+ page.drawText('Dynames', { x: 340, y: 340, size: 18 })
290
+
291
+ const exiaField = form.createCheckBox('gundam.exia')
292
+ const kyriosField = form.createCheckBox('gundam.kyrios')
293
+ const virtueField = form.createCheckBox('gundam.virtue')
294
+ const dynamesField = form.createCheckBox('gundam.dynames')
295
+
296
+ exiaField.addToPage(page, { x: 55, y: 380 })
297
+ kyriosField.addToPage(page, { x: 55, y: 320 })
298
+ virtueField.addToPage(page, { x: 275, y: 380 })
299
+ dynamesField.addToPage(page, { x: 275, y: 320 })
300
+
301
+ exiaField.check()
302
+ dynamesField.check()
303
+
304
+ // Add the planet dropdown and description
305
+ page.drawText('Select your favorite planet*:', { x: 50, y: 280, size: 20 })
306
+
307
+ const planetsField = form.createDropdown('favorite.planet')
308
+ planetsField.addOptions(['Venus', 'Earth', 'Mars', 'Pluto'])
309
+ planetsField.select('Pluto')
310
+ planetsField.addToPage(page, { x: 55, y: 220 })
311
+
312
+ // Add the person option list and description
313
+ page.drawText('Select your favorite person:', { x: 50, y: 180, size: 18 })
314
+
315
+ const personField = form.createOptionList('favorite.person')
316
+ personField.addOptions([
317
+ 'Julius Caesar',
318
+ 'Ada Lovelace',
319
+ 'Cleopatra',
320
+ 'Aaron Burr',
321
+ 'Mark Antony',
322
+ ])
323
+ personField.select('Ada Lovelace')
324
+ personField.addToPage(page, { x: 55, y: 70 })
325
+
326
+ // Just saying...
327
+ page.drawText(`* Pluto should be a planet too!`, { x: 15, y: 15, size: 15 })
328
+
329
+ // Serialize the PDFDocument to bytes (a Uint8Array)
330
+ const pdfBytes = await pdfDoc.save()
331
+
332
+ // For example, `pdfBytes` can be:
333
+ // • Written to a file in Node
334
+ // • Downloaded from the browser
335
+ // • Rendered in an <iframe>
336
+ ```
337
+
338
+ ### Fill Form
339
+
340
+ _This example produces [this PDF](assets/pdfs/examples/fill_form.pdf)_ (when [this PDF](assets/pdfs/dod_character.pdf) is used for the `formPdfBytes` variable, [this image](assets/images/small_mario.png) is used for the `marioImageBytes` variable, and [this image](assets/images/mario_emblem.png) is used for the `emblemImageBytes` variable).
341
+
342
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/0mwfqkv6/3/)
343
+
344
+ > See also [Creating and Filling Forms](#creating-and-filling-forms)
345
+
346
+ <!-- prettier-ignore -->
347
+ ```js
348
+ import { PDFDocument } from 'pdf-lib'
349
+
350
+ // These should be Uint8Arrays or ArrayBuffers
351
+ // This data can be obtained in a number of different ways
352
+ // If your running in a Node environment, you could use fs.readFile()
353
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
354
+ const formPdfBytes = ...
355
+ const marioImageBytes = ...
356
+ const emblemImageBytes = ...
357
+
358
+ // Load a PDF with form fields
359
+ const pdfDoc = await PDFDocument.load(formPdfBytes)
360
+
361
+ // Embed the Mario and emblem images
362
+ const marioImage = await pdfDoc.embedPng(marioImageBytes)
363
+ const emblemImage = await pdfDoc.embedPng(emblemImageBytes)
364
+
365
+ // Get the form containing all the fields
366
+ const form = pdfDoc.getForm()
367
+
368
+ // Get all fields in the PDF by their names
369
+ const nameField = form.getTextField('CharacterName 2')
370
+ const ageField = form.getTextField('Age')
371
+ const heightField = form.getTextField('Height')
372
+ const weightField = form.getTextField('Weight')
373
+ const eyesField = form.getTextField('Eyes')
374
+ const skinField = form.getTextField('Skin')
375
+ const hairField = form.getTextField('Hair')
376
+
377
+ const alliesField = form.getTextField('Allies')
378
+ const factionField = form.getTextField('FactionName')
379
+ const backstoryField = form.getTextField('Backstory')
380
+ const traitsField = form.getTextField('Feat+Traits')
381
+ const treasureField = form.getTextField('Treasure')
382
+
383
+ const characterImageField = form.getButton('CHARACTER IMAGE')
384
+ const factionImageField = form.getTextField('Faction Symbol Image')
385
+
386
+ // Fill in the basic info fields
387
+ nameField.setText('Mario')
388
+ ageField.setText('24 years')
389
+ heightField.setText(`5' 1"`)
390
+ weightField.setText('196 lbs')
391
+ eyesField.setText('blue')
392
+ skinField.setText('white')
393
+ hairField.setText('brown')
394
+
395
+ // Fill the character image field with our Mario image
396
+ characterImageField.setImage(marioImage)
397
+
398
+ // Fill in the allies field
399
+ alliesField.setText(
400
+ [
401
+ `Allies:`,
402
+ ` • Princess Daisy`,
403
+ ` • Princess Peach`,
404
+ ` • Rosalina`,
405
+ ` • Geno`,
406
+ ` • Luigi`,
407
+ ` • Donkey Kong`,
408
+ ` • Yoshi`,
409
+ ` • Diddy Kong`,
410
+ ``,
411
+ `Organizations:`,
412
+ ` • Italian Plumbers Association`,
413
+ ].join('\n'),
414
+ )
415
+
416
+ // Fill in the faction name field
417
+ factionField.setText(`Mario's Emblem`)
418
+
419
+ // Fill the faction image field with our emblem image
420
+ factionImageField.setImage(emblemImage)
421
+
422
+ // Fill in the backstory field
423
+ backstoryField.setText(
424
+ `Mario is a fictional character in the Mario video game franchise, owned by Nintendo and created by Japanese video game designer Shigeru Miyamoto. Serving as the company's mascot and the eponymous protagonist of the series, Mario has appeared in over 200 video games since his creation. Depicted as a short, pudgy, Italian plumber who resides in the Mushroom Kingdom, his adventures generally center upon rescuing Princess Peach from the Koopa villain Bowser. His younger brother and sidekick is Luigi.`,
425
+ )
426
+
427
+ // Fill in the traits field
428
+ traitsField.setText(
429
+ [
430
+ `Mario can use three basic three power-ups:`,
431
+ ` • the Super Mushroom, which causes Mario to grow larger`,
432
+ ` • the Fire Flower, which allows Mario to throw fireballs`,
433
+ ` • the Starman, which gives Mario temporary invincibility`,
434
+ ].join('\n'),
435
+ )
436
+
437
+ // Fill in the treasure field
438
+ treasureField.setText(['• Gold coins', '• Treasure chests'].join('\n'))
439
+
440
+ // Serialize the PDFDocument to bytes (a Uint8Array)
441
+ const pdfBytes = await pdfDoc.save()
442
+
443
+ // For example, `pdfBytes` can be:
444
+ // • Written to a file in Node
445
+ // • Downloaded from the browser
446
+ // • Rendered in an <iframe>
447
+ ```
448
+
449
+ ### Flatten Form
450
+
451
+ _This example produces [this PDF](assets/pdfs/examples/flatten_form.pdf)_ (when [this PDF](assets/pdfs/form_to_flatten.pdf) is used for the `formPdfBytes` variable).
452
+
453
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/skevywdz/2/)
454
+
455
+ <!-- prettier-ignore -->
456
+ ```js
457
+ import { PDFDocument } from 'pdf-lib'
458
+
459
+ // This should be a Uint8Array or ArrayBuffer
460
+ // This data can be obtained in a number of different ways
461
+ // If your running in a Node environment, you could use fs.readFile()
462
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
463
+ const formPdfBytes = ...
464
+
465
+ // Load a PDF with form fields
466
+ const pdfDoc = await PDFDocument.load(formPdfBytes)
467
+
468
+ // Get the form containing all the fields
469
+ const form = pdfDoc.getForm()
470
+
471
+ // Fill the form's fields
472
+ form.getTextField('Text1').setText('Some Text');
473
+
474
+ form.getRadioGroup('Group2').select('Choice1');
475
+ form.getRadioGroup('Group3').select('Choice3');
476
+ form.getRadioGroup('Group4').select('Choice1');
477
+
478
+ form.getCheckBox('Check Box3').check();
479
+ form.getCheckBox('Check Box4').uncheck();
480
+
481
+ form.getDropdown('Dropdown7').select('Infinity');
482
+
483
+ form.getOptionList('List Box6').select('Honda');
484
+
485
+ // Flatten the form's fields
486
+ form.flatten();
487
+
488
+ // Serialize the PDFDocument to bytes (a Uint8Array)
489
+ const pdfBytes = await pdfDoc.save()
490
+
491
+ // For example, `pdfBytes` can be:
492
+ // • Written to a file in Node
493
+ // • Downloaded from the browser
494
+ // • Rendered in an <iframe>
495
+ ```
496
+
497
+ ### Copy Pages
498
+
499
+ _This example produces [this PDF](assets/pdfs/examples/copy_pages.pdf)_ (when [this PDF](assets/pdfs/with_update_sections.pdf) is used for the `firstDonorPdfBytes` variable and [this PDF](assets/pdfs/with_large_page_count.pdf) is used for the `secondDonorPdfBytes` variable).
500
+
501
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/ybank8s9/2/)
502
+
503
+ <!-- prettier-ignore -->
504
+ ```js
505
+ import { PDFDocument } from 'pdf-lib'
506
+
507
+ // Create a new PDFDocument
508
+ const pdfDoc = await PDFDocument.create()
509
+
510
+ // These should be Uint8Arrays or ArrayBuffers
511
+ // This data can be obtained in a number of different ways
512
+ // If your running in a Node environment, you could use fs.readFile()
513
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
514
+ const firstDonorPdfBytes = ...
515
+ const secondDonorPdfBytes = ...
516
+
517
+ // Load a PDFDocument from each of the existing PDFs
518
+ const firstDonorPdfDoc = await PDFDocument.load(firstDonorPdfBytes)
519
+ const secondDonorPdfDoc = await PDFDocument.load(secondDonorPdfBytes)
520
+
521
+ // Copy the 1st page from the first donor document, and
522
+ // the 743rd page from the second donor document
523
+ const [firstDonorPage] = await pdfDoc.copyPages(firstDonorPdfDoc, [0])
524
+ const [secondDonorPage] = await pdfDoc.copyPages(secondDonorPdfDoc, [742])
525
+
526
+ // Add the first copied page
527
+ pdfDoc.addPage(firstDonorPage)
528
+
529
+ // Insert the second copied page to index 0, so it will be the
530
+ // first page in `pdfDoc`
531
+ pdfDoc.insertPage(0, secondDonorPage)
532
+
533
+ // Serialize the PDFDocument to bytes (a Uint8Array)
534
+ const pdfBytes = await pdfDoc.save()
535
+
536
+ // For example, `pdfBytes` can be:
537
+ // • Written to a file in Node
538
+ // • Downloaded from the browser
539
+ // • Rendered in an <iframe>
540
+ ```
541
+
542
+ ### Embed PNG and JPEG Images
543
+
544
+ _This example produces [this PDF](assets/pdfs/examples/embed_png_and_jpeg_images.pdf)_ (when [this image](assets/images/cat_riding_unicorn.jpg) is used for the `jpgImageBytes` variable and [this image](assets/images/minions_banana_alpha.png) is used for the `pngImageBytes` variable).
545
+
546
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/bcya43ju/5/)
547
+
548
+ <!-- prettier-ignore -->
549
+ ```js
550
+ import { PDFDocument } from 'pdf-lib'
551
+
552
+ // These should be Uint8Arrays or ArrayBuffers
553
+ // This data can be obtained in a number of different ways
554
+ // If your running in a Node environment, you could use fs.readFile()
555
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
556
+ const jpgImageBytes = ...
557
+ const pngImageBytes = ...
558
+
559
+ // Create a new PDFDocument
560
+ const pdfDoc = await PDFDocument.create()
561
+
562
+ // Embed the JPG image bytes and PNG image bytes
563
+ const jpgImage = await pdfDoc.embedJpg(jpgImageBytes)
564
+ const pngImage = await pdfDoc.embedPng(pngImageBytes)
565
+
566
+ // Get the width/height of the JPG image scaled down to 25% of its original size
567
+ const jpgDims = jpgImage.scale(0.25)
568
+
569
+ // Get the width/height of the PNG image scaled down to 50% of its original size
570
+ const pngDims = pngImage.scale(0.5)
571
+
572
+ // Add a blank page to the document
573
+ const page = pdfDoc.addPage()
574
+
575
+ // Draw the JPG image in the center of the page
576
+ page.drawImage(jpgImage, {
577
+ x: page.getWidth() / 2 - jpgDims.width / 2,
578
+ y: page.getHeight() / 2 - jpgDims.height / 2,
579
+ width: jpgDims.width,
580
+ height: jpgDims.height,
581
+ })
582
+
583
+ // Draw the PNG image near the lower right corner of the JPG image
584
+ page.drawImage(pngImage, {
585
+ x: page.getWidth() / 2 - pngDims.width / 2 + 75,
586
+ y: page.getHeight() / 2 - pngDims.height,
587
+ width: pngDims.width,
588
+ height: pngDims.height,
589
+ })
590
+
591
+ // Serialize the PDFDocument to bytes (a Uint8Array)
592
+ const pdfBytes = await pdfDoc.save()
593
+
594
+ // For example, `pdfBytes` can be:
595
+ // • Written to a file in Node
596
+ // • Downloaded from the browser
597
+ // • Rendered in an <iframe>
598
+ ```
599
+
600
+ ### Embed PDF Pages
601
+
602
+ _This example produces [this PDF](assets/pdfs/examples/embed_pdf_pages.pdf)_ (when [this PDF](assets/pdfs/american_flag.pdf) is used for the `americanFlagPdfBytes` variable and [this PDF](assets/pdfs/us_constitution.pdf) is used for the `usConstitutionPdfBytes` variable).
603
+
604
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/Lyb16ocj/13/)
605
+
606
+ <!-- prettier-ignore -->
607
+ ```js
608
+ import { PDFDocument } from 'pdf-lib'
609
+
610
+ // These should be Uint8Arrays or ArrayBuffers
611
+ // This data can be obtained in a number of different ways
612
+ // If your running in a Node environment, you could use fs.readFile()
613
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
614
+ const americanFlagPdfBytes = ...
615
+ const usConstitutionPdfBytes = ...
616
+
617
+ // Create a new PDFDocument
618
+ const pdfDoc = await PDFDocument.create()
619
+
620
+ // Embed the American flag PDF bytes
621
+ const [americanFlag] = await pdfDoc.embedPdf(americanFlagPdfBytes)
622
+
623
+ // Load the U.S. constitution PDF bytes
624
+ const usConstitutionPdf = await PDFDocument.load(usConstitutionPdfBytes)
625
+
626
+ // Embed the second page of the constitution and clip the preamble
627
+ const preamble = await pdfDoc.embedPage(usConstitutionPdf.getPages()[1], {
628
+ left: 55,
629
+ bottom: 485,
630
+ right: 300,
631
+ top: 575,
632
+ })
633
+
634
+ // Get the width/height of the American flag PDF scaled down to 30% of
635
+ // its original size
636
+ const americanFlagDims = americanFlag.scale(0.3)
637
+
638
+ // Get the width/height of the preamble clipping scaled up to 225% of
639
+ // its original size
640
+ const preambleDims = preamble.scale(2.25)
641
+
642
+ // Add a blank page to the document
643
+ const page = pdfDoc.addPage()
644
+
645
+ // Draw the American flag image in the center top of the page
646
+ page.drawPage(americanFlag, {
647
+ ...americanFlagDims,
648
+ x: page.getWidth() / 2 - americanFlagDims.width / 2,
649
+ y: page.getHeight() - americanFlagDims.height - 150,
650
+ })
651
+
652
+ // Draw the preamble clipping in the center bottom of the page
653
+ page.drawPage(preamble, {
654
+ ...preambleDims,
655
+ x: page.getWidth() / 2 - preambleDims.width / 2,
656
+ y: page.getHeight() / 2 - preambleDims.height / 2 - 50,
657
+ })
658
+
659
+ // Serialize the PDFDocument to bytes (a Uint8Array)
660
+ const pdfBytes = await pdfDoc.save()
661
+
662
+ // For example, `pdfBytes` can be:
663
+ // • Written to a file in Node
664
+ // • Downloaded from the browser
665
+ // • Rendered in an <iframe>
666
+ ```
667
+
668
+ ### Embed Font and Measure Text
669
+
670
+ `pdf-lib` relies on a sister module to support embedding custom fonts: [`@pdf-lib/fontkit`](https://www.npmjs.com/package/@pdf-lib/fontkit). You must add the `@pdf-lib/fontkit` module to your project and register it using `pdfDoc.registerFontkit(...)` before embedding custom fonts.
671
+
672
+ > **[See below for detailed installation instructions on installing `@pdf-lib/fontkit` as a UMD or NPM module.](#fontkit-installation)**
673
+
674
+ _This example produces [this PDF](assets/pdfs/examples/embed_font_and_measure_text.pdf)_ (when [this font](assets/fonts/ubuntu/Ubuntu-R.ttf) is used for the `fontBytes` variable).
675
+
676
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/rgu6ca59/2/)
677
+
678
+ <!-- prettier-ignore -->
679
+ ```js
680
+ import { PDFDocument, rgb } from 'pdf-lib'
681
+ import fontkit from '@pdf-lib/fontkit'
682
+
683
+ // This should be a Uint8Array or ArrayBuffer
684
+ // This data can be obtained in a number of different ways
685
+ // If you're running in a Node environment, you could use fs.readFile()
686
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
687
+ const fontBytes = ...
688
+
689
+ // Create a new PDFDocument
690
+ const pdfDoc = await PDFDocument.create()
691
+
692
+ // Register the `fontkit` instance
693
+ pdfDoc.registerFontkit(fontkit)
694
+
695
+ // Embed our custom font in the document
696
+ const customFont = await pdfDoc.embedFont(fontBytes)
697
+
698
+ // Add a blank page to the document
699
+ const page = pdfDoc.addPage()
700
+
701
+ // Create a string of text and measure its width and height in our custom font
702
+ const text = 'This is text in an embedded font!'
703
+ const textSize = 35
704
+ const textWidth = customFont.widthOfTextAtSize(text, textSize)
705
+ const textHeight = customFont.heightAtSize(textSize)
706
+
707
+ // Draw the string of text on the page
708
+ page.drawText(text, {
709
+ x: 40,
710
+ y: 450,
711
+ size: textSize,
712
+ font: customFont,
713
+ color: rgb(0, 0.53, 0.71),
714
+ })
715
+
716
+ // Draw a box around the string of text
717
+ page.drawRectangle({
718
+ x: 40,
719
+ y: 450,
720
+ width: textWidth,
721
+ height: textHeight,
722
+ borderColor: rgb(1, 0, 0),
723
+ borderWidth: 1.5,
724
+ })
725
+
726
+ // Serialize the PDFDocument to bytes (a Uint8Array)
727
+ const pdfBytes = await pdfDoc.save()
728
+
729
+ // For example, `pdfBytes` can be:
730
+ // • Written to a file in Node
731
+ // • Downloaded from the browser
732
+ // • Rendered in an <iframe>
733
+ ```
734
+
735
+ ### Add Attachments
736
+
737
+ _This example produces [this PDF](assets/pdfs/examples/add_attachments.pdf)_ (when [this image](assets/images/cat_riding_unicorn.jpg) is used for the `jpgAttachmentBytes` variable and [this PDF](assets/pdfs/us_constitution.pdf) is used for the `pdfAttachmentBytes` variable).
738
+
739
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/9snL63wj/5/)
740
+
741
+ <!-- prettier-ignore -->
742
+ ```js
743
+ import { PDFDocument } from 'pdf-lib'
744
+
745
+ // These should be Uint8Arrays or ArrayBuffers
746
+ // This data can be obtained in a number of different ways
747
+ // If your running in a Node environment, you could use fs.readFile()
748
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
749
+ const jpgAttachmentBytes = ...
750
+ const pdfAttachmentBytes = ...
751
+
752
+ // Create a new PDFDocument
753
+ const pdfDoc = await PDFDocument.create()
754
+
755
+ // Add the JPG attachment
756
+ await pdfDoc.attach(jpgAttachmentBytes, 'cat_riding_unicorn.jpg', {
757
+ mimeType: 'image/jpeg',
758
+ description: 'Cool cat riding a unicorn! 🦄🐈🕶️',
759
+ creationDate: new Date('2019/12/01'),
760
+ modificationDate: new Date('2020/04/19'),
761
+ })
762
+
763
+ // Add the PDF attachment
764
+ await pdfDoc.attach(pdfAttachmentBytes, 'us_constitution.pdf', {
765
+ mimeType: 'application/pdf',
766
+ description: 'Constitution of the United States 🇺🇸🦅',
767
+ creationDate: new Date('1787/09/17'),
768
+ modificationDate: new Date('1992/05/07'),
769
+ })
770
+
771
+ // Add a page with some text
772
+ const page = pdfDoc.addPage();
773
+ page.drawText('This PDF has two attachments', { x: 135, y: 415 })
774
+
775
+ // Serialize the PDFDocument to bytes (a Uint8Array)
776
+ const pdfBytes = await pdfDoc.save()
777
+
778
+ // For example, `pdfBytes` can be:
779
+ // • Written to a file in Node
780
+ // • Downloaded from the browser
781
+ // • Rendered in an <iframe>
782
+ ```
783
+
784
+ ### Set Document Metadata
785
+
786
+ _This example produces [this PDF](assets/pdfs/examples/set_document_metadata.pdf)_.
787
+
788
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/vcwmfnbe/2/)
789
+
790
+ <!-- prettier-ignore -->
791
+ ```js
792
+ import { PDFDocument, StandardFonts } from 'pdf-lib'
793
+
794
+ // Create a new PDFDocument
795
+ const pdfDoc = await PDFDocument.create()
796
+
797
+ // Embed the Times Roman font
798
+ const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
799
+
800
+ // Add a page and draw some text on it
801
+ const page = pdfDoc.addPage([500, 600])
802
+ page.setFont(timesRomanFont)
803
+ page.drawText('The Life of an Egg', { x: 60, y: 500, size: 50 })
804
+ page.drawText('An Epic Tale of Woe', { x: 125, y: 460, size: 25 })
805
+
806
+ // Set all available metadata fields on the PDFDocument. Note that these fields
807
+ // are visible in the "Document Properties" section of most PDF readers.
808
+ pdfDoc.setTitle('🥚 The Life of an Egg 🍳')
809
+ pdfDoc.setAuthor('Humpty Dumpty')
810
+ pdfDoc.setSubject('📘 An Epic Tale of Woe 📖')
811
+ pdfDoc.setKeywords(['eggs', 'wall', 'fall', 'king', 'horses', 'men'])
812
+ pdfDoc.setProducer('PDF App 9000 🤖')
813
+ pdfDoc.setCreator('pdf-lib (https://github.com/Hopding/pdf-lib)')
814
+ pdfDoc.setCreationDate(new Date('2018-06-24T01:58:37.228Z'))
815
+ pdfDoc.setModificationDate(new Date('2019-12-21T07:00:11.000Z'))
816
+
817
+ // Serialize the PDFDocument to bytes (a Uint8Array)
818
+ const pdfBytes = await pdfDoc.save()
819
+
820
+ // For example, `pdfBytes` can be:
821
+ // • Written to a file in Node
822
+ // • Downloaded from the browser
823
+ // • Rendered in an <iframe>
824
+ ```
825
+
826
+ ### Read Document Metadata
827
+
828
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/eg8rfz3k/16/)
829
+
830
+ <!-- prettier-ignore -->
831
+ ```js
832
+ import { PDFDocument } from 'pdf-lib'
833
+
834
+ // This should be a Uint8Array or ArrayBuffer
835
+ // This data can be obtained in a number of different ways
836
+ // If your running in a Node environment, you could use fs.readFile()
837
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
838
+ const existingPdfBytes = ...
839
+
840
+ // Load a PDFDocument without updating its existing metadata
841
+ const pdfDoc = await PDFDocument.load(existingPdfBytes, {
842
+ updateMetadata: false
843
+ })
844
+
845
+ // Print all available metadata fields
846
+ console.log('Title:', pdfDoc.getTitle())
847
+ console.log('Author:', pdfDoc.getAuthor())
848
+ console.log('Subject:', pdfDoc.getSubject())
849
+ console.log('Creator:', pdfDoc.getCreator())
850
+ console.log('Keywords:', pdfDoc.getKeywords())
851
+ console.log('Producer:', pdfDoc.getProducer())
852
+ console.log('Creation Date:', pdfDoc.getCreationDate())
853
+ console.log('Modification Date:', pdfDoc.getModificationDate())
854
+ ```
855
+
856
+ This script outputs the following (_when [this PDF](assets/pdfs/with_cropbox.pdf) is used for the `existingPdfBytes` variable_):
857
+
858
+ ```
859
+ Title: Microsoft Word - Basic Curriculum Vitae example.doc
860
+ Author: Administrator
861
+ Subject: undefined
862
+ Creator: PScript5.dll Version 5.2
863
+ Keywords: undefined
864
+ Producer: Acrobat Distiller 8.1.0 (Windows)
865
+ Creation Date: 2010-07-29T14:26:00.000Z
866
+ Modification Date: 2010-07-29T14:26:00.000Z
867
+ ```
868
+
869
+ ### Set Viewer Preferences
870
+
871
+ <!-- prettier-ignore -->
872
+ ```js
873
+ import {
874
+ PDFDocument,
875
+ StandardFonts,
876
+ NonFullScreenPageMode,
877
+ ReadingDirection,
878
+ PrintScaling,
879
+ Duplex,
880
+ PDFName,
881
+ } from 'pdf-lib'
882
+
883
+ // Create a new PDFDocument
884
+ const pdfDoc = await PDFDocument.create()
885
+
886
+ // Embed the Times Roman font
887
+ const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
888
+
889
+ // Add a page and draw some text on it
890
+ const page = pdfDoc.addPage([500, 600])
891
+ page.setFont(timesRomanFont)
892
+ page.drawText('The Life of an Egg', { x: 60, y: 500, size: 50 })
893
+ page.drawText('An Epic Tale of Woe', { x: 125, y: 460, size: 25 })
894
+
895
+ // Set all available viewer preferences on the PDFDocument:
896
+ const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()
897
+ viewerPrefs.setHideToolbar(true)
898
+ viewerPrefs.setHideMenubar(true)
899
+ viewerPrefs.setHideWindowUI(true)
900
+ viewerPrefs.setFitWindow(true)
901
+ viewerPrefs.setCenterWindow(true)
902
+ viewerPrefs.setDisplayDocTitle(true)
903
+
904
+ // Set the PageMode (otherwise setting NonFullScreenPageMode has no meaning)
905
+ pdfDoc.catalog.set(PDFName.of('PageMode'), PDFName.of('FullScreen'))
906
+
907
+ // Set what happens when fullScreen is closed
908
+ viewerPrefs.setNonFullScreenPageMode(NonFullScreenPageMode.UseOutlines)
909
+
910
+ viewerPrefs.setReadingDirection(ReadingDirection.L2R)
911
+ viewerPrefs.setPrintScaling(PrintScaling.None)
912
+ viewerPrefs.setDuplex(Duplex.DuplexFlipLongEdge)
913
+ viewerPrefs.setPickTrayByPDFSize(true)
914
+
915
+ // We can set the default print range to only the first page
916
+ viewerPrefs.setPrintPageRange({ start: 0, end: 0 })
917
+
918
+ // Or we can supply noncontiguous ranges (e.g. pages 1, 3, and 5-7)
919
+ viewerPrefs.setPrintPageRange([
920
+ { start: 0, end: 0 },
921
+ { start: 2, end: 2 },
922
+ { start: 4, end: 6 },
923
+ ])
924
+
925
+ viewerPrefs.setNumCopies(2)
926
+
927
+ // Serialize the PDFDocument to bytes (a Uint8Array)
928
+ const pdfBytes = await pdfDoc.save()
929
+
930
+ // For example, `pdfBytes` can be:
931
+ // • Written to a file in Node
932
+ // • Downloaded from the browser
933
+ // • Rendered in an <iframe>
934
+ ```
935
+
936
+ ### Read Viewer Preferences
937
+
938
+ <!-- prettier-ignore -->
939
+ ```js
940
+ import { PDFDocument } from 'pdf-lib'
941
+
942
+ // This should be a Uint8Array or ArrayBuffer
943
+ // This data can be obtained in a number of different ways
944
+ // If your running in a Node environment, you could use fs.readFile()
945
+ // In the browser, you could make a fetch() call and use res.arrayBuffer()
946
+ const existingPdfBytes = ...
947
+
948
+ // Load a PDFDocument without updating its existing metadata
949
+ const pdfDoc = await PDFDocument.load(existingPdfBytes)
950
+ const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()
951
+
952
+ // Print all available viewer preference fields
953
+ console.log('HideToolbar:', viewerPrefs.getHideToolbar())
954
+ console.log('HideMenubar:', viewerPrefs.getHideMenubar())
955
+ console.log('HideWindowUI:', viewerPrefs.getHideWindowUI())
956
+ console.log('FitWindow:', viewerPrefs.getFitWindow())
957
+ console.log('CenterWindow:', viewerPrefs.getCenterWindow())
958
+ console.log('DisplayDocTitle:', viewerPrefs.getDisplayDocTitle())
959
+ console.log('NonFullScreenPageMode:', viewerPrefs.getNonFullScreenPageMode())
960
+ console.log('ReadingDirection:', viewerPrefs.getReadingDirection())
961
+ console.log('PrintScaling:', viewerPrefs.getPrintScaling())
962
+ console.log('Duplex:', viewerPrefs.getDuplex())
963
+ console.log('PickTrayByPDFSize:', viewerPrefs.getPickTrayByPDFSize())
964
+ console.log('PrintPageRange:', viewerPrefs.getPrintPageRange())
965
+ console.log('NumCopies:', viewerPrefs.getNumCopies())
966
+ ```
967
+
968
+ This script outputs the following (_when [this PDF](assets/pdfs/with_viewer_prefs.pdf) is used for the `existingPdfBytes` variable_):
969
+
970
+ ```
971
+ HideToolbar: true
972
+ HideMenubar: true
973
+ HideWindowUI: false
974
+ FitWindow: true
975
+ CenterWindow: true
976
+ DisplayDocTitle: true
977
+ NonFullScreenPageMode: UseNone
978
+ ReadingDirection: R2L
979
+ PrintScaling: None
980
+ Duplex: DuplexFlipLongEdge
981
+ PickTrayByPDFSize: true
982
+ PrintPageRange: [ { start: 1, end: 1 }, { start: 3, end: 4 } ]
983
+ NumCopies: 2
984
+ ```
985
+
986
+ ### Draw SVG Paths
987
+
988
+ _This example produces [this PDF](assets/pdfs/examples/draw_svg_paths.pdf)_.
989
+
990
+ [Try the JSFiddle demo](https://jsfiddle.net/Hopding/bwaomr9h/2/)
991
+
992
+ <!-- prettier-ignore -->
993
+ ```js
994
+ import { PDFDocument, rgb } from 'pdf-lib'
995
+
996
+ // SVG path for a wavy line
997
+ const svgPath =
998
+ 'M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90'
999
+
1000
+ // Create a new PDFDocument
1001
+ const pdfDoc = await PDFDocument.create()
1002
+
1003
+ // Add a blank page to the document
1004
+ const page = pdfDoc.addPage()
1005
+ page.moveTo(100, page.getHeight() - 5)
1006
+
1007
+ // Draw the SVG path as a black line
1008
+ page.moveDown(25)
1009
+ page.drawSvgPath(svgPath)
1010
+
1011
+ // Draw the SVG path as a thick green line
1012
+ page.moveDown(200)
1013
+ page.drawSvgPath(svgPath, { borderColor: rgb(0, 1, 0), borderWidth: 5 })
1014
+
1015
+ // Draw the SVG path and fill it with red
1016
+ page.moveDown(200)
1017
+ page.drawSvgPath(svgPath, { color: rgb(1, 0, 0) })
1018
+
1019
+ // Draw the SVG path at 50% of its original size
1020
+ page.moveDown(200)
1021
+ page.drawSvgPath(svgPath, { scale: 0.5 })
1022
+
1023
+ // Serialize the PDFDocument to bytes (a Uint8Array)
1024
+ const pdfBytes = await pdfDoc.save()
1025
+
1026
+ // For example, `pdfBytes` can be:
1027
+ // • Written to a file in Node
1028
+ // • Downloaded from the browser
1029
+ // • Rendered in an <iframe>
1030
+ ```
1031
+
1032
+ ## Deno Usage
1033
+
1034
+ `pdf-lib` fully supports the exciting new [Deno](https://deno.land/) runtime! All of the [usage examples](#usage-examples) work in Deno. The only thing you need to do is change the imports for `pdf-lib` and `@pdf-lib/fontkit` to use the [Skypack](https://www.skypack.dev/) CDN, because Deno requires all modules to be referenced via URLs.
1035
+
1036
+ > **See also [How to Create and Modify PDF Files in Deno With pdf-lib](https://medium.com/swlh/how-to-create-and-modify-pdf-files-in-deno-ffaad7099b0?source=friends_link&sk=3da183bb776d059df428eaea52102f19)**
1037
+
1038
+ ### Creating a Document with Deno
1039
+
1040
+ Below is the [**create document**](#create-document) example modified for Deno:
1041
+
1042
+ ```js
1043
+ import {
1044
+ PDFDocument,
1045
+ StandardFonts,
1046
+ rgb,
1047
+ } from 'https://cdn.skypack.dev/pdf-lib@^1.11.1?dts';
1048
+
1049
+ const pdfDoc = await PDFDocument.create();
1050
+ const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman);
1051
+
1052
+ const page = pdfDoc.addPage();
1053
+ const { width, height } = page.getSize();
1054
+ const fontSize = 30;
1055
+ page.drawText('Creating PDFs in JavaScript is awesome!', {
1056
+ x: 50,
1057
+ y: height - 4 * fontSize,
1058
+ size: fontSize,
1059
+ font: timesRomanFont,
1060
+ color: rgb(0, 0.53, 0.71),
1061
+ });
1062
+
1063
+ const pdfBytes = await pdfDoc.save();
1064
+
1065
+ await Deno.writeFile('out.pdf', pdfBytes);
1066
+ ```
1067
+
1068
+ If you save this script as `create-document.ts`, you can execute it using Deno with the following command:
1069
+
1070
+ ```
1071
+ deno run --allow-write create-document.ts
1072
+ ```
1073
+
1074
+ The resulting `out.pdf` file will look like [this PDF](assets/pdfs/examples/create_document.pdf).
1075
+
1076
+ ### Embedding a Font with Deno
1077
+
1078
+ Here's a slightly more complicated example demonstrating how to embed a font and measure text in Deno:
1079
+
1080
+ ```js
1081
+ import {
1082
+ degrees,
1083
+ PDFDocument,
1084
+ rgb,
1085
+ StandardFonts,
1086
+ } from 'https://cdn.skypack.dev/pdf-lib@^1.11.1?dts';
1087
+ import fontkit from 'https://cdn.skypack.dev/@pdf-lib/fontkit@^1.0.0?dts';
1088
+
1089
+ const url = 'https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf';
1090
+ const fontBytes = await fetch(url).then((res) => res.arrayBuffer());
1091
+
1092
+ const pdfDoc = await PDFDocument.create();
1093
+
1094
+ pdfDoc.registerFontkit(fontkit);
1095
+ const customFont = await pdfDoc.embedFont(fontBytes);
1096
+
1097
+ const page = pdfDoc.addPage();
1098
+
1099
+ const text = 'This is text in an embedded font!';
1100
+ const textSize = 35;
1101
+ const textWidth = customFont.widthOfTextAtSize(text, textSize);
1102
+ const textHeight = customFont.heightAtSize(textSize);
1103
+
1104
+ page.drawText(text, {
1105
+ x: 40,
1106
+ y: 450,
1107
+ size: textSize,
1108
+ font: customFont,
1109
+ color: rgb(0, 0.53, 0.71),
1110
+ });
1111
+ page.drawRectangle({
1112
+ x: 40,
1113
+ y: 450,
1114
+ width: textWidth,
1115
+ height: textHeight,
1116
+ borderColor: rgb(1, 0, 0),
1117
+ borderWidth: 1.5,
1118
+ });
1119
+
1120
+ const pdfBytes = await pdfDoc.save();
1121
+
1122
+ await Deno.writeFile('out.pdf', pdfBytes);
1123
+ ```
1124
+
1125
+ If you save this script as `custom-font.ts`, you can execute it with the following command:
1126
+
1127
+ ```
1128
+ deno run --allow-write --allow-net custom-font.ts
1129
+ ```
1130
+
1131
+ The resulting `out.pdf` file will look like [this PDF](assets/pdfs/examples/embed_font_and_measure_text.pdf).
1132
+
1133
+ ## Complete Examples
1134
+
1135
+ The [usage examples](#usage-examples) provide code that is brief and to the point, demonstrating the different features of `pdf-lib`. You can find complete working examples in the [`apps/`](apps/) directory. These apps are used to do manual testing of `pdf-lib` before every release (in addition to the [automated tests](tests/)).
1136
+
1137
+ There are currently four apps:
1138
+
1139
+ - [**`node`**](apps/node/) - contains [tests](apps/node/tests/) for `pdf-lib` in Node environments. These tests are a handy reference when trying to save/load PDFs, fonts, or images with `pdf-lib` from the filesystem. They also allow you to quickly open your PDFs in different viewers (Acrobat, Preview, Foxit, Chrome, Firefox, etc...) to ensure compatibility.
1140
+ - [**`web`**](apps/web/) - contains [tests](apps/web/) for `pdf-lib` in browser environments. These tests are a handy reference when trying to save/load PDFs, fonts, or images with `pdf-lib` in a browser environment.
1141
+ - [**`rn`**](apps/rn) - contains [tests](apps/rn/src/tests/) for `pdf-lib` in React Native environments. These tests are a handy reference when trying to save/load PDFs, fonts, or images with `pdf-lib` in a React Native environment.
1142
+ - [**`deno`**](apps/deno) - contains [tests](apps/deno/tests/) for `pdf-lib` in Deno environments. These tests are a handy reference when trying to save/load PDFs, fonts, or images with `pdf-lib` from the filesystem.
1143
+
1144
+ ## Installation
1145
+
1146
+ ### NPM Module
1147
+
1148
+ To install the latest stable version:
1149
+
1150
+ ```bash
1151
+ # With npm
1152
+ npm install --save pdf-lib
1153
+
1154
+ # With yarn
1155
+ yarn add pdf-lib
1156
+ ```
1157
+
1158
+ This assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.
1159
+
1160
+ ### UMD Module
1161
+
1162
+ You can also download `pdf-lib` as a UMD module from [unpkg](https://unpkg.com/#/) or [jsDelivr](https://www.jsdelivr.com/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.
1163
+
1164
+ The following builds are available:
1165
+
1166
+ - https://unpkg.com/pdf-lib/dist/pdf-lib.js
1167
+ - https://unpkg.com/pdf-lib/dist/pdf-lib.min.js
1168
+ - https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.js
1169
+ - https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.min.js
1170
+
1171
+ > **NOTE:** if you are using the CDN scripts in production, you should include a specific version number in the URL, for example:
1172
+ >
1173
+ > - https://unpkg.com/pdf-lib@1.4.0/dist/pdf-lib.min.js
1174
+ > - https://cdn.jsdelivr.net/npm/pdf-lib@1.4.0/dist/pdf-lib.min.js
1175
+
1176
+ When using a UMD build, you will have access to a global `window.PDFLib` variable. This variable contains all of the classes and functions exported by `pdf-lib`. For example:
1177
+
1178
+ ```javascript
1179
+ // NPM module
1180
+ import { PDFDocument, rgb } from 'pdf-lib';
1181
+
1182
+ // UMD module
1183
+ var PDFDocument = PDFLib.PDFDocument;
1184
+ var rgb = PDFLib.rgb;
1185
+ ```
1186
+
1187
+ ## Fontkit Installation
1188
+
1189
+ `pdf-lib` relies upon a sister module to support embedding custom fonts: [`@pdf-lib/fontkit`](https://www.npmjs.com/package/@pdf-lib/fontkit). You must add the `@pdf-lib/fontkit` module to your project and register it using `pdfDoc.registerFontkit(...)` before embedding custom fonts (see the [font embedding example](#embed-font-and-measure-text)). This module is not included by default because not all users need it, and it increases bundle size.
1190
+
1191
+ Installing this module is easy. Just like `pdf-lib` itself, `@pdf-lib/fontkit` can be installed with `npm`/`yarn` or as a UMD module.
1192
+
1193
+ ### Fontkit NPM Module
1194
+
1195
+ ```bash
1196
+ # With npm
1197
+ npm install --save @pdf-lib/fontkit
1198
+
1199
+ # With yarn
1200
+ yarn add @pdf-lib/fontkit
1201
+ ```
1202
+
1203
+ To register the `fontkit` instance:
1204
+
1205
+ <!-- prettier-ignore -->
1206
+ ```js
1207
+ import { PDFDocument } from 'pdf-lib'
1208
+ import fontkit from '@pdf-lib/fontkit'
1209
+
1210
+ const pdfDoc = await PDFDocument.create()
1211
+ pdfDoc.registerFontkit(fontkit)
1212
+ ```
1213
+
1214
+ ### Fontkit UMD Module
1215
+
1216
+ The following builds are available:
1217
+
1218
+ - https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.js
1219
+ - https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.min.js
1220
+ - https://cdn.jsdelivr.net/npm/@pdf-lib/fontkit/dist/fontkit.umd.js
1221
+ - https://cdn.jsdelivr.net/npm/@pdf-lib/fontkit/dist/fontkit.umd.min.js
1222
+
1223
+ > **NOTE:** if you are using the CDN scripts in production, you should include a specific version number in the URL, for example:
1224
+ >
1225
+ > - https://unpkg.com/@pdf-lib/fontkit@0.0.4/dist/fontkit.umd.min.js
1226
+ > - https://cdn.jsdelivr.net/npm/@pdf-lib/fontkit@0.0.4/dist/fontkit.umd.min.js
1227
+
1228
+ When using a UMD build, you will have access to a global `window.fontkit` variable. To register the `fontkit` instance:
1229
+
1230
+ <!-- prettier-ignore -->
1231
+ ```js
1232
+ var pdfDoc = await PDFLib.PDFDocument.create()
1233
+ pdfDoc.registerFontkit(fontkit)
1234
+ ```
1235
+
1236
+ ## Documentation
1237
+
1238
+ API documentation is available on the project site at https://pdf-lib.js.org/docs/api/.
1239
+
1240
+ The repo for the project site (and generated documentation files) is
1241
+ located here: https://github.com/Hopding/pdf-lib-docs.
1242
+
1243
+ ## Fonts and Unicode
1244
+
1245
+ When working with PDFs, you will frequently come across the terms "character encoding" and "font". If you have experience in web development, you may wonder why these are so prevalent. Aren't they just annoying details that you shouldn't need to worry about? Shouldn't PDF libraries and readers be able to handle all of this for you like web browsers can? Unfortunately, this is not the case. The nature of the PDF file format makes it very difficult to avoid thinking about character encodings and fonts when working with PDFs.
1246
+
1247
+ `pdf-lib` does its best to simplify things for you. But it can't perform magic. This means you should be aware of the following:
1248
+
1249
+ - **There are 14 standard fonts** defined in the PDF specification. They are as follows: _Times Roman_ (normal, bold, and italic), _Helvetica_ (normal, bold, and italic), _Courier_ (normal, bold, and italic), _ZapfDingbats_ (normal), and _Symbol_ (normal). These 14 fonts are guaranteed to be available in PDF readers. As such, you do not need to embed any font data if you wish to use one of these fonts. You can use a standard font like so:
1250
+ <!-- prettier-ignore -->
1251
+ ```js
1252
+ import { PDFDocument, StandardFonts } from 'pdf-lib'
1253
+ const pdfDoc = await PDFDocument.create()
1254
+ const courierFont = await pdfDoc.embedFont(StandardFonts.Courier)
1255
+ const page = pdfDoc.addPage()
1256
+ page.drawText('Some boring latin text in the Courier font', {
1257
+ font: courierFont,
1258
+ })
1259
+ ```
1260
+ - **The standard fonts do not support all characters** available in Unicode. The Times Roman, Helvetica, and Courier fonts use WinAnsi encoding (aka [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252)). The WinAnsi character set only supports 218 characters in the Latin alphabet. For this reason, many users will find the standard fonts insufficient for their use case. This is unfortunate, but there's nothing that PDF libraries can do to change this. This is a result of the PDF specification and its age. Note that the [ZapfDingbats](https://en.wikipedia.org/wiki/Zapf_Dingbats) and [Symbol](<https://en.wikipedia.org/wiki/Symbol_(typeface)>) fonts use their own specialized encodings that support 203 and 194 characters, respectively. However, the characters they support are not useful for most use cases. See [here](assets/pdfs/standard_fonts_demo.pdf) for an example of all 14 standard fonts.
1261
+ - **You can use characters outside the Latin alphabet** by embedding your own fonts. Embedding your own font requires to you load the font data (from a file or via a network request, for example) and pass it to the `embedFont` method. When you embed your own font, you can use any Unicode characters that it supports. This capability frees you from the limitations imposed by the standard fonts. Most PDF files use embedded fonts. You can embed and use a custom font like so ([see also](#embed-font-and-measure-text)):
1262
+ <!-- prettier-ignore -->
1263
+ ```js
1264
+ import { PDFDocument } from 'pdf-lib'
1265
+ import fontkit from '@pdf-lib/fontkit'
1266
+
1267
+ const url = 'https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf'
1268
+ const fontBytes = await fetch(url).then((res) => res.arrayBuffer())
1269
+
1270
+ const pdfDoc = await PDFDocument.create()
1271
+
1272
+ pdfDoc.registerFontkit(fontkit)
1273
+ const ubuntuFont = await pdfDoc.embedFont(fontBytes)
1274
+
1275
+ const page = pdfDoc.addPage()
1276
+ page.drawText('Some fancy Unicode text in the ŪЬȕǹƚü font', {
1277
+ font: ubuntuFont,
1278
+ })
1279
+ ```
1280
+
1281
+ Note that encoding errors will be thrown if you try to use a character with a font that does not support it. For example, `Ω` is not in the WinAnsi character set. So trying to draw it on a page with the standard Helvetica font will throw the following error:
1282
+
1283
+ ```
1284
+ Error: WinAnsi cannot encode "Ω" (0x03a9)
1285
+ at Encoding.encodeUnicodeCodePoint
1286
+ ```
1287
+
1288
+ ### Font Subsetting
1289
+
1290
+ Embedding a font in a PDF document will typically increase the file's size. You can reduce the amount a file's size is increased by subsetting the font so that only the necessary characters are embedded. You can subset a font by setting the [`subset` option](https://pdf-lib.js.org/docs/api/interfaces/embedfontoptions#optional-subset) to `true`. For example:
1291
+
1292
+ ```js
1293
+ const font = await pdfDoc.embedFont(fontBytes, { subset: true });
1294
+ ```
1295
+
1296
+ Note that subsetting does not work for all fonts. See https://github.com/Hopding/pdf-lib/issues/207#issuecomment-537210471 for additional details.
1297
+
1298
+ ## Creating and Filling Forms
1299
+
1300
+ `pdf-lib` can create, fill, and read PDF form fields. The following field types are supported:
1301
+
1302
+ - [Buttons](https://pdf-lib.js.org/docs/api/classes/pdfbutton)
1303
+ - [Check Boxes](https://pdf-lib.js.org/docs/api/classes/pdfcheckbox)
1304
+ - [Dropdowns](https://pdf-lib.js.org/docs/api/classes/pdfdropdown)
1305
+ - [Option Lists](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist)
1306
+ - [Radio Groups](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup)
1307
+ - [Text Fields](https://pdf-lib.js.org/docs/api/classes/pdftextfield)
1308
+
1309
+ See the [form creation](#create-form) and [form filling](#fill-form) usage examples for code samples. Tests 1, 14, 15, 16, and 17 in the [complete examples](#complete-examples) contain working example code for form creation and filling in a variety of different JS environments.
1310
+
1311
+ **IMPORTANT:** The default font used to display text in buttons, dropdowns, option lists, and text fields is the standard Helvetica font. This font only supports characters in the latin alphabet (see [Fonts and Unicode](#fonts-and-unicode) for details). This means that if any of these field types are created or modified to contain text outside the latin alphabet (as is often the case), you will need to embed and use a custom font to update the field appearances. Otherwise an error will be thrown (likely when you save the `PDFDocument`).
1312
+
1313
+ You can use an embedded font when filling form fields as follows:
1314
+
1315
+ ```js
1316
+ import { PDFDocument } from 'pdf-lib';
1317
+ import fontkit from '@pdf-lib/fontkit';
1318
+
1319
+ // Fetch the PDF with form fields
1320
+ const formUrl = 'https://pdf-lib.js.org/assets/dod_character.pdf';
1321
+ const formBytes = await fetch(formUrl).then((res) => res.arrayBuffer());
1322
+
1323
+ // Fetch the Ubuntu font
1324
+ const fontUrl = 'https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf';
1325
+ const fontBytes = await fetch(fontUrl).then((res) => res.arrayBuffer());
1326
+
1327
+ // Load the PDF with form fields
1328
+ const pdfDoc = await PDFDocument.load(formBytes);
1329
+
1330
+ // Embed the Ubuntu font
1331
+ pdfDoc.registerFontkit(fontkit);
1332
+ const ubuntuFont = await pdfDoc.embedFont(fontBytes);
1333
+
1334
+ // Get two text fields from the form
1335
+ const form = pdfDoc.getForm();
1336
+ const nameField = form.getTextField('CharacterName 2');
1337
+ const ageField = form.getTextField('Age');
1338
+
1339
+ // Fill the text fields with some fancy Unicode characters (outside
1340
+ // the WinAnsi latin character set)
1341
+ nameField.setText('Ӎӑȑїõ');
1342
+ ageField.setText('24 ŷȇȁŗš');
1343
+
1344
+ // **Key Step:** Update the field appearances with the Ubuntu font
1345
+ form.updateFieldAppearances(ubuntuFont);
1346
+
1347
+ // Save the PDF with filled form fields
1348
+ const pdfBytes = await pdfDoc.save();
1349
+ ```
1350
+
1351
+ ### Handy Methods for Filling, Creating, and Reading Form Fields
1352
+
1353
+ Existing form fields can be accessed with the following methods of [`PDFForm`](https://pdf-lib.js.org/docs/api/classes/pdfform):
1354
+
1355
+ - [`PDFForm.getButton`](https://pdf-lib.js.org/docs/api/classes/pdfform#getbutton)
1356
+ - [`PDFForm.getCheckBox`](https://pdf-lib.js.org/docs/api/classes/pdfform#getcheckbox)
1357
+ - [`PDFForm.getDropdown`](https://pdf-lib.js.org/docs/api/classes/pdfform#getdropdown)
1358
+ - [`PDFForm.getOptionList`](https://pdf-lib.js.org/docs/api/classes/pdfform#getoptionlist)
1359
+ - [`PDFForm.getRadioGroup`](https://pdf-lib.js.org/docs/api/classes/pdfform#getradiogroup)
1360
+ - [`PDFForm.getTextField`](https://pdf-lib.js.org/docs/api/classes/pdfform#gettextfield)
1361
+
1362
+ New form fields can be created with the following methods of [`PDFForm`](https://pdf-lib.js.org/docs/api/classes/pdfform):
1363
+
1364
+ - [`PDFForm.createButton`](https://pdf-lib.js.org/docs/api/classes/pdfform#createbutton)
1365
+ - [`PDFForm.createCheckBox`](https://pdf-lib.js.org/docs/api/classes/pdfform#createcheckbox)
1366
+ - [`PDFForm.createDropdown`](https://pdf-lib.js.org/docs/api/classes/pdfform#createdropdown)
1367
+ - [`PDFForm.createOptionList`](https://pdf-lib.js.org/docs/api/classes/pdfform#createoptionlist)
1368
+ - [`PDFForm.createRadioGroup`](https://pdf-lib.js.org/docs/api/classes/pdfform#createradiogroup)
1369
+ - [`PDFForm.createTextField`](https://pdf-lib.js.org/docs/api/classes/pdfform#createtextfield)
1370
+
1371
+ Below are some of the most commonly used methods for reading and filling the aforementioned subclasses of [`PDFField`](https://pdf-lib.js.org/docs/api/classes/pdffield):
1372
+
1373
+ - [`PDFCheckBox.check`](https://pdf-lib.js.org/docs/api/classes/pdfcheckbox#check)
1374
+ - [`PDFCheckBox.uncheck`](https://pdf-lib.js.org/docs/api/classes/pdfcheckbox#uncheck)
1375
+ - [`PDFCheckBox.isChecked`](https://pdf-lib.js.org/docs/api/classes/pdfcheckbox#ischecked)
1376
+
1377
+ ---
1378
+
1379
+ - [`PDFDropdown.select`](https://pdf-lib.js.org/docs/api/classes/pdfdropdown#select)
1380
+ - [`PDFDropdown.clear`](https://pdf-lib.js.org/docs/api/classes/pdfdropdown#clear)
1381
+ - [`PDFDropdown.getSelected`](https://pdf-lib.js.org/docs/api/classes/pdfdropdown#getselected)
1382
+ - [`PDFDropdown.getOptions`](https://pdf-lib.js.org/docs/api/classes/pdfdropdown#getoptions)
1383
+ - [`PDFDropdown.addOptions`](https://pdf-lib.js.org/docs/api/classes/pdfdropdown#addoptions)
1384
+
1385
+ ---
1386
+
1387
+ - [`PDFOptionList.select`](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist#select)
1388
+ - [`PDFOptionList.clear`](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist#clear)
1389
+ - [`PDFOptionList.getSelected`](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist#getselected)
1390
+ - [`PDFOptionList.getOptions`](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist#getoptions)
1391
+ - [`PDFOptionList.addOptions`](https://pdf-lib.js.org/docs/api/classes/pdfoptionlist#addoptions)
1392
+
1393
+ ---
1394
+
1395
+ - [`PDFRadioGroup.select`](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup#select)
1396
+ - [`PDFRadioGroup.clear`](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup#clear)
1397
+ - [`PDFRadioGroup.getSelected`](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup#getselected)
1398
+ - [`PDFRadioGroup.getOptions`](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup#getoptions)
1399
+ - [`PDFRadioGroup.addOptionToPage`](https://pdf-lib.js.org/docs/api/classes/pdfradiogroup#addoptiontopage)
1400
+
1401
+ ---
1402
+
1403
+ - [`PDFTextField.setText`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#settext)
1404
+ - [`PDFTextField.getText`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#gettext)
1405
+ - [`PDFTextField.setMaxLength`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#setmaxlength)
1406
+ - [`PDFTextField.getMaxLength`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#getmaxlength)
1407
+ - [`PDFTextField.removeMaxLength`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#removemaxlength)
1408
+
1409
+ ## Limitations
1410
+
1411
+ - `pdf-lib` **can** extract the content of text fields (see [`PDFTextField.getText`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#gettext)), but it **cannot** extract plain text on a page outside of a form field. This is a difficult feature to implement, but it is within the scope of this library and may be added to `pdf-lib` in the future. See
1412
+ [#93](https://github.com/Hopding/pdf-lib/issues/93),
1413
+ [#137](https://github.com/Hopding/pdf-lib/issues/137),
1414
+ [#177](https://github.com/Hopding/pdf-lib/issues/177),
1415
+ [#329](https://github.com/Hopding/pdf-lib/issues/329), and
1416
+ [#380](https://github.com/Hopding/pdf-lib/issues/380).
1417
+ - `pdf-lib` **can** remove and edit the content of text fields (see [`PDFTextField.setText`](https://pdf-lib.js.org/docs/api/classes/pdftextfield#settext)), but it does **not** provide APIs for removing or editing text on a page outside of a form field. This is also a difficult feature to implement, but is within the scope of `pdf-lib` and may be added in the future. See
1418
+ [#93](https://github.com/Hopding/pdf-lib/issues/93),
1419
+ [#137](https://github.com/Hopding/pdf-lib/issues/137),
1420
+ [#177](https://github.com/Hopding/pdf-lib/issues/177),
1421
+ [#329](https://github.com/Hopding/pdf-lib/issues/329), and
1422
+ [#380](https://github.com/Hopding/pdf-lib/issues/380).
1423
+ - `pdf-lib` does **not** support the use of HTML or CSS when adding content to a PDF. Similarly, `pdf-lib` **cannot** embed HTML/CSS content into PDFs. As convenient as such a feature might be, it would be extremely difficult to implement and is far beyond the scope of this library. If this capability is something you need, consider using [Puppeteer](https://github.com/puppeteer/puppeteer).
1424
+
1425
+ ## Help and Discussion
1426
+
1427
+ [Discussions](https://github.com/Hopding/pdf-lib/discussions) is the best place to chat with us, ask questions, and learn more about pdf-lib!
1428
+
1429
+ See also [MAINTAINERSHIP.md#communication](docs/MAINTAINERSHIP.md#communication) and [MAINTAINERSHIP.md#discord](docs/MAINTAINERSHIP.md#discord).
1430
+
1431
+ ## Encryption Handling
1432
+
1433
+ **`pdf-lib` does not currently support encrypted documents.** You should not use `pdf-lib` with encrypted documents. However, this is a feature that could be added to `pdf-lib`. Please [create an issue](https://github.com/Hopding/pdf-lib/issues/new) if you would find this feature helpful!
1434
+
1435
+ When an encrypted document is passed to `PDFDocument.load(...)`, an error will be thrown:
1436
+
1437
+ <!-- prettier-ignore -->
1438
+ ```js
1439
+ import { PDFDocument, EncryptedPDFError } from 'pdf-lib'
1440
+
1441
+ const encryptedPdfBytes = ...
1442
+
1443
+ // Assignment fails. Throws an `EncryptedPDFError`.
1444
+ const pdfDoc = PDFDocument.load(encryptedPdfBytes)
1445
+ ```
1446
+
1447
+ This default behavior is usually what you want. It allows you to easily detect if a given document is encrypted, and it prevents you from trying to modify it. However, if you really want to load the document, you can use the `{ ignoreEncryption: true }` option:
1448
+
1449
+ ```js
1450
+ import { PDFDocument } from 'pdf-lib'
1451
+
1452
+ const encryptedPdfBytes = ...
1453
+
1454
+ // Assignment succeeds. Does not throw an error.
1455
+ const pdfDoc = PDFDocument.load(encryptedPdfBytes, { ignoreEncryption: true })
1456
+ ```
1457
+
1458
+ Note that **using this option does not decrypt the document**. This means that any modifications you attempt to make on the returned `PDFDocument` may fail, or have unexpected results.
1459
+
1460
+ **You should not use this option.** It only exists for backwards compatibility reasons.
1461
+
1462
+ ## Contributing
1463
+
1464
+ We welcome contributions from the open source community! If you are interested in contributing to `pdf-lib`, please take a look at the [CONTRIBUTING.md](docs/CONTRIBUTING.md) file. It contains information to help you get `pdf-lib` setup and running on your machine. (We try to make this as simple and fast as possible! :rocket:)
1465
+
1466
+ ## Maintainership
1467
+
1468
+ Check out [MAINTAINERSHIP.md](docs/MAINTAINERSHIP.md) for details on how this repo is maintained and how we use [issues](docs/MAINTAINERSHIP.md#issues), [PRs](docs/MAINTAINERSHIP.md#pull-requests), and [discussions](docs/MAINTAINERSHIP.md#discussions).
1469
+
1470
+ ## Tutorials and Cool Stuff
1471
+
1472
+ - [labelmake](https://github.com/hand-dot/labelmake) - a library for declarative PDF generation created by @hand-dot
1473
+ - [Möbius Printing helper](https://shreevatsa.net/mobius-print/) - a tool created by @shreevatsa
1474
+ - [Extract PDF pages](https://shreevatsa.net/pdf-pages/) - a tool created by @shreevatsa
1475
+ - [Travel certificate generator](https://github.com/LAB-MI/deplacement-covid-19) - a tool that creates travel certificates for French citizens under quarantine due to COVID-19
1476
+ - [How to use pdf-lib in AWS Lambdas](https://medium.com/swlh/create-pdf-using-pdf-lib-on-serverless-aws-lambda-e9506246dc88) - a tutorial written by Crespo Wang
1477
+ - [Working With PDFs in Node.js Using pdf-lib](http://thecodebarbarian.com/working-with-pdfs-in-node-js.html) - a tutorial by Valeri Karpov
1478
+ - [Electron app for resizing PDFs](https://github.com/vegarringdal/simple-pdf-resizer) - a tool created by @vegarringdal
1479
+ - [PDF Shelter](https://pdfshelter.com) - online PDF manipulation tools by Lucas Morais
1480
+
1481
+ ## Prior Art
1482
+
1483
+ - [`pdfkit`](https://github.com/devongovett/pdfkit) is a PDF generation library for Node and the Browser. This library was immensely helpful as a reference and existence proof when creating `pdf-lib`. `pdfkit`'s code for [font embedding](src/core/embedders/CustomFontEmbedder.ts#L17-L21), [PNG embedding](src/core/embedders/PngEmbedder.ts#L7-L11), and [JPG embedding](src/core/embedders/JpegEmbedder.ts#L25-L29) was especially useful.
1484
+ - [`pdf.js`](https://github.com/mozilla/pdf.js) is a PDF rendering library for the Browser. This library was helpful as a reference when writing `pdf-lib`'s parser. Some of the code for stream decoding was [ported directly to TypeScript](src/core/streams) for use in `pdf-lib`.
1485
+ - [`pdfbox`](https://pdfbox.apache.org/) is a PDF generation and modification library written in Java. This library was an invaluable reference when implementing form creation and filling APIs for `pdf-lib`.
1486
+ - [`jspdf`](https://github.com/MrRio/jsPDF) is a PDF generation library for the browser.
1487
+ - [`pdfmake`](https://github.com/bpampuch/pdfmake) is a PDF generation library for the browser.
1488
+ - [`hummus`](https://github.com/galkahana/HummusJS) is a PDF generation and modification library for Node environments. `hummus` is a Node wrapper around a [C++ library](https://github.com/galkahana/PDF-Writer), so it doesn't work in many JavaScript environments - like the Browser or React Native.
1489
+ - [`react-native-pdf-lib`](https://github.com/Hopding/react-native-pdf-lib) is a PDF generation and modification library for React Native environments. `react-native-pdf-lib` is a wrapper around [C++](https://github.com/galkahana/PDF-Writer) and [Java](https://github.com/TomRoush/PdfBox-Android) libraries.
1490
+ - [`pdfassembler`](https://github.com/DevelopingMagic/pdfassembler) is a PDF generation and modification library for Node and the browser. It requires some knowledge about the logical structure of PDF documents to use.
1491
+
1492
+ ## Git History Rewrite
1493
+
1494
+ This repo used to contain a file called `pdf_specification.pdf` in the root directory. This was a copy of the [PDF 1.7 specification](https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf), which is made freely available by Adobe. On 8/30/2021, we received a DMCA complaint requiring us to remove the file from this repo. Simply removing the file via a new commit to `master` was insufficient to satisfy the complaint. The file needed to be completely removed from the repo's git history. Unfortunately, the file was added over two years ago, this meant we had to rewrite the repo's git history and force push to `master` 😔.
1495
+
1496
+ ### Steps We Took
1497
+
1498
+ We removed the file and rewrote the repo's history using [BFG Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/) as outlined [here](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository). For full transparency, here are the exact commands we ran:
1499
+
1500
+ ```
1501
+ $ git clone git@github.com:Hopding/pdf-lib.git
1502
+ $ cd pdf-lib
1503
+ $ rm pdf_specification.pdf
1504
+ $ git commit -am 'Remove pdf_specification.pdf'
1505
+ $ bfg --delete-files pdf_specification.pdf
1506
+ $ git reflog expire --expire=now --all && git gc --prune=now --aggressive
1507
+ $ git push --force
1508
+ ```
1509
+
1510
+ ### Why Should I Care?
1511
+
1512
+ If you're a user of `pdf-lib`, you shouldn't care! Just keep on using `pdf-lib` like normal 😃 ✨!
1513
+
1514
+ If you are a `pdf-lib` developer (meaning you've forked `pdf-lib` and/or have an open PR) then this does impact you. If you forked or cloned the repo prior to 8/30/2021 then your fork's git history is out of sync with this repo's `master` branch. Unfortunately, this will likely be a headache for you to deal with. Sorry! We didn't want to rewrite the history, but there really was no alternative.
1515
+
1516
+ It's important to note that pdf-lib's _source code_ has not changed at all. It's exactly the same as it was before the git history rewrite. The repo still has the exact same number of commits (and even the same commit contents, except for the commit that added `pdf_specification.pdf`). What has changed are the SHAs of those commits.
1517
+
1518
+ The simplest way to deal with this fact is to:
1519
+
1520
+ 1. Reclone pdf-lib
1521
+ 2. Manually copy any changes you've made from your old clone to the new one
1522
+ 3. Use your new clone going forward
1523
+ 4. Reopen your unmerged PRs using your new clone
1524
+
1525
+ See this [StackOverflow answer](https://stackoverflow.com/a/48268766) for a great, in depth explanation of what a git history rewrite entails.
1526
+
1527
+ ## License
1528
+
1529
+ [MIT](LICENSE.md)