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

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