@adnsistemas/pdf-lib 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1586) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +1713 -0
  3. package/cjs/api/Embeddable.d.ts +8 -0
  4. package/cjs/api/Embeddable.d.ts.map +1 -0
  5. package/cjs/api/Embeddable.js +3 -0
  6. package/cjs/api/Embeddable.js.map +1 -0
  7. package/cjs/api/PDFDocument.d.ts +800 -0
  8. package/cjs/api/PDFDocument.d.ts.map +1 -0
  9. package/cjs/api/PDFDocument.js +1454 -0
  10. package/cjs/api/PDFDocument.js.map +1 -0
  11. package/cjs/api/PDFDocumentOptions.d.ts +43 -0
  12. package/cjs/api/PDFDocumentOptions.d.ts.map +1 -0
  13. package/cjs/api/PDFDocumentOptions.js +11 -0
  14. package/cjs/api/PDFDocumentOptions.js.map +1 -0
  15. package/cjs/api/PDFEmbeddedFile.d.ts +39 -0
  16. package/cjs/api/PDFEmbeddedFile.d.ts.map +1 -0
  17. package/cjs/api/PDFEmbeddedFile.js +84 -0
  18. package/cjs/api/PDFEmbeddedFile.js.map +1 -0
  19. package/cjs/api/PDFEmbeddedPage.d.ts +74 -0
  20. package/cjs/api/PDFEmbeddedPage.d.ts.map +1 -0
  21. package/cjs/api/PDFEmbeddedPage.js +95 -0
  22. package/cjs/api/PDFEmbeddedPage.js.map +1 -0
  23. package/cjs/api/PDFFont.d.ts +95 -0
  24. package/cjs/api/PDFFont.d.ts.map +1 -0
  25. package/cjs/api/PDFFont.js +143 -0
  26. package/cjs/api/PDFFont.js.map +1 -0
  27. package/cjs/api/PDFImage.d.ts +96 -0
  28. package/cjs/api/PDFImage.d.ts.map +1 -0
  29. package/cjs/api/PDFImage.js +132 -0
  30. package/cjs/api/PDFImage.js.map +1 -0
  31. package/cjs/api/PDFJavaScript.d.ts +39 -0
  32. package/cjs/api/PDFJavaScript.d.ts.map +1 -0
  33. package/cjs/api/PDFJavaScript.js +73 -0
  34. package/cjs/api/PDFJavaScript.js.map +1 -0
  35. package/cjs/api/PDFPage.d.ts +898 -0
  36. package/cjs/api/PDFPage.d.ts.map +1 -0
  37. package/cjs/api/PDFPage.js +1442 -0
  38. package/cjs/api/PDFPage.js.map +1 -0
  39. package/cjs/api/PDFPageOptions.d.ts +155 -0
  40. package/cjs/api/PDFPageOptions.d.ts.map +1 -0
  41. package/cjs/api/PDFPageOptions.js +19 -0
  42. package/cjs/api/PDFPageOptions.js.map +1 -0
  43. package/cjs/api/StandardFonts.d.ts +17 -0
  44. package/cjs/api/StandardFonts.d.ts.map +1 -0
  45. package/cjs/api/StandardFonts.js +21 -0
  46. package/cjs/api/StandardFonts.js.map +1 -0
  47. package/cjs/api/colors.d.ts +31 -0
  48. package/cjs/api/colors.d.ts.map +1 -0
  49. package/cjs/api/colors.js +59 -0
  50. package/cjs/api/colors.js.map +1 -0
  51. package/cjs/api/errors.d.ts +43 -0
  52. package/cjs/api/errors.d.ts.map +1 -0
  53. package/cjs/api/errors.js +168 -0
  54. package/cjs/api/errors.js.map +1 -0
  55. package/cjs/api/form/PDFButton.d.ts +138 -0
  56. package/cjs/api/form/PDFButton.d.ts.map +1 -0
  57. package/cjs/api/form/PDFButton.js +220 -0
  58. package/cjs/api/form/PDFButton.js.map +1 -0
  59. package/cjs/api/form/PDFCheckBox.d.ts +143 -0
  60. package/cjs/api/form/PDFCheckBox.d.ts.map +1 -0
  61. package/cjs/api/form/PDFCheckBox.js +236 -0
  62. package/cjs/api/form/PDFCheckBox.js.map +1 -0
  63. package/cjs/api/form/PDFDropdown.d.ts +403 -0
  64. package/cjs/api/form/PDFDropdown.d.ts.map +1 -0
  65. package/cjs/api/form/PDFDropdown.js +580 -0
  66. package/cjs/api/form/PDFDropdown.js.map +1 -0
  67. package/cjs/api/form/PDFField.d.ts +204 -0
  68. package/cjs/api/form/PDFField.d.ts.map +1 -0
  69. package/cjs/api/form/PDFField.js +384 -0
  70. package/cjs/api/form/PDFField.js.map +1 -0
  71. package/cjs/api/form/PDFForm.d.ts +412 -0
  72. package/cjs/api/form/PDFForm.d.ts.map +1 -0
  73. package/cjs/api/form/PDFForm.js +726 -0
  74. package/cjs/api/form/PDFForm.js.map +1 -0
  75. package/cjs/api/form/PDFOptionList.d.ts +336 -0
  76. package/cjs/api/form/PDFOptionList.d.ts.map +1 -0
  77. package/cjs/api/form/PDFOptionList.js +499 -0
  78. package/cjs/api/form/PDFOptionList.js.map +1 -0
  79. package/cjs/api/form/PDFRadioGroup.d.ts +253 -0
  80. package/cjs/api/form/PDFRadioGroup.d.ts.map +1 -0
  81. package/cjs/api/form/PDFRadioGroup.js +415 -0
  82. package/cjs/api/form/PDFRadioGroup.js.map +1 -0
  83. package/cjs/api/form/PDFSignature.d.ts +30 -0
  84. package/cjs/api/form/PDFSignature.d.ts.map +1 -0
  85. package/cjs/api/form/PDFSignature.js +43 -0
  86. package/cjs/api/form/PDFSignature.js.map +1 -0
  87. package/cjs/api/form/PDFTextField.d.ts +538 -0
  88. package/cjs/api/form/PDFTextField.d.ts.map +1 -0
  89. package/cjs/api/form/PDFTextField.js +739 -0
  90. package/cjs/api/form/PDFTextField.js.map +1 -0
  91. package/cjs/api/form/appearances.d.ts +42 -0
  92. package/cjs/api/form/appearances.d.ts.map +1 -0
  93. package/cjs/api/form/appearances.js +421 -0
  94. package/cjs/api/form/appearances.js.map +1 -0
  95. package/cjs/api/form/index.d.ts +11 -0
  96. package/cjs/api/form/index.d.ts.map +1 -0
  97. package/cjs/api/form/index.js +23 -0
  98. package/cjs/api/form/index.js.map +1 -0
  99. package/cjs/api/image/alignment.d.ts +6 -0
  100. package/cjs/api/image/alignment.d.ts.map +1 -0
  101. package/cjs/api/image/alignment.js +10 -0
  102. package/cjs/api/image/alignment.js.map +1 -0
  103. package/cjs/api/image/index.d.ts +2 -0
  104. package/cjs/api/image/index.d.ts.map +1 -0
  105. package/cjs/api/image/index.js +5 -0
  106. package/cjs/api/image/index.js.map +1 -0
  107. package/cjs/api/index.d.ts +22 -0
  108. package/cjs/api/index.d.ts.map +1 -0
  109. package/cjs/api/index.js +30 -0
  110. package/cjs/api/index.js.map +1 -0
  111. package/cjs/api/objects.d.ts +5 -0
  112. package/cjs/api/objects.d.ts.map +1 -0
  113. package/cjs/api/objects.js +14 -0
  114. package/cjs/api/objects.js.map +1 -0
  115. package/cjs/api/operations.d.ts +212 -0
  116. package/cjs/api/operations.d.ts.map +1 -0
  117. package/cjs/api/operations.js +488 -0
  118. package/cjs/api/operations.js.map +1 -0
  119. package/cjs/api/operators.d.ts +86 -0
  120. package/cjs/api/operators.d.ts.map +1 -0
  121. package/cjs/api/operators.js +231 -0
  122. package/cjs/api/operators.js.map +1 -0
  123. package/cjs/api/rotations.d.ts +39 -0
  124. package/cjs/api/rotations.d.ts.map +1 -0
  125. package/cjs/api/rotations.js +71 -0
  126. package/cjs/api/rotations.js.map +1 -0
  127. package/cjs/api/sizes.d.ts +53 -0
  128. package/cjs/api/sizes.d.ts.map +1 -0
  129. package/cjs/api/sizes.js +56 -0
  130. package/cjs/api/sizes.js.map +1 -0
  131. package/cjs/api/snapshot/DefaultDocumentSnapshot.d.ts +13 -0
  132. package/cjs/api/snapshot/DefaultDocumentSnapshot.d.ts.map +1 -0
  133. package/cjs/api/snapshot/DefaultDocumentSnapshot.js +28 -0
  134. package/cjs/api/snapshot/DefaultDocumentSnapshot.js.map +1 -0
  135. package/cjs/api/snapshot/DocumentSnapshot.d.ts +11 -0
  136. package/cjs/api/snapshot/DocumentSnapshot.d.ts.map +1 -0
  137. package/cjs/api/snapshot/DocumentSnapshot.js +3 -0
  138. package/cjs/api/snapshot/DocumentSnapshot.js.map +1 -0
  139. package/cjs/api/snapshot/IncrementalDocumentSnapshot.d.ts +16 -0
  140. package/cjs/api/snapshot/IncrementalDocumentSnapshot.d.ts.map +1 -0
  141. package/cjs/api/snapshot/IncrementalDocumentSnapshot.js +44 -0
  142. package/cjs/api/snapshot/IncrementalDocumentSnapshot.js.map +1 -0
  143. package/cjs/api/snapshot/index.d.ts +4 -0
  144. package/cjs/api/snapshot/index.d.ts.map +1 -0
  145. package/cjs/api/snapshot/index.js +7 -0
  146. package/cjs/api/snapshot/index.js.map +1 -0
  147. package/cjs/api/svgPath.d.ts +3 -0
  148. package/cjs/api/svgPath.d.ts.map +1 -0
  149. package/cjs/api/svgPath.js +380 -0
  150. package/cjs/api/svgPath.js.map +1 -0
  151. package/cjs/api/text/alignment.d.ts +6 -0
  152. package/cjs/api/text/alignment.d.ts.map +1 -0
  153. package/cjs/api/text/alignment.js +10 -0
  154. package/cjs/api/text/alignment.js.map +1 -0
  155. package/cjs/api/text/index.d.ts +3 -0
  156. package/cjs/api/text/index.d.ts.map +1 -0
  157. package/cjs/api/text/index.js +6 -0
  158. package/cjs/api/text/index.js.map +1 -0
  159. package/cjs/api/text/layout.d.ts +55 -0
  160. package/cjs/api/text/layout.d.ts.map +1 -0
  161. package/cjs/api/text/layout.js +212 -0
  162. package/cjs/api/text/layout.js.map +1 -0
  163. package/cjs/core/PDFContext.d.ts +93 -0
  164. package/cjs/core/PDFContext.d.ts.map +1 -0
  165. package/cjs/core/PDFContext.js +210 -0
  166. package/cjs/core/PDFContext.js.map +1 -0
  167. package/cjs/core/PDFObjectCopier.d.ts +38 -0
  168. package/cjs/core/PDFObjectCopier.d.ts.map +1 -0
  169. package/cjs/core/PDFObjectCopier.js +119 -0
  170. package/cjs/core/PDFObjectCopier.js.map +1 -0
  171. package/cjs/core/acroform/PDFAcroButton.d.ts +22 -0
  172. package/cjs/core/acroform/PDFAcroButton.d.ts.map +1 -0
  173. package/cjs/core/acroform/PDFAcroButton.js +96 -0
  174. package/cjs/core/acroform/PDFAcroButton.js.map +1 -0
  175. package/cjs/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  176. package/cjs/core/acroform/PDFAcroCheckBox.d.ts.map +1 -0
  177. package/cjs/core/acroform/PDFAcroCheckBox.js +50 -0
  178. package/cjs/core/acroform/PDFAcroCheckBox.js.map +1 -0
  179. package/cjs/core/acroform/PDFAcroChoice.d.ts +21 -0
  180. package/cjs/core/acroform/PDFAcroChoice.d.ts.map +1 -0
  181. package/cjs/core/acroform/PDFAcroChoice.js +127 -0
  182. package/cjs/core/acroform/PDFAcroChoice.js.map +1 -0
  183. package/cjs/core/acroform/PDFAcroComboBox.d.ts +10 -0
  184. package/cjs/core/acroform/PDFAcroComboBox.d.ts.map +1 -0
  185. package/cjs/core/acroform/PDFAcroComboBox.js +26 -0
  186. package/cjs/core/acroform/PDFAcroComboBox.js.map +1 -0
  187. package/cjs/core/acroform/PDFAcroField.d.ts +37 -0
  188. package/cjs/core/acroform/PDFAcroField.d.ts.map +1 -0
  189. package/cjs/core/acroform/PDFAcroField.js +149 -0
  190. package/cjs/core/acroform/PDFAcroField.js.map +1 -0
  191. package/cjs/core/acroform/PDFAcroForm.d.ts +21 -0
  192. package/cjs/core/acroform/PDFAcroForm.d.ts.map +1 -0
  193. package/cjs/core/acroform/PDFAcroForm.js +78 -0
  194. package/cjs/core/acroform/PDFAcroForm.js.map +1 -0
  195. package/cjs/core/acroform/PDFAcroListBox.d.ts +10 -0
  196. package/cjs/core/acroform/PDFAcroListBox.d.ts.map +1 -0
  197. package/cjs/core/acroform/PDFAcroListBox.js +24 -0
  198. package/cjs/core/acroform/PDFAcroListBox.js.map +1 -0
  199. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  200. package/cjs/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -0
  201. package/cjs/core/acroform/PDFAcroNonTerminal.js +34 -0
  202. package/cjs/core/acroform/PDFAcroNonTerminal.js.map +1 -0
  203. package/cjs/core/acroform/PDFAcroPushButton.d.ts +10 -0
  204. package/cjs/core/acroform/PDFAcroPushButton.d.ts.map +1 -0
  205. package/cjs/core/acroform/PDFAcroPushButton.js +26 -0
  206. package/cjs/core/acroform/PDFAcroPushButton.js.map +1 -0
  207. package/cjs/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  208. package/cjs/core/acroform/PDFAcroRadioButton.d.ts.map +1 -0
  209. package/cjs/core/acroform/PDFAcroRadioButton.js +57 -0
  210. package/cjs/core/acroform/PDFAcroRadioButton.js.map +1 -0
  211. package/cjs/core/acroform/PDFAcroSignature.d.ts +8 -0
  212. package/cjs/core/acroform/PDFAcroSignature.d.ts.map +1 -0
  213. package/cjs/core/acroform/PDFAcroSignature.js +16 -0
  214. package/cjs/core/acroform/PDFAcroSignature.js.map +1 -0
  215. package/cjs/core/acroform/PDFAcroTerminal.d.ts +17 -0
  216. package/cjs/core/acroform/PDFAcroTerminal.d.ts.map +1 -0
  217. package/cjs/core/acroform/PDFAcroTerminal.js +70 -0
  218. package/cjs/core/acroform/PDFAcroTerminal.js.map +1 -0
  219. package/cjs/core/acroform/PDFAcroText.d.ts +23 -0
  220. package/cjs/core/acroform/PDFAcroText.d.ts.map +1 -0
  221. package/cjs/core/acroform/PDFAcroText.js +73 -0
  222. package/cjs/core/acroform/PDFAcroText.js.map +1 -0
  223. package/cjs/core/acroform/flags.d.ts +142 -0
  224. package/cjs/core/acroform/flags.d.ts.map +1 -0
  225. package/cjs/core/acroform/flags.js +150 -0
  226. package/cjs/core/acroform/flags.js.map +1 -0
  227. package/cjs/core/acroform/index.d.ts +16 -0
  228. package/cjs/core/acroform/index.d.ts.map +1 -0
  229. package/cjs/core/acroform/index.js +32 -0
  230. package/cjs/core/acroform/index.js.map +1 -0
  231. package/cjs/core/acroform/utils.d.ts +7 -0
  232. package/cjs/core/acroform/utils.d.ts.map +1 -0
  233. package/cjs/core/acroform/utils.js +127 -0
  234. package/cjs/core/acroform/utils.js.map +1 -0
  235. package/cjs/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  236. package/cjs/core/annotation/AppearanceCharacteristics.d.ts.map +1 -0
  237. package/cjs/core/annotation/AppearanceCharacteristics.js +123 -0
  238. package/cjs/core/annotation/AppearanceCharacteristics.js.map +1 -0
  239. package/cjs/core/annotation/BorderStyle.d.ts +12 -0
  240. package/cjs/core/annotation/BorderStyle.d.ts.map +1 -0
  241. package/cjs/core/annotation/BorderStyle.js +29 -0
  242. package/cjs/core/annotation/BorderStyle.js.map +1 -0
  243. package/cjs/core/annotation/PDFAnnotation.d.ts +52 -0
  244. package/cjs/core/annotation/PDFAnnotation.d.ts.map +1 -0
  245. package/cjs/core/annotation/PDFAnnotation.js +123 -0
  246. package/cjs/core/annotation/PDFAnnotation.js.map +1 -0
  247. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  248. package/cjs/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -0
  249. package/cjs/core/annotation/PDFWidgetAnnotation.js +110 -0
  250. package/cjs/core/annotation/PDFWidgetAnnotation.js.map +1 -0
  251. package/cjs/core/annotation/flags.d.ts +80 -0
  252. package/cjs/core/annotation/flags.d.ts.map +1 -0
  253. package/cjs/core/annotation/flags.js +85 -0
  254. package/cjs/core/annotation/flags.js.map +1 -0
  255. package/cjs/core/annotation/index.d.ts +5 -0
  256. package/cjs/core/annotation/index.d.ts.map +1 -0
  257. package/cjs/core/annotation/index.js +11 -0
  258. package/cjs/core/annotation/index.js.map +1 -0
  259. package/cjs/core/document/PDFCrossRefSection.d.ts +28 -0
  260. package/cjs/core/document/PDFCrossRefSection.d.ts.map +1 -0
  261. package/cjs/core/document/PDFCrossRefSection.js +124 -0
  262. package/cjs/core/document/PDFCrossRefSection.js.map +1 -0
  263. package/cjs/core/document/PDFHeader.d.ts +11 -0
  264. package/cjs/core/document/PDFHeader.d.ts.map +1 -0
  265. package/cjs/core/document/PDFHeader.js +42 -0
  266. package/cjs/core/document/PDFHeader.js.map +1 -0
  267. package/cjs/core/document/PDFTrailer.d.ts +10 -0
  268. package/cjs/core/document/PDFTrailer.d.ts.map +1 -0
  269. package/cjs/core/document/PDFTrailer.js +43 -0
  270. package/cjs/core/document/PDFTrailer.js.map +1 -0
  271. package/cjs/core/document/PDFTrailerDict.d.ts +11 -0
  272. package/cjs/core/document/PDFTrailerDict.d.ts.map +1 -0
  273. package/cjs/core/document/PDFTrailerDict.js +32 -0
  274. package/cjs/core/document/PDFTrailerDict.js.map +1 -0
  275. package/cjs/core/embedders/CMap.d.ts +4 -0
  276. package/cjs/core/embedders/CMap.d.ts.map +1 -0
  277. package/cjs/core/embedders/CMap.js +43 -0
  278. package/cjs/core/embedders/CMap.js.map +1 -0
  279. package/cjs/core/embedders/CustomFontEmbedder.d.ts +45 -0
  280. package/cjs/core/embedders/CustomFontEmbedder.d.ts.map +1 -0
  281. package/cjs/core/embedders/CustomFontEmbedder.js +240 -0
  282. package/cjs/core/embedders/CustomFontEmbedder.js.map +1 -0
  283. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  284. package/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -0
  285. package/cjs/core/embedders/CustomFontSubsetEmbedder.js +68 -0
  286. package/cjs/core/embedders/CustomFontSubsetEmbedder.js.map +1 -0
  287. package/cjs/core/embedders/FileEmbedder.d.ts +34 -0
  288. package/cjs/core/embedders/FileEmbedder.d.ts.map +1 -0
  289. package/cjs/core/embedders/FileEmbedder.js +75 -0
  290. package/cjs/core/embedders/FileEmbedder.js.map +1 -0
  291. package/cjs/core/embedders/FontFlags.d.ts +14 -0
  292. package/cjs/core/embedders/FontFlags.d.ts.map +1 -0
  293. package/cjs/core/embedders/FontFlags.js +40 -0
  294. package/cjs/core/embedders/FontFlags.js.map +1 -0
  295. package/cjs/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  296. package/cjs/core/embedders/JavaScriptEmbedder.d.ts.map +1 -0
  297. package/cjs/core/embedders/JavaScriptEmbedder.js +36 -0
  298. package/cjs/core/embedders/JavaScriptEmbedder.js.map +1 -0
  299. package/cjs/core/embedders/JpegEmbedder.d.ts +24 -0
  300. package/cjs/core/embedders/JpegEmbedder.d.ts.map +1 -0
  301. package/cjs/core/embedders/JpegEmbedder.js +107 -0
  302. package/cjs/core/embedders/JpegEmbedder.js.map +1 -0
  303. package/cjs/core/embedders/PDFPageEmbedder.d.ts +38 -0
  304. package/cjs/core/embedders/PDFPageEmbedder.d.ts.map +1 -0
  305. package/cjs/core/embedders/PDFPageEmbedder.js +91 -0
  306. package/cjs/core/embedders/PDFPageEmbedder.js.map +1 -0
  307. package/cjs/core/embedders/PngEmbedder.d.ts +20 -0
  308. package/cjs/core/embedders/PngEmbedder.d.ts.map +1 -0
  309. package/cjs/core/embedders/PngEmbedder.js +69 -0
  310. package/cjs/core/embedders/PngEmbedder.js.map +1 -0
  311. package/cjs/core/embedders/StandardFontEmbedder.d.ts +37 -0
  312. package/cjs/core/embedders/StandardFontEmbedder.d.ts.map +1 -0
  313. package/cjs/core/embedders/StandardFontEmbedder.js +98 -0
  314. package/cjs/core/embedders/StandardFontEmbedder.js.map +1 -0
  315. package/cjs/core/errors.d.ts +92 -0
  316. package/cjs/core/errors.d.ts.map +1 -0
  317. package/cjs/core/errors.js +323 -0
  318. package/cjs/core/errors.js.map +1 -0
  319. package/cjs/core/index.d.ts +48 -0
  320. package/cjs/core/index.d.ts.map +1 -0
  321. package/cjs/core/index.js +100 -0
  322. package/cjs/core/index.js.map +1 -0
  323. package/cjs/core/interactive/ViewerPreferences.d.ts +348 -0
  324. package/cjs/core/interactive/ViewerPreferences.d.ts.map +1 -0
  325. package/cjs/core/interactive/ViewerPreferences.js +511 -0
  326. package/cjs/core/interactive/ViewerPreferences.js.map +1 -0
  327. package/cjs/core/objects/PDFArray.d.ts +64 -0
  328. package/cjs/core/objects/PDFArray.d.ts.map +1 -0
  329. package/cjs/core/objects/PDFArray.js +117 -0
  330. package/cjs/core/objects/PDFArray.js.map +1 -0
  331. package/cjs/core/objects/PDFBool.d.ts +14 -0
  332. package/cjs/core/objects/PDFBool.d.ts.map +1 -0
  333. package/cjs/core/objects/PDFBool.js +52 -0
  334. package/cjs/core/objects/PDFBool.js.map +1 -0
  335. package/cjs/core/objects/PDFDict.d.ts +63 -0
  336. package/cjs/core/objects/PDFDict.d.ts.map +1 -0
  337. package/cjs/core/objects/PDFDict.js +143 -0
  338. package/cjs/core/objects/PDFDict.js.map +1 -0
  339. package/cjs/core/objects/PDFHexString.d.ts +17 -0
  340. package/cjs/core/objects/PDFHexString.d.ts.map +1 -0
  341. package/cjs/core/objects/PDFHexString.js +74 -0
  342. package/cjs/core/objects/PDFHexString.js.map +1 -0
  343. package/cjs/core/objects/PDFInvalidObject.d.ts +12 -0
  344. package/cjs/core/objects/PDFInvalidObject.d.ts.map +1 -0
  345. package/cjs/core/objects/PDFInvalidObject.js +32 -0
  346. package/cjs/core/objects/PDFInvalidObject.js.map +1 -0
  347. package/cjs/core/objects/PDFName.d.ts +42 -0
  348. package/cjs/core/objects/PDFName.d.ts.map +1 -0
  349. package/cjs/core/objects/PDFName.js +138 -0
  350. package/cjs/core/objects/PDFName.js.map +1 -0
  351. package/cjs/core/objects/PDFNull.d.ts +11 -0
  352. package/cjs/core/objects/PDFNull.d.ts.map +1 -0
  353. package/cjs/core/objects/PDFNull.js +33 -0
  354. package/cjs/core/objects/PDFNull.js.map +1 -0
  355. package/cjs/core/objects/PDFNumber.d.ts +16 -0
  356. package/cjs/core/objects/PDFNumber.d.ts.map +1 -0
  357. package/cjs/core/objects/PDFNumber.js +38 -0
  358. package/cjs/core/objects/PDFNumber.js.map +1 -0
  359. package/cjs/core/objects/PDFObject.d.ts +10 -0
  360. package/cjs/core/objects/PDFObject.d.ts.map +1 -0
  361. package/cjs/core/objects/PDFObject.js +25 -0
  362. package/cjs/core/objects/PDFObject.js.map +1 -0
  363. package/cjs/core/objects/PDFRawStream.d.ts +15 -0
  364. package/cjs/core/objects/PDFRawStream.d.ts.map +1 -0
  365. package/cjs/core/objects/PDFRawStream.js +34 -0
  366. package/cjs/core/objects/PDFRawStream.js.map +1 -0
  367. package/cjs/core/objects/PDFRef.d.ts +14 -0
  368. package/cjs/core/objects/PDFRef.d.ts.map +1 -0
  369. package/cjs/core/objects/PDFRef.js +47 -0
  370. package/cjs/core/objects/PDFRef.js.map +1 -0
  371. package/cjs/core/objects/PDFStream.d.ts +17 -0
  372. package/cjs/core/objects/PDFStream.d.ts.map +1 -0
  373. package/cjs/core/objects/PDFStream.js +75 -0
  374. package/cjs/core/objects/PDFStream.js.map +1 -0
  375. package/cjs/core/objects/PDFString.d.ts +17 -0
  376. package/cjs/core/objects/PDFString.d.ts.map +1 -0
  377. package/cjs/core/objects/PDFString.js +116 -0
  378. package/cjs/core/objects/PDFString.js.map +1 -0
  379. package/cjs/core/operators/PDFOperator.d.ts +20 -0
  380. package/cjs/core/operators/PDFOperator.d.ts.map +1 -0
  381. package/cjs/core/operators/PDFOperator.js +58 -0
  382. package/cjs/core/operators/PDFOperator.js.map +1 -0
  383. package/cjs/core/operators/PDFOperatorNames.d.ts +77 -0
  384. package/cjs/core/operators/PDFOperatorNames.d.ts.map +1 -0
  385. package/cjs/core/operators/PDFOperatorNames.js +88 -0
  386. package/cjs/core/operators/PDFOperatorNames.js.map +1 -0
  387. package/cjs/core/parser/BaseParser.d.ts +15 -0
  388. package/cjs/core/parser/BaseParser.d.ts.map +1 -0
  389. package/cjs/core/parser/BaseParser.js +110 -0
  390. package/cjs/core/parser/BaseParser.js.map +1 -0
  391. package/cjs/core/parser/ByteStream.d.ts +27 -0
  392. package/cjs/core/parser/ByteStream.d.ts.map +1 -0
  393. package/cjs/core/parser/ByteStream.js +64 -0
  394. package/cjs/core/parser/ByteStream.js.map +1 -0
  395. package/cjs/core/parser/PDFObjectParser.d.ts +30 -0
  396. package/cjs/core/parser/PDFObjectParser.d.ts.map +1 -0
  397. package/cjs/core/parser/PDFObjectParser.js +233 -0
  398. package/cjs/core/parser/PDFObjectParser.js.map +1 -0
  399. package/cjs/core/parser/PDFObjectStreamParser.d.ts +14 -0
  400. package/cjs/core/parser/PDFObjectStreamParser.d.ts.map +1 -0
  401. package/cjs/core/parser/PDFObjectStreamParser.js +70 -0
  402. package/cjs/core/parser/PDFObjectStreamParser.js.map +1 -0
  403. package/cjs/core/parser/PDFParser.d.ts +46 -0
  404. package/cjs/core/parser/PDFParser.d.ts.map +1 -0
  405. package/cjs/core/parser/PDFParser.js +362 -0
  406. package/cjs/core/parser/PDFParser.js.map +1 -0
  407. package/cjs/core/parser/PDFXRefStreamParser.d.ts +22 -0
  408. package/cjs/core/parser/PDFXRefStreamParser.d.ts.map +1 -0
  409. package/cjs/core/parser/PDFXRefStreamParser.js +93 -0
  410. package/cjs/core/parser/PDFXRefStreamParser.js.map +1 -0
  411. package/cjs/core/streams/Ascii85Stream.d.ts +10 -0
  412. package/cjs/core/streams/Ascii85Stream.d.ts.map +1 -0
  413. package/cjs/core/streams/Ascii85Stream.js +87 -0
  414. package/cjs/core/streams/Ascii85Stream.js.map +1 -0
  415. package/cjs/core/streams/AsciiHexStream.d.ts +10 -0
  416. package/cjs/core/streams/AsciiHexStream.d.ts.map +1 -0
  417. package/cjs/core/streams/AsciiHexStream.js +75 -0
  418. package/cjs/core/streams/AsciiHexStream.js.map +1 -0
  419. package/cjs/core/streams/DecodeStream.d.ts +27 -0
  420. package/cjs/core/streams/DecodeStream.d.ts.map +1 -0
  421. package/cjs/core/streams/DecodeStream.js +149 -0
  422. package/cjs/core/streams/DecodeStream.js.map +1 -0
  423. package/cjs/core/streams/FlateStream.d.ts +14 -0
  424. package/cjs/core/streams/FlateStream.d.ts.map +1 -0
  425. package/cjs/core/streams/FlateStream.js +371 -0
  426. package/cjs/core/streams/FlateStream.js.map +1 -0
  427. package/cjs/core/streams/LZWStream.d.ts +13 -0
  428. package/cjs/core/streams/LZWStream.d.ts.map +1 -0
  429. package/cjs/core/streams/LZWStream.js +137 -0
  430. package/cjs/core/streams/LZWStream.js.map +1 -0
  431. package/cjs/core/streams/RunLengthStream.d.ts +9 -0
  432. package/cjs/core/streams/RunLengthStream.d.ts.map +1 -0
  433. package/cjs/core/streams/RunLengthStream.js +55 -0
  434. package/cjs/core/streams/RunLengthStream.js.map +1 -0
  435. package/cjs/core/streams/Stream.d.ts +35 -0
  436. package/cjs/core/streams/Stream.d.ts.map +1 -0
  437. package/cjs/core/streams/Stream.js +106 -0
  438. package/cjs/core/streams/Stream.js.map +1 -0
  439. package/cjs/core/streams/decode.d.ts +4 -0
  440. package/cjs/core/streams/decode.d.ts.map +1 -0
  441. package/cjs/core/streams/decode.js +59 -0
  442. package/cjs/core/streams/decode.js.map +1 -0
  443. package/cjs/core/structures/PDFCatalog.d.ts +28 -0
  444. package/cjs/core/structures/PDFCatalog.d.ts.map +1 -0
  445. package/cjs/core/structures/PDFCatalog.js +79 -0
  446. package/cjs/core/structures/PDFCatalog.js.map +1 -0
  447. package/cjs/core/structures/PDFContentStream.d.ts +16 -0
  448. package/cjs/core/structures/PDFContentStream.d.ts.map +1 -0
  449. package/cjs/core/structures/PDFContentStream.js +60 -0
  450. package/cjs/core/structures/PDFContentStream.js.map +1 -0
  451. package/cjs/core/structures/PDFCrossRefStream.d.ts +54 -0
  452. package/cjs/core/structures/PDFCrossRefStream.d.ts.map +1 -0
  453. package/cjs/core/structures/PDFCrossRefStream.js +187 -0
  454. package/cjs/core/structures/PDFCrossRefStream.js.map +1 -0
  455. package/cjs/core/structures/PDFFlateStream.d.ts +14 -0
  456. package/cjs/core/structures/PDFFlateStream.d.ts.map +1 -0
  457. package/cjs/core/structures/PDFFlateStream.js +35 -0
  458. package/cjs/core/structures/PDFFlateStream.js.map +1 -0
  459. package/cjs/core/structures/PDFObjectStream.d.ts +21 -0
  460. package/cjs/core/structures/PDFObjectStream.d.ts.map +1 -0
  461. package/cjs/core/structures/PDFObjectStream.js +77 -0
  462. package/cjs/core/structures/PDFObjectStream.js.map +1 -0
  463. package/cjs/core/structures/PDFPageLeaf.d.ts +55 -0
  464. package/cjs/core/structures/PDFPageLeaf.d.ts.map +1 -0
  465. package/cjs/core/structures/PDFPageLeaf.js +208 -0
  466. package/cjs/core/structures/PDFPageLeaf.js.map +1 -0
  467. package/cjs/core/structures/PDFPageTree.d.ts +42 -0
  468. package/cjs/core/structures/PDFPageTree.d.ts.map +1 -0
  469. package/cjs/core/structures/PDFPageTree.js +177 -0
  470. package/cjs/core/structures/PDFPageTree.js.map +1 -0
  471. package/cjs/core/syntax/CharCodes.d.ts +62 -0
  472. package/cjs/core/syntax/CharCodes.d.ts.map +1 -0
  473. package/cjs/core/syntax/CharCodes.js +65 -0
  474. package/cjs/core/syntax/CharCodes.js.map +1 -0
  475. package/cjs/core/syntax/Delimiters.d.ts +2 -0
  476. package/cjs/core/syntax/Delimiters.d.ts.map +1 -0
  477. package/cjs/core/syntax/Delimiters.js +17 -0
  478. package/cjs/core/syntax/Delimiters.js.map +1 -0
  479. package/cjs/core/syntax/Irregular.d.ts +2 -0
  480. package/cjs/core/syntax/Irregular.d.ts.map +1 -0
  481. package/cjs/core/syntax/Irregular.js +13 -0
  482. package/cjs/core/syntax/Irregular.js.map +1 -0
  483. package/cjs/core/syntax/Keywords.d.ts +23 -0
  484. package/cjs/core/syntax/Keywords.d.ts.map +1 -0
  485. package/cjs/core/syntax/Keywords.js +84 -0
  486. package/cjs/core/syntax/Keywords.js.map +1 -0
  487. package/cjs/core/syntax/Numeric.d.ts +4 -0
  488. package/cjs/core/syntax/Numeric.d.ts.map +1 -0
  489. package/cjs/core/syntax/Numeric.js +25 -0
  490. package/cjs/core/syntax/Numeric.js.map +1 -0
  491. package/cjs/core/syntax/Whitespace.d.ts +2 -0
  492. package/cjs/core/syntax/Whitespace.d.ts.map +1 -0
  493. package/cjs/core/syntax/Whitespace.js +13 -0
  494. package/cjs/core/syntax/Whitespace.js.map +1 -0
  495. package/cjs/core/writers/PDFStreamWriter.d.ts +22 -0
  496. package/cjs/core/writers/PDFStreamWriter.d.ts.map +1 -0
  497. package/cjs/core/writers/PDFStreamWriter.js +133 -0
  498. package/cjs/core/writers/PDFStreamWriter.js.map +1 -0
  499. package/cjs/core/writers/PDFWriter.d.ts +33 -0
  500. package/cjs/core/writers/PDFWriter.d.ts.map +1 -0
  501. package/cjs/core/writers/PDFWriter.js +164 -0
  502. package/cjs/core/writers/PDFWriter.js.map +1 -0
  503. package/cjs/index.d.ts +5 -0
  504. package/cjs/index.d.ts.map +1 -0
  505. package/cjs/index.js +8 -0
  506. package/cjs/index.js.map +1 -0
  507. package/cjs/types/fontkit.d.ts +582 -0
  508. package/cjs/types/fontkit.d.ts.map +1 -0
  509. package/cjs/types/fontkit.js +3 -0
  510. package/cjs/types/fontkit.js.map +1 -0
  511. package/cjs/types/index.d.ts +2 -0
  512. package/cjs/types/index.d.ts.map +1 -0
  513. package/cjs/types/index.js +3 -0
  514. package/cjs/types/index.js.map +1 -0
  515. package/cjs/types/matrix.d.ts +22 -0
  516. package/cjs/types/matrix.d.ts.map +1 -0
  517. package/cjs/types/matrix.js +5 -0
  518. package/cjs/types/matrix.js.map +1 -0
  519. package/cjs/utils/Cache.d.ts +11 -0
  520. package/cjs/utils/Cache.d.ts.map +1 -0
  521. package/cjs/utils/Cache.js +23 -0
  522. package/cjs/utils/Cache.js.map +1 -0
  523. package/cjs/utils/arrays.d.ts +16 -0
  524. package/cjs/utils/arrays.d.ts.map +1 -0
  525. package/cjs/utils/arrays.js +132 -0
  526. package/cjs/utils/arrays.js.map +1 -0
  527. package/cjs/utils/async.d.ts +6 -0
  528. package/cjs/utils/async.d.ts.map +1 -0
  529. package/cjs/utils/async.js +13 -0
  530. package/cjs/utils/async.js.map +1 -0
  531. package/cjs/utils/base64.d.ts +11 -0
  532. package/cjs/utils/base64.d.ts.map +1 -0
  533. package/cjs/utils/base64.js +87 -0
  534. package/cjs/utils/base64.js.map +1 -0
  535. package/cjs/utils/errors.d.ts +2 -0
  536. package/cjs/utils/errors.d.ts.map +1 -0
  537. package/cjs/utils/errors.js +7 -0
  538. package/cjs/utils/errors.js.map +1 -0
  539. package/cjs/utils/index.d.ts +12 -0
  540. package/cjs/utils/index.d.ts.map +1 -0
  541. package/cjs/utils/index.js +16 -0
  542. package/cjs/utils/index.js.map +1 -0
  543. package/cjs/utils/numbers.d.ts +24 -0
  544. package/cjs/utils/numbers.d.ts.map +1 -0
  545. package/cjs/utils/numbers.js +57 -0
  546. package/cjs/utils/numbers.js.map +1 -0
  547. package/cjs/utils/objects.d.ts +16 -0
  548. package/cjs/utils/objects.d.ts.map +1 -0
  549. package/cjs/utils/objects.js +11 -0
  550. package/cjs/utils/objects.js.map +1 -0
  551. package/cjs/utils/pdfDocEncoding.d.ts +8 -0
  552. package/cjs/utils/pdfDocEncoding.d.ts.map +1 -0
  553. package/cjs/utils/pdfDocEncoding.js +69 -0
  554. package/cjs/utils/pdfDocEncoding.js.map +1 -0
  555. package/cjs/utils/png.d.ts +18 -0
  556. package/cjs/utils/png.d.ts.map +1 -0
  557. package/cjs/utils/png.js +63 -0
  558. package/cjs/utils/png.js.map +1 -0
  559. package/cjs/utils/rng.d.ts +14 -0
  560. package/cjs/utils/rng.d.ts.map +1 -0
  561. package/cjs/utils/rng.js +23 -0
  562. package/cjs/utils/rng.js.map +1 -0
  563. package/cjs/utils/strings.d.ts +25 -0
  564. package/cjs/utils/strings.d.ts.map +1 -0
  565. package/cjs/utils/strings.js +141 -0
  566. package/cjs/utils/strings.js.map +1 -0
  567. package/cjs/utils/unicode.d.ts +187 -0
  568. package/cjs/utils/unicode.d.ts.map +1 -0
  569. package/cjs/utils/unicode.js +370 -0
  570. package/cjs/utils/unicode.js.map +1 -0
  571. package/cjs/utils/validators.d.ts +27 -0
  572. package/cjs/utils/validators.d.ts.map +1 -0
  573. package/cjs/utils/validators.js +183 -0
  574. package/cjs/utils/validators.js.map +1 -0
  575. package/dist/pdf-lib.esm.js +39613 -0
  576. package/dist/pdf-lib.esm.js.map +1 -0
  577. package/dist/pdf-lib.esm.min.js +16 -0
  578. package/dist/pdf-lib.esm.min.js.map +1 -0
  579. package/dist/pdf-lib.js +39886 -0
  580. package/dist/pdf-lib.js.map +1 -0
  581. package/dist/pdf-lib.min.js +16 -0
  582. package/dist/pdf-lib.min.js.map +1 -0
  583. package/es/api/Embeddable.d.ts +8 -0
  584. package/es/api/Embeddable.d.ts.map +1 -0
  585. package/es/api/Embeddable.js +1 -0
  586. package/es/api/Embeddable.js.map +1 -0
  587. package/es/api/PDFDocument.d.ts +800 -0
  588. package/es/api/PDFDocument.d.ts.map +1 -0
  589. package/es/api/PDFDocument.js +1452 -0
  590. package/es/api/PDFDocument.js.map +1 -0
  591. package/es/api/PDFDocumentOptions.d.ts +43 -0
  592. package/es/api/PDFDocumentOptions.d.ts.map +1 -0
  593. package/es/api/PDFDocumentOptions.js +8 -0
  594. package/es/api/PDFDocumentOptions.js.map +1 -0
  595. package/es/api/PDFEmbeddedFile.d.ts +39 -0
  596. package/es/api/PDFEmbeddedFile.d.ts.map +1 -0
  597. package/es/api/PDFEmbeddedFile.js +82 -0
  598. package/es/api/PDFEmbeddedFile.js.map +1 -0
  599. package/es/api/PDFEmbeddedPage.d.ts +74 -0
  600. package/es/api/PDFEmbeddedPage.d.ts.map +1 -0
  601. package/es/api/PDFEmbeddedPage.js +93 -0
  602. package/es/api/PDFEmbeddedPage.js.map +1 -0
  603. package/es/api/PDFFont.d.ts +95 -0
  604. package/es/api/PDFFont.d.ts.map +1 -0
  605. package/es/api/PDFFont.js +141 -0
  606. package/es/api/PDFFont.js.map +1 -0
  607. package/es/api/PDFImage.d.ts +96 -0
  608. package/es/api/PDFImage.d.ts.map +1 -0
  609. package/es/api/PDFImage.js +130 -0
  610. package/es/api/PDFImage.js.map +1 -0
  611. package/es/api/PDFJavaScript.d.ts +39 -0
  612. package/es/api/PDFJavaScript.d.ts.map +1 -0
  613. package/es/api/PDFJavaScript.js +71 -0
  614. package/es/api/PDFJavaScript.js.map +1 -0
  615. package/es/api/PDFPage.d.ts +898 -0
  616. package/es/api/PDFPage.d.ts.map +1 -0
  617. package/es/api/PDFPage.js +1440 -0
  618. package/es/api/PDFPage.js.map +1 -0
  619. package/es/api/PDFPageOptions.d.ts +155 -0
  620. package/es/api/PDFPageOptions.d.ts.map +1 -0
  621. package/es/api/PDFPageOptions.js +16 -0
  622. package/es/api/PDFPageOptions.js.map +1 -0
  623. package/es/api/StandardFonts.d.ts +17 -0
  624. package/es/api/StandardFonts.d.ts.map +1 -0
  625. package/es/api/StandardFonts.js +18 -0
  626. package/es/api/StandardFonts.js.map +1 -0
  627. package/es/api/colors.d.ts +31 -0
  628. package/es/api/colors.d.ts.map +1 -0
  629. package/es/api/colors.js +56 -0
  630. package/es/api/colors.js.map +1 -0
  631. package/es/api/errors.d.ts +43 -0
  632. package/es/api/errors.d.ts.map +1 -0
  633. package/es/api/errors.js +165 -0
  634. package/es/api/errors.js.map +1 -0
  635. package/es/api/form/PDFButton.d.ts +138 -0
  636. package/es/api/form/PDFButton.d.ts.map +1 -0
  637. package/es/api/form/PDFButton.js +218 -0
  638. package/es/api/form/PDFButton.js.map +1 -0
  639. package/es/api/form/PDFCheckBox.d.ts +143 -0
  640. package/es/api/form/PDFCheckBox.d.ts.map +1 -0
  641. package/es/api/form/PDFCheckBox.js +234 -0
  642. package/es/api/form/PDFCheckBox.js.map +1 -0
  643. package/es/api/form/PDFDropdown.d.ts +403 -0
  644. package/es/api/form/PDFDropdown.d.ts.map +1 -0
  645. package/es/api/form/PDFDropdown.js +578 -0
  646. package/es/api/form/PDFDropdown.js.map +1 -0
  647. package/es/api/form/PDFField.d.ts +204 -0
  648. package/es/api/form/PDFField.d.ts.map +1 -0
  649. package/es/api/form/PDFField.js +381 -0
  650. package/es/api/form/PDFField.js.map +1 -0
  651. package/es/api/form/PDFForm.d.ts +412 -0
  652. package/es/api/form/PDFForm.d.ts.map +1 -0
  653. package/es/api/form/PDFForm.js +724 -0
  654. package/es/api/form/PDFForm.js.map +1 -0
  655. package/es/api/form/PDFOptionList.d.ts +336 -0
  656. package/es/api/form/PDFOptionList.d.ts.map +1 -0
  657. package/es/api/form/PDFOptionList.js +497 -0
  658. package/es/api/form/PDFOptionList.js.map +1 -0
  659. package/es/api/form/PDFRadioGroup.d.ts +253 -0
  660. package/es/api/form/PDFRadioGroup.d.ts.map +1 -0
  661. package/es/api/form/PDFRadioGroup.js +413 -0
  662. package/es/api/form/PDFRadioGroup.js.map +1 -0
  663. package/es/api/form/PDFSignature.d.ts +30 -0
  664. package/es/api/form/PDFSignature.d.ts.map +1 -0
  665. package/es/api/form/PDFSignature.js +41 -0
  666. package/es/api/form/PDFSignature.js.map +1 -0
  667. package/es/api/form/PDFTextField.d.ts +538 -0
  668. package/es/api/form/PDFTextField.d.ts.map +1 -0
  669. package/es/api/form/PDFTextField.js +737 -0
  670. package/es/api/form/PDFTextField.js.map +1 -0
  671. package/es/api/form/appearances.d.ts +42 -0
  672. package/es/api/form/appearances.d.ts.map +1 -0
  673. package/es/api/form/appearances.js +418 -0
  674. package/es/api/form/appearances.js.map +1 -0
  675. package/es/api/form/index.d.ts +11 -0
  676. package/es/api/form/index.d.ts.map +1 -0
  677. package/es/api/form/index.js +11 -0
  678. package/es/api/form/index.js.map +1 -0
  679. package/es/api/image/alignment.d.ts +6 -0
  680. package/es/api/image/alignment.d.ts.map +1 -0
  681. package/es/api/image/alignment.js +7 -0
  682. package/es/api/image/alignment.js.map +1 -0
  683. package/es/api/image/index.d.ts +2 -0
  684. package/es/api/image/index.d.ts.map +1 -0
  685. package/es/api/image/index.js +2 -0
  686. package/es/api/image/index.js.map +1 -0
  687. package/es/api/index.d.ts +22 -0
  688. package/es/api/index.d.ts.map +1 -0
  689. package/es/api/index.js +21 -0
  690. package/es/api/index.js.map +1 -0
  691. package/es/api/objects.d.ts +5 -0
  692. package/es/api/objects.d.ts.map +1 -0
  693. package/es/api/objects.js +11 -0
  694. package/es/api/objects.js.map +1 -0
  695. package/es/api/operations.d.ts +212 -0
  696. package/es/api/operations.d.ts.map +1 -0
  697. package/es/api/operations.js +485 -0
  698. package/es/api/operations.js.map +1 -0
  699. package/es/api/operators.d.ts +86 -0
  700. package/es/api/operators.d.ts.map +1 -0
  701. package/es/api/operators.js +228 -0
  702. package/es/api/operators.js.map +1 -0
  703. package/es/api/rotations.d.ts +39 -0
  704. package/es/api/rotations.d.ts.map +1 -0
  705. package/es/api/rotations.js +68 -0
  706. package/es/api/rotations.js.map +1 -0
  707. package/es/api/sizes.d.ts +53 -0
  708. package/es/api/sizes.d.ts.map +1 -0
  709. package/es/api/sizes.js +53 -0
  710. package/es/api/sizes.js.map +1 -0
  711. package/es/api/snapshot/DefaultDocumentSnapshot.d.ts +13 -0
  712. package/es/api/snapshot/DefaultDocumentSnapshot.d.ts.map +1 -0
  713. package/es/api/snapshot/DefaultDocumentSnapshot.js +25 -0
  714. package/es/api/snapshot/DefaultDocumentSnapshot.js.map +1 -0
  715. package/es/api/snapshot/DocumentSnapshot.d.ts +11 -0
  716. package/es/api/snapshot/DocumentSnapshot.d.ts.map +1 -0
  717. package/es/api/snapshot/DocumentSnapshot.js +1 -0
  718. package/es/api/snapshot/DocumentSnapshot.js.map +1 -0
  719. package/es/api/snapshot/IncrementalDocumentSnapshot.d.ts +16 -0
  720. package/es/api/snapshot/IncrementalDocumentSnapshot.d.ts.map +1 -0
  721. package/es/api/snapshot/IncrementalDocumentSnapshot.js +41 -0
  722. package/es/api/snapshot/IncrementalDocumentSnapshot.js.map +1 -0
  723. package/es/api/snapshot/index.d.ts +4 -0
  724. package/es/api/snapshot/index.d.ts.map +1 -0
  725. package/es/api/snapshot/index.js +4 -0
  726. package/es/api/snapshot/index.js.map +1 -0
  727. package/es/api/svgPath.d.ts +3 -0
  728. package/es/api/svgPath.d.ts.map +1 -0
  729. package/es/api/svgPath.js +377 -0
  730. package/es/api/svgPath.js.map +1 -0
  731. package/es/api/text/alignment.d.ts +6 -0
  732. package/es/api/text/alignment.d.ts.map +1 -0
  733. package/es/api/text/alignment.js +7 -0
  734. package/es/api/text/alignment.js.map +1 -0
  735. package/es/api/text/index.d.ts +3 -0
  736. package/es/api/text/index.d.ts.map +1 -0
  737. package/es/api/text/index.js +3 -0
  738. package/es/api/text/index.js.map +1 -0
  739. package/es/api/text/layout.d.ts +55 -0
  740. package/es/api/text/layout.d.ts.map +1 -0
  741. package/es/api/text/layout.js +209 -0
  742. package/es/api/text/layout.js.map +1 -0
  743. package/es/core/PDFContext.d.ts +93 -0
  744. package/es/core/PDFContext.d.ts.map +1 -0
  745. package/es/core/PDFContext.js +208 -0
  746. package/es/core/PDFContext.js.map +1 -0
  747. package/es/core/PDFObjectCopier.d.ts +38 -0
  748. package/es/core/PDFObjectCopier.d.ts.map +1 -0
  749. package/es/core/PDFObjectCopier.js +116 -0
  750. package/es/core/PDFObjectCopier.js.map +1 -0
  751. package/es/core/acroform/PDFAcroButton.d.ts +22 -0
  752. package/es/core/acroform/PDFAcroButton.d.ts.map +1 -0
  753. package/es/core/acroform/PDFAcroButton.js +94 -0
  754. package/es/core/acroform/PDFAcroButton.js.map +1 -0
  755. package/es/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  756. package/es/core/acroform/PDFAcroCheckBox.d.ts.map +1 -0
  757. package/es/core/acroform/PDFAcroCheckBox.js +48 -0
  758. package/es/core/acroform/PDFAcroCheckBox.js.map +1 -0
  759. package/es/core/acroform/PDFAcroChoice.d.ts +21 -0
  760. package/es/core/acroform/PDFAcroChoice.d.ts.map +1 -0
  761. package/es/core/acroform/PDFAcroChoice.js +125 -0
  762. package/es/core/acroform/PDFAcroChoice.js.map +1 -0
  763. package/es/core/acroform/PDFAcroComboBox.d.ts +10 -0
  764. package/es/core/acroform/PDFAcroComboBox.d.ts.map +1 -0
  765. package/es/core/acroform/PDFAcroComboBox.js +24 -0
  766. package/es/core/acroform/PDFAcroComboBox.js.map +1 -0
  767. package/es/core/acroform/PDFAcroField.d.ts +37 -0
  768. package/es/core/acroform/PDFAcroField.d.ts.map +1 -0
  769. package/es/core/acroform/PDFAcroField.js +146 -0
  770. package/es/core/acroform/PDFAcroField.js.map +1 -0
  771. package/es/core/acroform/PDFAcroForm.d.ts +21 -0
  772. package/es/core/acroform/PDFAcroForm.d.ts.map +1 -0
  773. package/es/core/acroform/PDFAcroForm.js +75 -0
  774. package/es/core/acroform/PDFAcroForm.js.map +1 -0
  775. package/es/core/acroform/PDFAcroListBox.d.ts +10 -0
  776. package/es/core/acroform/PDFAcroListBox.d.ts.map +1 -0
  777. package/es/core/acroform/PDFAcroListBox.js +22 -0
  778. package/es/core/acroform/PDFAcroListBox.js.map +1 -0
  779. package/es/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  780. package/es/core/acroform/PDFAcroNonTerminal.d.ts.map +1 -0
  781. package/es/core/acroform/PDFAcroNonTerminal.js +32 -0
  782. package/es/core/acroform/PDFAcroNonTerminal.js.map +1 -0
  783. package/es/core/acroform/PDFAcroPushButton.d.ts +10 -0
  784. package/es/core/acroform/PDFAcroPushButton.d.ts.map +1 -0
  785. package/es/core/acroform/PDFAcroPushButton.js +24 -0
  786. package/es/core/acroform/PDFAcroPushButton.js.map +1 -0
  787. package/es/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  788. package/es/core/acroform/PDFAcroRadioButton.d.ts.map +1 -0
  789. package/es/core/acroform/PDFAcroRadioButton.js +55 -0
  790. package/es/core/acroform/PDFAcroRadioButton.js.map +1 -0
  791. package/es/core/acroform/PDFAcroSignature.d.ts +8 -0
  792. package/es/core/acroform/PDFAcroSignature.d.ts.map +1 -0
  793. package/es/core/acroform/PDFAcroSignature.js +14 -0
  794. package/es/core/acroform/PDFAcroSignature.js.map +1 -0
  795. package/es/core/acroform/PDFAcroTerminal.d.ts +17 -0
  796. package/es/core/acroform/PDFAcroTerminal.d.ts.map +1 -0
  797. package/es/core/acroform/PDFAcroTerminal.js +68 -0
  798. package/es/core/acroform/PDFAcroTerminal.js.map +1 -0
  799. package/es/core/acroform/PDFAcroText.d.ts +23 -0
  800. package/es/core/acroform/PDFAcroText.d.ts.map +1 -0
  801. package/es/core/acroform/PDFAcroText.js +71 -0
  802. package/es/core/acroform/PDFAcroText.js.map +1 -0
  803. package/es/core/acroform/flags.d.ts +142 -0
  804. package/es/core/acroform/flags.d.ts.map +1 -0
  805. package/es/core/acroform/flags.js +147 -0
  806. package/es/core/acroform/flags.js.map +1 -0
  807. package/es/core/acroform/index.d.ts +16 -0
  808. package/es/core/acroform/index.d.ts.map +1 -0
  809. package/es/core/acroform/index.js +16 -0
  810. package/es/core/acroform/index.js.map +1 -0
  811. package/es/core/acroform/utils.d.ts +7 -0
  812. package/es/core/acroform/utils.d.ts.map +1 -0
  813. package/es/core/acroform/utils.js +123 -0
  814. package/es/core/acroform/utils.js.map +1 -0
  815. package/es/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  816. package/es/core/annotation/AppearanceCharacteristics.d.ts.map +1 -0
  817. package/es/core/annotation/AppearanceCharacteristics.js +120 -0
  818. package/es/core/annotation/AppearanceCharacteristics.js.map +1 -0
  819. package/es/core/annotation/BorderStyle.d.ts +12 -0
  820. package/es/core/annotation/BorderStyle.d.ts.map +1 -0
  821. package/es/core/annotation/BorderStyle.js +26 -0
  822. package/es/core/annotation/BorderStyle.js.map +1 -0
  823. package/es/core/annotation/PDFAnnotation.d.ts +52 -0
  824. package/es/core/annotation/PDFAnnotation.d.ts.map +1 -0
  825. package/es/core/annotation/PDFAnnotation.js +120 -0
  826. package/es/core/annotation/PDFAnnotation.js.map +1 -0
  827. package/es/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  828. package/es/core/annotation/PDFWidgetAnnotation.d.ts.map +1 -0
  829. package/es/core/annotation/PDFWidgetAnnotation.js +108 -0
  830. package/es/core/annotation/PDFWidgetAnnotation.js.map +1 -0
  831. package/es/core/annotation/flags.d.ts +80 -0
  832. package/es/core/annotation/flags.d.ts.map +1 -0
  833. package/es/core/annotation/flags.js +82 -0
  834. package/es/core/annotation/flags.js.map +1 -0
  835. package/es/core/annotation/index.d.ts +5 -0
  836. package/es/core/annotation/index.d.ts.map +1 -0
  837. package/es/core/annotation/index.js +5 -0
  838. package/es/core/annotation/index.js.map +1 -0
  839. package/es/core/document/PDFCrossRefSection.d.ts +28 -0
  840. package/es/core/document/PDFCrossRefSection.d.ts.map +1 -0
  841. package/es/core/document/PDFCrossRefSection.js +121 -0
  842. package/es/core/document/PDFCrossRefSection.js.map +1 -0
  843. package/es/core/document/PDFHeader.d.ts +11 -0
  844. package/es/core/document/PDFHeader.d.ts.map +1 -0
  845. package/es/core/document/PDFHeader.js +39 -0
  846. package/es/core/document/PDFHeader.js.map +1 -0
  847. package/es/core/document/PDFTrailer.d.ts +10 -0
  848. package/es/core/document/PDFTrailer.d.ts.map +1 -0
  849. package/es/core/document/PDFTrailer.js +40 -0
  850. package/es/core/document/PDFTrailer.js.map +1 -0
  851. package/es/core/document/PDFTrailerDict.d.ts +11 -0
  852. package/es/core/document/PDFTrailerDict.d.ts.map +1 -0
  853. package/es/core/document/PDFTrailerDict.js +29 -0
  854. package/es/core/document/PDFTrailerDict.js.map +1 -0
  855. package/es/core/embedders/CMap.d.ts +4 -0
  856. package/es/core/embedders/CMap.d.ts.map +1 -0
  857. package/es/core/embedders/CMap.js +40 -0
  858. package/es/core/embedders/CMap.js.map +1 -0
  859. package/es/core/embedders/CustomFontEmbedder.d.ts +45 -0
  860. package/es/core/embedders/CustomFontEmbedder.d.ts.map +1 -0
  861. package/es/core/embedders/CustomFontEmbedder.js +238 -0
  862. package/es/core/embedders/CustomFontEmbedder.js.map +1 -0
  863. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  864. package/es/core/embedders/CustomFontSubsetEmbedder.d.ts.map +1 -0
  865. package/es/core/embedders/CustomFontSubsetEmbedder.js +66 -0
  866. package/es/core/embedders/CustomFontSubsetEmbedder.js.map +1 -0
  867. package/es/core/embedders/FileEmbedder.d.ts +34 -0
  868. package/es/core/embedders/FileEmbedder.d.ts.map +1 -0
  869. package/es/core/embedders/FileEmbedder.js +72 -0
  870. package/es/core/embedders/FileEmbedder.js.map +1 -0
  871. package/es/core/embedders/FontFlags.d.ts +14 -0
  872. package/es/core/embedders/FontFlags.d.ts.map +1 -0
  873. package/es/core/embedders/FontFlags.js +37 -0
  874. package/es/core/embedders/FontFlags.js.map +1 -0
  875. package/es/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  876. package/es/core/embedders/JavaScriptEmbedder.d.ts.map +1 -0
  877. package/es/core/embedders/JavaScriptEmbedder.js +34 -0
  878. package/es/core/embedders/JavaScriptEmbedder.js.map +1 -0
  879. package/es/core/embedders/JpegEmbedder.d.ts +24 -0
  880. package/es/core/embedders/JpegEmbedder.d.ts.map +1 -0
  881. package/es/core/embedders/JpegEmbedder.js +105 -0
  882. package/es/core/embedders/JpegEmbedder.js.map +1 -0
  883. package/es/core/embedders/PDFPageEmbedder.d.ts +38 -0
  884. package/es/core/embedders/PDFPageEmbedder.d.ts.map +1 -0
  885. package/es/core/embedders/PDFPageEmbedder.js +89 -0
  886. package/es/core/embedders/PDFPageEmbedder.js.map +1 -0
  887. package/es/core/embedders/PngEmbedder.d.ts +20 -0
  888. package/es/core/embedders/PngEmbedder.d.ts.map +1 -0
  889. package/es/core/embedders/PngEmbedder.js +67 -0
  890. package/es/core/embedders/PngEmbedder.js.map +1 -0
  891. package/es/core/embedders/StandardFontEmbedder.d.ts +37 -0
  892. package/es/core/embedders/StandardFontEmbedder.d.ts.map +1 -0
  893. package/es/core/embedders/StandardFontEmbedder.js +95 -0
  894. package/es/core/embedders/StandardFontEmbedder.js.map +1 -0
  895. package/es/core/errors.d.ts +92 -0
  896. package/es/core/errors.d.ts.map +1 -0
  897. package/es/core/errors.js +320 -0
  898. package/es/core/errors.js.map +1 -0
  899. package/es/core/index.d.ts +48 -0
  900. package/es/core/index.d.ts.map +1 -0
  901. package/es/core/index.js +48 -0
  902. package/es/core/index.js.map +1 -0
  903. package/es/core/interactive/ViewerPreferences.d.ts +348 -0
  904. package/es/core/interactive/ViewerPreferences.d.ts.map +1 -0
  905. package/es/core/interactive/ViewerPreferences.js +507 -0
  906. package/es/core/interactive/ViewerPreferences.js.map +1 -0
  907. package/es/core/objects/PDFArray.d.ts +64 -0
  908. package/es/core/objects/PDFArray.d.ts.map +1 -0
  909. package/es/core/objects/PDFArray.js +115 -0
  910. package/es/core/objects/PDFArray.js.map +1 -0
  911. package/es/core/objects/PDFBool.d.ts +14 -0
  912. package/es/core/objects/PDFBool.d.ts.map +1 -0
  913. package/es/core/objects/PDFBool.js +50 -0
  914. package/es/core/objects/PDFBool.js.map +1 -0
  915. package/es/core/objects/PDFDict.d.ts +63 -0
  916. package/es/core/objects/PDFDict.d.ts.map +1 -0
  917. package/es/core/objects/PDFDict.js +141 -0
  918. package/es/core/objects/PDFDict.js.map +1 -0
  919. package/es/core/objects/PDFHexString.d.ts +17 -0
  920. package/es/core/objects/PDFHexString.d.ts.map +1 -0
  921. package/es/core/objects/PDFHexString.js +72 -0
  922. package/es/core/objects/PDFHexString.js.map +1 -0
  923. package/es/core/objects/PDFInvalidObject.d.ts +12 -0
  924. package/es/core/objects/PDFInvalidObject.d.ts.map +1 -0
  925. package/es/core/objects/PDFInvalidObject.js +30 -0
  926. package/es/core/objects/PDFInvalidObject.js.map +1 -0
  927. package/es/core/objects/PDFName.d.ts +42 -0
  928. package/es/core/objects/PDFName.d.ts.map +1 -0
  929. package/es/core/objects/PDFName.js +136 -0
  930. package/es/core/objects/PDFName.js.map +1 -0
  931. package/es/core/objects/PDFNull.d.ts +11 -0
  932. package/es/core/objects/PDFNull.d.ts.map +1 -0
  933. package/es/core/objects/PDFNull.js +31 -0
  934. package/es/core/objects/PDFNull.js.map +1 -0
  935. package/es/core/objects/PDFNumber.d.ts +16 -0
  936. package/es/core/objects/PDFNumber.d.ts.map +1 -0
  937. package/es/core/objects/PDFNumber.js +36 -0
  938. package/es/core/objects/PDFNumber.js.map +1 -0
  939. package/es/core/objects/PDFObject.d.ts +10 -0
  940. package/es/core/objects/PDFObject.d.ts.map +1 -0
  941. package/es/core/objects/PDFObject.js +23 -0
  942. package/es/core/objects/PDFObject.js.map +1 -0
  943. package/es/core/objects/PDFRawStream.d.ts +15 -0
  944. package/es/core/objects/PDFRawStream.d.ts.map +1 -0
  945. package/es/core/objects/PDFRawStream.js +32 -0
  946. package/es/core/objects/PDFRawStream.js.map +1 -0
  947. package/es/core/objects/PDFRef.d.ts +14 -0
  948. package/es/core/objects/PDFRef.d.ts.map +1 -0
  949. package/es/core/objects/PDFRef.js +45 -0
  950. package/es/core/objects/PDFRef.js.map +1 -0
  951. package/es/core/objects/PDFStream.d.ts +17 -0
  952. package/es/core/objects/PDFStream.d.ts.map +1 -0
  953. package/es/core/objects/PDFStream.js +73 -0
  954. package/es/core/objects/PDFStream.js.map +1 -0
  955. package/es/core/objects/PDFString.d.ts +17 -0
  956. package/es/core/objects/PDFString.d.ts.map +1 -0
  957. package/es/core/objects/PDFString.js +114 -0
  958. package/es/core/objects/PDFString.js.map +1 -0
  959. package/es/core/operators/PDFOperator.d.ts +20 -0
  960. package/es/core/operators/PDFOperator.d.ts.map +1 -0
  961. package/es/core/operators/PDFOperator.js +55 -0
  962. package/es/core/operators/PDFOperator.js.map +1 -0
  963. package/es/core/operators/PDFOperatorNames.d.ts +77 -0
  964. package/es/core/operators/PDFOperatorNames.d.ts.map +1 -0
  965. package/es/core/operators/PDFOperatorNames.js +86 -0
  966. package/es/core/operators/PDFOperatorNames.js.map +1 -0
  967. package/es/core/parser/BaseParser.d.ts +15 -0
  968. package/es/core/parser/BaseParser.d.ts.map +1 -0
  969. package/es/core/parser/BaseParser.js +107 -0
  970. package/es/core/parser/BaseParser.js.map +1 -0
  971. package/es/core/parser/ByteStream.d.ts +27 -0
  972. package/es/core/parser/ByteStream.d.ts.map +1 -0
  973. package/es/core/parser/ByteStream.js +61 -0
  974. package/es/core/parser/ByteStream.js.map +1 -0
  975. package/es/core/parser/PDFObjectParser.d.ts +30 -0
  976. package/es/core/parser/PDFObjectParser.d.ts.map +1 -0
  977. package/es/core/parser/PDFObjectParser.js +231 -0
  978. package/es/core/parser/PDFObjectParser.js.map +1 -0
  979. package/es/core/parser/PDFObjectStreamParser.d.ts +14 -0
  980. package/es/core/parser/PDFObjectStreamParser.d.ts.map +1 -0
  981. package/es/core/parser/PDFObjectStreamParser.js +68 -0
  982. package/es/core/parser/PDFObjectStreamParser.js.map +1 -0
  983. package/es/core/parser/PDFParser.d.ts +46 -0
  984. package/es/core/parser/PDFParser.d.ts.map +1 -0
  985. package/es/core/parser/PDFParser.js +360 -0
  986. package/es/core/parser/PDFParser.js.map +1 -0
  987. package/es/core/parser/PDFXRefStreamParser.d.ts +22 -0
  988. package/es/core/parser/PDFXRefStreamParser.d.ts.map +1 -0
  989. package/es/core/parser/PDFXRefStreamParser.js +90 -0
  990. package/es/core/parser/PDFXRefStreamParser.js.map +1 -0
  991. package/es/core/streams/Ascii85Stream.d.ts +10 -0
  992. package/es/core/streams/Ascii85Stream.d.ts.map +1 -0
  993. package/es/core/streams/Ascii85Stream.js +85 -0
  994. package/es/core/streams/Ascii85Stream.js.map +1 -0
  995. package/es/core/streams/AsciiHexStream.d.ts +10 -0
  996. package/es/core/streams/AsciiHexStream.d.ts.map +1 -0
  997. package/es/core/streams/AsciiHexStream.js +73 -0
  998. package/es/core/streams/AsciiHexStream.js.map +1 -0
  999. package/es/core/streams/DecodeStream.d.ts +27 -0
  1000. package/es/core/streams/DecodeStream.d.ts.map +1 -0
  1001. package/es/core/streams/DecodeStream.js +146 -0
  1002. package/es/core/streams/DecodeStream.js.map +1 -0
  1003. package/es/core/streams/FlateStream.d.ts +14 -0
  1004. package/es/core/streams/FlateStream.d.ts.map +1 -0
  1005. package/es/core/streams/FlateStream.js +369 -0
  1006. package/es/core/streams/FlateStream.js.map +1 -0
  1007. package/es/core/streams/LZWStream.d.ts +13 -0
  1008. package/es/core/streams/LZWStream.d.ts.map +1 -0
  1009. package/es/core/streams/LZWStream.js +135 -0
  1010. package/es/core/streams/LZWStream.js.map +1 -0
  1011. package/es/core/streams/RunLengthStream.d.ts +9 -0
  1012. package/es/core/streams/RunLengthStream.d.ts.map +1 -0
  1013. package/es/core/streams/RunLengthStream.js +53 -0
  1014. package/es/core/streams/RunLengthStream.js.map +1 -0
  1015. package/es/core/streams/Stream.d.ts +35 -0
  1016. package/es/core/streams/Stream.d.ts.map +1 -0
  1017. package/es/core/streams/Stream.js +104 -0
  1018. package/es/core/streams/Stream.js.map +1 -0
  1019. package/es/core/streams/decode.d.ts +4 -0
  1020. package/es/core/streams/decode.d.ts.map +1 -0
  1021. package/es/core/streams/decode.js +55 -0
  1022. package/es/core/streams/decode.js.map +1 -0
  1023. package/es/core/structures/PDFCatalog.d.ts +28 -0
  1024. package/es/core/structures/PDFCatalog.d.ts.map +1 -0
  1025. package/es/core/structures/PDFCatalog.js +77 -0
  1026. package/es/core/structures/PDFCatalog.js.map +1 -0
  1027. package/es/core/structures/PDFContentStream.d.ts +16 -0
  1028. package/es/core/structures/PDFContentStream.d.ts.map +1 -0
  1029. package/es/core/structures/PDFContentStream.js +58 -0
  1030. package/es/core/structures/PDFContentStream.js.map +1 -0
  1031. package/es/core/structures/PDFCrossRefStream.d.ts +54 -0
  1032. package/es/core/structures/PDFCrossRefStream.d.ts.map +1 -0
  1033. package/es/core/structures/PDFCrossRefStream.js +184 -0
  1034. package/es/core/structures/PDFCrossRefStream.js.map +1 -0
  1035. package/es/core/structures/PDFFlateStream.d.ts +14 -0
  1036. package/es/core/structures/PDFFlateStream.d.ts.map +1 -0
  1037. package/es/core/structures/PDFFlateStream.js +33 -0
  1038. package/es/core/structures/PDFFlateStream.js.map +1 -0
  1039. package/es/core/structures/PDFObjectStream.d.ts +21 -0
  1040. package/es/core/structures/PDFObjectStream.d.ts.map +1 -0
  1041. package/es/core/structures/PDFObjectStream.js +75 -0
  1042. package/es/core/structures/PDFObjectStream.js.map +1 -0
  1043. package/es/core/structures/PDFPageLeaf.d.ts +55 -0
  1044. package/es/core/structures/PDFPageLeaf.d.ts.map +1 -0
  1045. package/es/core/structures/PDFPageLeaf.js +206 -0
  1046. package/es/core/structures/PDFPageLeaf.js.map +1 -0
  1047. package/es/core/structures/PDFPageTree.d.ts +42 -0
  1048. package/es/core/structures/PDFPageTree.d.ts.map +1 -0
  1049. package/es/core/structures/PDFPageTree.js +175 -0
  1050. package/es/core/structures/PDFPageTree.js.map +1 -0
  1051. package/es/core/syntax/CharCodes.d.ts +62 -0
  1052. package/es/core/syntax/CharCodes.d.ts.map +1 -0
  1053. package/es/core/syntax/CharCodes.js +63 -0
  1054. package/es/core/syntax/CharCodes.js.map +1 -0
  1055. package/es/core/syntax/Delimiters.d.ts +2 -0
  1056. package/es/core/syntax/Delimiters.d.ts.map +1 -0
  1057. package/es/core/syntax/Delimiters.js +13 -0
  1058. package/es/core/syntax/Delimiters.js.map +1 -0
  1059. package/es/core/syntax/Irregular.d.ts +2 -0
  1060. package/es/core/syntax/Irregular.d.ts.map +1 -0
  1061. package/es/core/syntax/Irregular.js +9 -0
  1062. package/es/core/syntax/Irregular.js.map +1 -0
  1063. package/es/core/syntax/Keywords.d.ts +23 -0
  1064. package/es/core/syntax/Keywords.d.ts.map +1 -0
  1065. package/es/core/syntax/Keywords.js +81 -0
  1066. package/es/core/syntax/Keywords.js.map +1 -0
  1067. package/es/core/syntax/Numeric.d.ts +4 -0
  1068. package/es/core/syntax/Numeric.d.ts.map +1 -0
  1069. package/es/core/syntax/Numeric.js +21 -0
  1070. package/es/core/syntax/Numeric.js.map +1 -0
  1071. package/es/core/syntax/Whitespace.d.ts +2 -0
  1072. package/es/core/syntax/Whitespace.d.ts.map +1 -0
  1073. package/es/core/syntax/Whitespace.js +9 -0
  1074. package/es/core/syntax/Whitespace.js.map +1 -0
  1075. package/es/core/writers/PDFStreamWriter.d.ts +22 -0
  1076. package/es/core/writers/PDFStreamWriter.d.ts.map +1 -0
  1077. package/es/core/writers/PDFStreamWriter.js +131 -0
  1078. package/es/core/writers/PDFStreamWriter.js.map +1 -0
  1079. package/es/core/writers/PDFWriter.d.ts +33 -0
  1080. package/es/core/writers/PDFWriter.d.ts.map +1 -0
  1081. package/es/core/writers/PDFWriter.js +162 -0
  1082. package/es/core/writers/PDFWriter.js.map +1 -0
  1083. package/es/index.d.ts +5 -0
  1084. package/es/index.d.ts.map +1 -0
  1085. package/es/index.js +5 -0
  1086. package/es/index.js.map +1 -0
  1087. package/es/types/fontkit.d.ts +582 -0
  1088. package/es/types/fontkit.d.ts.map +1 -0
  1089. package/es/types/fontkit.js +1 -0
  1090. package/es/types/fontkit.js.map +1 -0
  1091. package/es/types/index.d.ts +2 -0
  1092. package/es/types/index.d.ts.map +1 -0
  1093. package/es/types/index.js +1 -0
  1094. package/es/types/index.js.map +1 -0
  1095. package/es/types/matrix.d.ts +22 -0
  1096. package/es/types/matrix.d.ts.map +1 -0
  1097. package/es/types/matrix.js +2 -0
  1098. package/es/types/matrix.js.map +1 -0
  1099. package/es/utils/Cache.d.ts +11 -0
  1100. package/es/utils/Cache.d.ts.map +1 -0
  1101. package/es/utils/Cache.js +21 -0
  1102. package/es/utils/Cache.js.map +1 -0
  1103. package/es/utils/arrays.d.ts +16 -0
  1104. package/es/utils/arrays.d.ts.map +1 -0
  1105. package/es/utils/arrays.js +129 -0
  1106. package/es/utils/arrays.js.map +1 -0
  1107. package/es/utils/async.d.ts +6 -0
  1108. package/es/utils/async.d.ts.map +1 -0
  1109. package/es/utils/async.js +10 -0
  1110. package/es/utils/async.js.map +1 -0
  1111. package/es/utils/base64.d.ts +11 -0
  1112. package/es/utils/base64.d.ts.map +1 -0
  1113. package/es/utils/base64.js +84 -0
  1114. package/es/utils/base64.js.map +1 -0
  1115. package/es/utils/errors.d.ts +2 -0
  1116. package/es/utils/errors.d.ts.map +1 -0
  1117. package/es/utils/errors.js +4 -0
  1118. package/es/utils/errors.js.map +1 -0
  1119. package/es/utils/index.d.ts +12 -0
  1120. package/es/utils/index.d.ts.map +1 -0
  1121. package/es/utils/index.js +12 -0
  1122. package/es/utils/index.js.map +1 -0
  1123. package/es/utils/numbers.d.ts +24 -0
  1124. package/es/utils/numbers.d.ts.map +1 -0
  1125. package/es/utils/numbers.js +54 -0
  1126. package/es/utils/numbers.js.map +1 -0
  1127. package/es/utils/objects.d.ts +16 -0
  1128. package/es/utils/objects.d.ts.map +1 -0
  1129. package/es/utils/objects.js +8 -0
  1130. package/es/utils/objects.js.map +1 -0
  1131. package/es/utils/pdfDocEncoding.d.ts +8 -0
  1132. package/es/utils/pdfDocEncoding.d.ts.map +1 -0
  1133. package/es/utils/pdfDocEncoding.js +66 -0
  1134. package/es/utils/pdfDocEncoding.js.map +1 -0
  1135. package/es/utils/png.d.ts +18 -0
  1136. package/es/utils/png.d.ts.map +1 -0
  1137. package/es/utils/png.js +59 -0
  1138. package/es/utils/png.js.map +1 -0
  1139. package/es/utils/rng.d.ts +14 -0
  1140. package/es/utils/rng.d.ts.map +1 -0
  1141. package/es/utils/rng.js +20 -0
  1142. package/es/utils/rng.js.map +1 -0
  1143. package/es/utils/strings.d.ts +25 -0
  1144. package/es/utils/strings.d.ts.map +1 -0
  1145. package/es/utils/strings.js +138 -0
  1146. package/es/utils/strings.js.map +1 -0
  1147. package/es/utils/unicode.d.ts +187 -0
  1148. package/es/utils/unicode.d.ts.map +1 -0
  1149. package/es/utils/unicode.js +367 -0
  1150. package/es/utils/unicode.js.map +1 -0
  1151. package/es/utils/validators.d.ts +27 -0
  1152. package/es/utils/validators.d.ts.map +1 -0
  1153. package/es/utils/validators.js +180 -0
  1154. package/es/utils/validators.js.map +1 -0
  1155. package/package.json +144 -0
  1156. package/src/api/Embeddable.ts +7 -0
  1157. package/src/api/PDFDocument.ts +1495 -0
  1158. package/src/api/PDFDocumentOptions.ts +50 -0
  1159. package/src/api/PDFEmbeddedFile.ts +90 -0
  1160. package/src/api/PDFEmbeddedPage.ts +104 -0
  1161. package/src/api/PDFFont.ts +154 -0
  1162. package/src/api/PDFImage.ts +143 -0
  1163. package/src/api/PDFJavaScript.ts +82 -0
  1164. package/src/api/PDFPage.ts +1621 -0
  1165. package/src/api/PDFPageOptions.ts +158 -0
  1166. package/src/api/StandardFonts.ts +16 -0
  1167. package/src/api/colors.ts +104 -0
  1168. package/src/api/errors.ts +111 -0
  1169. package/src/api/form/PDFButton.ts +267 -0
  1170. package/src/api/form/PDFCheckBox.ts +262 -0
  1171. package/src/api/form/PDFDropdown.ts +652 -0
  1172. package/src/api/form/PDFField.ts +521 -0
  1173. package/src/api/form/PDFForm.ts +852 -0
  1174. package/src/api/form/PDFOptionList.ts +571 -0
  1175. package/src/api/form/PDFRadioGroup.ts +471 -0
  1176. package/src/api/form/PDFSignature.ts +53 -0
  1177. package/src/api/form/PDFTextField.ts +826 -0
  1178. package/src/api/form/appearances.ts +665 -0
  1179. package/src/api/form/index.ts +10 -0
  1180. package/src/api/image/alignment.ts +5 -0
  1181. package/src/api/image/index.ts +1 -0
  1182. package/src/api/index.ts +21 -0
  1183. package/src/api/objects.ts +10 -0
  1184. package/src/api/operations.ts +800 -0
  1185. package/src/api/operators.ts +360 -0
  1186. package/src/api/rotations.ts +87 -0
  1187. package/src/api/sizes.ts +52 -0
  1188. package/src/api/snapshot/DefaultDocumentSnapshot.ts +29 -0
  1189. package/src/api/snapshot/DocumentSnapshot.ts +14 -0
  1190. package/src/api/snapshot/IncrementalDocumentSnapshot.ts +59 -0
  1191. package/src/api/snapshot/index.ts +3 -0
  1192. package/src/api/svgPath.ts +489 -0
  1193. package/src/api/text/alignment.ts +5 -0
  1194. package/src/api/text/index.ts +2 -0
  1195. package/src/api/text/layout.ts +343 -0
  1196. package/src/core/PDFContext.ts +316 -0
  1197. package/src/core/PDFObjectCopier.ts +143 -0
  1198. package/src/core/acroform/PDFAcroButton.ts +114 -0
  1199. package/src/core/acroform/PDFAcroCheckBox.ts +49 -0
  1200. package/src/core/acroform/PDFAcroChoice.ts +153 -0
  1201. package/src/core/acroform/PDFAcroComboBox.ts +22 -0
  1202. package/src/core/acroform/PDFAcroField.ts +167 -0
  1203. package/src/core/acroform/PDFAcroForm.ts +102 -0
  1204. package/src/core/acroform/PDFAcroListBox.ts +20 -0
  1205. package/src/core/acroform/PDFAcroNonTerminal.ts +34 -0
  1206. package/src/core/acroform/PDFAcroPushButton.ts +22 -0
  1207. package/src/core/acroform/PDFAcroRadioButton.ts +58 -0
  1208. package/src/core/acroform/PDFAcroSignature.ts +10 -0
  1209. package/src/core/acroform/PDFAcroTerminal.ts +71 -0
  1210. package/src/core/acroform/PDFAcroText.ts +76 -0
  1211. package/src/core/acroform/flags.ts +162 -0
  1212. package/src/core/acroform/index.ts +15 -0
  1213. package/src/core/acroform/utils.ts +135 -0
  1214. package/src/core/annotation/AppearanceCharacteristics.ts +133 -0
  1215. package/src/core/annotation/BorderStyle.ts +31 -0
  1216. package/src/core/annotation/PDFAnnotation.ts +148 -0
  1217. package/src/core/annotation/PDFWidgetAnnotation.ts +112 -0
  1218. package/src/core/annotation/flags.ts +90 -0
  1219. package/src/core/annotation/index.ts +4 -0
  1220. package/src/core/document/PDFCrossRefSection.ts +173 -0
  1221. package/src/core/document/PDFHeader.ts +49 -0
  1222. package/src/core/document/PDFTrailer.ts +49 -0
  1223. package/src/core/document/PDFTrailerDict.ts +39 -0
  1224. package/src/core/embedders/CMap.ts +70 -0
  1225. package/src/core/embedders/CustomFontEmbedder.ts +249 -0
  1226. package/src/core/embedders/CustomFontSubsetEmbedder.ts +84 -0
  1227. package/src/core/embedders/FileEmbedder.ts +95 -0
  1228. package/src/core/embedders/FontFlags.ts +45 -0
  1229. package/src/core/embedders/JavaScriptEmbedder.ts +34 -0
  1230. package/src/core/embedders/JpegEmbedder.ts +127 -0
  1231. package/src/core/embedders/PDFPageEmbedder.ts +141 -0
  1232. package/src/core/embedders/PngEmbedder.ts +69 -0
  1233. package/src/core/embedders/StandardFontEmbedder.ts +130 -0
  1234. package/src/core/errors.ts +221 -0
  1235. package/src/core/index.ts +69 -0
  1236. package/src/core/interactive/ViewerPreferences.ts +579 -0
  1237. package/src/core/objects/PDFArray.ts +185 -0
  1238. package/src/core/objects/PDFBool.ts +53 -0
  1239. package/src/core/objects/PDFDict.ts +232 -0
  1240. package/src/core/objects/PDFHexString.ts +94 -0
  1241. package/src/core/objects/PDFInvalidObject.ts +34 -0
  1242. package/src/core/objects/PDFName.ts +159 -0
  1243. package/src/core/objects/PDFNull.ts +30 -0
  1244. package/src/core/objects/PDFNumber.ts +44 -0
  1245. package/src/core/objects/PDFObject.ts +28 -0
  1246. package/src/core/objects/PDFRawStream.ts +38 -0
  1247. package/src/core/objects/PDFRef.ts +55 -0
  1248. package/src/core/objects/PDFStream.ts +93 -0
  1249. package/src/core/objects/PDFString.ts +118 -0
  1250. package/src/core/operators/PDFOperator.ts +79 -0
  1251. package/src/core/operators/PDFOperatorNames.ts +92 -0
  1252. package/src/core/parser/BaseParser.ts +119 -0
  1253. package/src/core/parser/ByteStream.ts +76 -0
  1254. package/src/core/parser/PDFObjectParser.ts +274 -0
  1255. package/src/core/parser/PDFObjectStreamParser.ts +67 -0
  1256. package/src/core/parser/PDFParser.ts +377 -0
  1257. package/src/core/parser/PDFXRefStreamParser.ts +131 -0
  1258. package/src/core/streams/Ascii85Stream.ts +98 -0
  1259. package/src/core/streams/AsciiHexStream.ts +77 -0
  1260. package/src/core/streams/DecodeStream.ts +170 -0
  1261. package/src/core/streams/FlateStream.ts +407 -0
  1262. package/src/core/streams/LZWStream.ts +164 -0
  1263. package/src/core/streams/RunLengthStream.ts +55 -0
  1264. package/src/core/streams/Stream.ts +132 -0
  1265. package/src/core/streams/decode.ts +73 -0
  1266. package/src/core/structures/PDFCatalog.ts +85 -0
  1267. package/src/core/structures/PDFContentStream.ts +58 -0
  1268. package/src/core/structures/PDFCrossRefStream.ts +246 -0
  1269. package/src/core/structures/PDFFlateStream.ts +43 -0
  1270. package/src/core/structures/PDFObjectStream.ts +101 -0
  1271. package/src/core/structures/PDFPageLeaf.ts +265 -0
  1272. package/src/core/structures/PDFPageTree.ts +195 -0
  1273. package/src/core/syntax/CharCodes.ts +62 -0
  1274. package/src/core/syntax/Delimiters.ts +14 -0
  1275. package/src/core/syntax/Irregular.ts +10 -0
  1276. package/src/core/syntax/Keywords.ts +83 -0
  1277. package/src/core/syntax/Numeric.ts +26 -0
  1278. package/src/core/syntax/Whitespace.ts +10 -0
  1279. package/src/core/writers/PDFStreamWriter.ts +158 -0
  1280. package/src/core/writers/PDFWriter.ts +194 -0
  1281. package/src/index.ts +4 -0
  1282. package/src/types/fontkit.ts +640 -0
  1283. package/src/types/index.ts +1 -0
  1284. package/src/types/matrix.ts +29 -0
  1285. package/src/utils/Cache.ts +26 -0
  1286. package/src/utils/arrays.ts +146 -0
  1287. package/src/utils/async.ts +8 -0
  1288. package/src/utils/base64.ts +99 -0
  1289. package/src/utils/errors.ts +3 -0
  1290. package/src/utils/index.ts +11 -0
  1291. package/src/utils/numbers.ts +55 -0
  1292. package/src/utils/objects.ts +13 -0
  1293. package/src/utils/pdfDocEncoding.ts +69 -0
  1294. package/src/utils/png.ts +70 -0
  1295. package/src/utils/rng.ts +21 -0
  1296. package/src/utils/strings.ts +182 -0
  1297. package/src/utils/unicode.ts +386 -0
  1298. package/src/utils/validators.ts +228 -0
  1299. package/ts3.4/apps/deno/dummy.d.ts +20 -0
  1300. package/ts3.4/cjs/api/Embeddable.d.ts +8 -0
  1301. package/ts3.4/cjs/api/PDFDocument.d.ts +800 -0
  1302. package/ts3.4/cjs/api/PDFDocumentOptions.d.ts +43 -0
  1303. package/ts3.4/cjs/api/PDFEmbeddedFile.d.ts +39 -0
  1304. package/ts3.4/cjs/api/PDFEmbeddedPage.d.ts +74 -0
  1305. package/ts3.4/cjs/api/PDFFont.d.ts +95 -0
  1306. package/ts3.4/cjs/api/PDFImage.d.ts +96 -0
  1307. package/ts3.4/cjs/api/PDFJavaScript.d.ts +39 -0
  1308. package/ts3.4/cjs/api/PDFPage.d.ts +898 -0
  1309. package/ts3.4/cjs/api/PDFPageOptions.d.ts +155 -0
  1310. package/ts3.4/cjs/api/StandardFonts.d.ts +17 -0
  1311. package/ts3.4/cjs/api/colors.d.ts +31 -0
  1312. package/ts3.4/cjs/api/errors.d.ts +43 -0
  1313. package/ts3.4/cjs/api/form/PDFButton.d.ts +138 -0
  1314. package/ts3.4/cjs/api/form/PDFCheckBox.d.ts +143 -0
  1315. package/ts3.4/cjs/api/form/PDFDropdown.d.ts +403 -0
  1316. package/ts3.4/cjs/api/form/PDFField.d.ts +204 -0
  1317. package/ts3.4/cjs/api/form/PDFForm.d.ts +412 -0
  1318. package/ts3.4/cjs/api/form/PDFOptionList.d.ts +336 -0
  1319. package/ts3.4/cjs/api/form/PDFRadioGroup.d.ts +253 -0
  1320. package/ts3.4/cjs/api/form/PDFSignature.d.ts +30 -0
  1321. package/ts3.4/cjs/api/form/PDFTextField.d.ts +538 -0
  1322. package/ts3.4/cjs/api/form/appearances.d.ts +42 -0
  1323. package/ts3.4/cjs/api/form/index.d.ts +11 -0
  1324. package/ts3.4/cjs/api/image/alignment.d.ts +6 -0
  1325. package/ts3.4/cjs/api/image/index.d.ts +2 -0
  1326. package/ts3.4/cjs/api/index.d.ts +22 -0
  1327. package/ts3.4/cjs/api/objects.d.ts +5 -0
  1328. package/ts3.4/cjs/api/operations.d.ts +212 -0
  1329. package/ts3.4/cjs/api/operators.d.ts +86 -0
  1330. package/ts3.4/cjs/api/rotations.d.ts +39 -0
  1331. package/ts3.4/cjs/api/sizes.d.ts +53 -0
  1332. package/ts3.4/cjs/api/snapshot/DefaultDocumentSnapshot.d.ts +13 -0
  1333. package/ts3.4/cjs/api/snapshot/DocumentSnapshot.d.ts +11 -0
  1334. package/ts3.4/cjs/api/snapshot/IncrementalDocumentSnapshot.d.ts +16 -0
  1335. package/ts3.4/cjs/api/snapshot/index.d.ts +4 -0
  1336. package/ts3.4/cjs/api/svgPath.d.ts +3 -0
  1337. package/ts3.4/cjs/api/text/alignment.d.ts +6 -0
  1338. package/ts3.4/cjs/api/text/index.d.ts +3 -0
  1339. package/ts3.4/cjs/api/text/layout.d.ts +55 -0
  1340. package/ts3.4/cjs/core/PDFContext.d.ts +93 -0
  1341. package/ts3.4/cjs/core/PDFObjectCopier.d.ts +38 -0
  1342. package/ts3.4/cjs/core/acroform/PDFAcroButton.d.ts +22 -0
  1343. package/ts3.4/cjs/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  1344. package/ts3.4/cjs/core/acroform/PDFAcroChoice.d.ts +21 -0
  1345. package/ts3.4/cjs/core/acroform/PDFAcroComboBox.d.ts +10 -0
  1346. package/ts3.4/cjs/core/acroform/PDFAcroField.d.ts +37 -0
  1347. package/ts3.4/cjs/core/acroform/PDFAcroForm.d.ts +21 -0
  1348. package/ts3.4/cjs/core/acroform/PDFAcroListBox.d.ts +10 -0
  1349. package/ts3.4/cjs/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  1350. package/ts3.4/cjs/core/acroform/PDFAcroPushButton.d.ts +10 -0
  1351. package/ts3.4/cjs/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  1352. package/ts3.4/cjs/core/acroform/PDFAcroSignature.d.ts +8 -0
  1353. package/ts3.4/cjs/core/acroform/PDFAcroTerminal.d.ts +17 -0
  1354. package/ts3.4/cjs/core/acroform/PDFAcroText.d.ts +23 -0
  1355. package/ts3.4/cjs/core/acroform/flags.d.ts +142 -0
  1356. package/ts3.4/cjs/core/acroform/index.d.ts +16 -0
  1357. package/ts3.4/cjs/core/acroform/utils.d.ts +7 -0
  1358. package/ts3.4/cjs/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  1359. package/ts3.4/cjs/core/annotation/BorderStyle.d.ts +12 -0
  1360. package/ts3.4/cjs/core/annotation/PDFAnnotation.d.ts +52 -0
  1361. package/ts3.4/cjs/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  1362. package/ts3.4/cjs/core/annotation/flags.d.ts +80 -0
  1363. package/ts3.4/cjs/core/annotation/index.d.ts +5 -0
  1364. package/ts3.4/cjs/core/document/PDFCrossRefSection.d.ts +28 -0
  1365. package/ts3.4/cjs/core/document/PDFHeader.d.ts +11 -0
  1366. package/ts3.4/cjs/core/document/PDFTrailer.d.ts +10 -0
  1367. package/ts3.4/cjs/core/document/PDFTrailerDict.d.ts +11 -0
  1368. package/ts3.4/cjs/core/embedders/CMap.d.ts +4 -0
  1369. package/ts3.4/cjs/core/embedders/CustomFontEmbedder.d.ts +45 -0
  1370. package/ts3.4/cjs/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  1371. package/ts3.4/cjs/core/embedders/FileEmbedder.d.ts +34 -0
  1372. package/ts3.4/cjs/core/embedders/FontFlags.d.ts +14 -0
  1373. package/ts3.4/cjs/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  1374. package/ts3.4/cjs/core/embedders/JpegEmbedder.d.ts +24 -0
  1375. package/ts3.4/cjs/core/embedders/PDFPageEmbedder.d.ts +38 -0
  1376. package/ts3.4/cjs/core/embedders/PngEmbedder.d.ts +20 -0
  1377. package/ts3.4/cjs/core/embedders/StandardFontEmbedder.d.ts +37 -0
  1378. package/ts3.4/cjs/core/errors.d.ts +92 -0
  1379. package/ts3.4/cjs/core/index.d.ts +48 -0
  1380. package/ts3.4/cjs/core/interactive/ViewerPreferences.d.ts +348 -0
  1381. package/ts3.4/cjs/core/objects/PDFArray.d.ts +64 -0
  1382. package/ts3.4/cjs/core/objects/PDFBool.d.ts +14 -0
  1383. package/ts3.4/cjs/core/objects/PDFDict.d.ts +63 -0
  1384. package/ts3.4/cjs/core/objects/PDFHexString.d.ts +17 -0
  1385. package/ts3.4/cjs/core/objects/PDFInvalidObject.d.ts +12 -0
  1386. package/ts3.4/cjs/core/objects/PDFName.d.ts +42 -0
  1387. package/ts3.4/cjs/core/objects/PDFNull.d.ts +11 -0
  1388. package/ts3.4/cjs/core/objects/PDFNumber.d.ts +16 -0
  1389. package/ts3.4/cjs/core/objects/PDFObject.d.ts +10 -0
  1390. package/ts3.4/cjs/core/objects/PDFRawStream.d.ts +15 -0
  1391. package/ts3.4/cjs/core/objects/PDFRef.d.ts +14 -0
  1392. package/ts3.4/cjs/core/objects/PDFStream.d.ts +17 -0
  1393. package/ts3.4/cjs/core/objects/PDFString.d.ts +17 -0
  1394. package/ts3.4/cjs/core/operators/PDFOperator.d.ts +20 -0
  1395. package/ts3.4/cjs/core/operators/PDFOperatorNames.d.ts +77 -0
  1396. package/ts3.4/cjs/core/parser/BaseParser.d.ts +15 -0
  1397. package/ts3.4/cjs/core/parser/ByteStream.d.ts +27 -0
  1398. package/ts3.4/cjs/core/parser/PDFObjectParser.d.ts +30 -0
  1399. package/ts3.4/cjs/core/parser/PDFObjectStreamParser.d.ts +14 -0
  1400. package/ts3.4/cjs/core/parser/PDFParser.d.ts +46 -0
  1401. package/ts3.4/cjs/core/parser/PDFXRefStreamParser.d.ts +22 -0
  1402. package/ts3.4/cjs/core/streams/Ascii85Stream.d.ts +10 -0
  1403. package/ts3.4/cjs/core/streams/AsciiHexStream.d.ts +10 -0
  1404. package/ts3.4/cjs/core/streams/DecodeStream.d.ts +27 -0
  1405. package/ts3.4/cjs/core/streams/FlateStream.d.ts +14 -0
  1406. package/ts3.4/cjs/core/streams/LZWStream.d.ts +13 -0
  1407. package/ts3.4/cjs/core/streams/RunLengthStream.d.ts +9 -0
  1408. package/ts3.4/cjs/core/streams/Stream.d.ts +35 -0
  1409. package/ts3.4/cjs/core/streams/decode.d.ts +4 -0
  1410. package/ts3.4/cjs/core/structures/PDFCatalog.d.ts +28 -0
  1411. package/ts3.4/cjs/core/structures/PDFContentStream.d.ts +16 -0
  1412. package/ts3.4/cjs/core/structures/PDFCrossRefStream.d.ts +54 -0
  1413. package/ts3.4/cjs/core/structures/PDFFlateStream.d.ts +14 -0
  1414. package/ts3.4/cjs/core/structures/PDFObjectStream.d.ts +21 -0
  1415. package/ts3.4/cjs/core/structures/PDFPageLeaf.d.ts +55 -0
  1416. package/ts3.4/cjs/core/structures/PDFPageTree.d.ts +42 -0
  1417. package/ts3.4/cjs/core/syntax/CharCodes.d.ts +62 -0
  1418. package/ts3.4/cjs/core/syntax/Delimiters.d.ts +2 -0
  1419. package/ts3.4/cjs/core/syntax/Irregular.d.ts +2 -0
  1420. package/ts3.4/cjs/core/syntax/Keywords.d.ts +23 -0
  1421. package/ts3.4/cjs/core/syntax/Numeric.d.ts +4 -0
  1422. package/ts3.4/cjs/core/syntax/Whitespace.d.ts +2 -0
  1423. package/ts3.4/cjs/core/writers/PDFStreamWriter.d.ts +22 -0
  1424. package/ts3.4/cjs/core/writers/PDFWriter.d.ts +33 -0
  1425. package/ts3.4/cjs/index.d.ts +5 -0
  1426. package/ts3.4/cjs/types/fontkit.d.ts +582 -0
  1427. package/ts3.4/cjs/types/index.d.ts +2 -0
  1428. package/ts3.4/cjs/types/matrix.d.ts +22 -0
  1429. package/ts3.4/cjs/utils/Cache.d.ts +11 -0
  1430. package/ts3.4/cjs/utils/arrays.d.ts +16 -0
  1431. package/ts3.4/cjs/utils/async.d.ts +6 -0
  1432. package/ts3.4/cjs/utils/base64.d.ts +11 -0
  1433. package/ts3.4/cjs/utils/errors.d.ts +2 -0
  1434. package/ts3.4/cjs/utils/index.d.ts +12 -0
  1435. package/ts3.4/cjs/utils/numbers.d.ts +24 -0
  1436. package/ts3.4/cjs/utils/objects.d.ts +16 -0
  1437. package/ts3.4/cjs/utils/pdfDocEncoding.d.ts +8 -0
  1438. package/ts3.4/cjs/utils/png.d.ts +18 -0
  1439. package/ts3.4/cjs/utils/rng.d.ts +14 -0
  1440. package/ts3.4/cjs/utils/strings.d.ts +25 -0
  1441. package/ts3.4/cjs/utils/unicode.d.ts +187 -0
  1442. package/ts3.4/cjs/utils/validators.d.ts +27 -0
  1443. package/ts3.4/es/api/Embeddable.d.ts +8 -0
  1444. package/ts3.4/es/api/PDFDocument.d.ts +800 -0
  1445. package/ts3.4/es/api/PDFDocumentOptions.d.ts +43 -0
  1446. package/ts3.4/es/api/PDFEmbeddedFile.d.ts +39 -0
  1447. package/ts3.4/es/api/PDFEmbeddedPage.d.ts +74 -0
  1448. package/ts3.4/es/api/PDFFont.d.ts +95 -0
  1449. package/ts3.4/es/api/PDFImage.d.ts +96 -0
  1450. package/ts3.4/es/api/PDFJavaScript.d.ts +39 -0
  1451. package/ts3.4/es/api/PDFPage.d.ts +898 -0
  1452. package/ts3.4/es/api/PDFPageOptions.d.ts +155 -0
  1453. package/ts3.4/es/api/StandardFonts.d.ts +17 -0
  1454. package/ts3.4/es/api/colors.d.ts +31 -0
  1455. package/ts3.4/es/api/errors.d.ts +43 -0
  1456. package/ts3.4/es/api/form/PDFButton.d.ts +138 -0
  1457. package/ts3.4/es/api/form/PDFCheckBox.d.ts +143 -0
  1458. package/ts3.4/es/api/form/PDFDropdown.d.ts +403 -0
  1459. package/ts3.4/es/api/form/PDFField.d.ts +204 -0
  1460. package/ts3.4/es/api/form/PDFForm.d.ts +412 -0
  1461. package/ts3.4/es/api/form/PDFOptionList.d.ts +336 -0
  1462. package/ts3.4/es/api/form/PDFRadioGroup.d.ts +253 -0
  1463. package/ts3.4/es/api/form/PDFSignature.d.ts +30 -0
  1464. package/ts3.4/es/api/form/PDFTextField.d.ts +538 -0
  1465. package/ts3.4/es/api/form/appearances.d.ts +42 -0
  1466. package/ts3.4/es/api/form/index.d.ts +11 -0
  1467. package/ts3.4/es/api/image/alignment.d.ts +6 -0
  1468. package/ts3.4/es/api/image/index.d.ts +2 -0
  1469. package/ts3.4/es/api/index.d.ts +22 -0
  1470. package/ts3.4/es/api/objects.d.ts +5 -0
  1471. package/ts3.4/es/api/operations.d.ts +212 -0
  1472. package/ts3.4/es/api/operators.d.ts +86 -0
  1473. package/ts3.4/es/api/rotations.d.ts +39 -0
  1474. package/ts3.4/es/api/sizes.d.ts +53 -0
  1475. package/ts3.4/es/api/snapshot/DefaultDocumentSnapshot.d.ts +13 -0
  1476. package/ts3.4/es/api/snapshot/DocumentSnapshot.d.ts +11 -0
  1477. package/ts3.4/es/api/snapshot/IncrementalDocumentSnapshot.d.ts +16 -0
  1478. package/ts3.4/es/api/snapshot/index.d.ts +4 -0
  1479. package/ts3.4/es/api/svgPath.d.ts +3 -0
  1480. package/ts3.4/es/api/text/alignment.d.ts +6 -0
  1481. package/ts3.4/es/api/text/index.d.ts +3 -0
  1482. package/ts3.4/es/api/text/layout.d.ts +55 -0
  1483. package/ts3.4/es/core/PDFContext.d.ts +93 -0
  1484. package/ts3.4/es/core/PDFObjectCopier.d.ts +38 -0
  1485. package/ts3.4/es/core/acroform/PDFAcroButton.d.ts +22 -0
  1486. package/ts3.4/es/core/acroform/PDFAcroCheckBox.d.ts +14 -0
  1487. package/ts3.4/es/core/acroform/PDFAcroChoice.d.ts +21 -0
  1488. package/ts3.4/es/core/acroform/PDFAcroComboBox.d.ts +10 -0
  1489. package/ts3.4/es/core/acroform/PDFAcroField.d.ts +37 -0
  1490. package/ts3.4/es/core/acroform/PDFAcroForm.d.ts +21 -0
  1491. package/ts3.4/es/core/acroform/PDFAcroListBox.d.ts +10 -0
  1492. package/ts3.4/es/core/acroform/PDFAcroNonTerminal.d.ts +14 -0
  1493. package/ts3.4/es/core/acroform/PDFAcroPushButton.d.ts +10 -0
  1494. package/ts3.4/es/core/acroform/PDFAcroRadioButton.d.ts +14 -0
  1495. package/ts3.4/es/core/acroform/PDFAcroSignature.d.ts +8 -0
  1496. package/ts3.4/es/core/acroform/PDFAcroTerminal.d.ts +17 -0
  1497. package/ts3.4/es/core/acroform/PDFAcroText.d.ts +23 -0
  1498. package/ts3.4/es/core/acroform/flags.d.ts +142 -0
  1499. package/ts3.4/es/core/acroform/index.d.ts +16 -0
  1500. package/ts3.4/es/core/acroform/utils.d.ts +7 -0
  1501. package/ts3.4/es/core/annotation/AppearanceCharacteristics.d.ts +34 -0
  1502. package/ts3.4/es/core/annotation/BorderStyle.d.ts +12 -0
  1503. package/ts3.4/es/core/annotation/PDFAnnotation.d.ts +52 -0
  1504. package/ts3.4/es/core/annotation/PDFWidgetAnnotation.d.ts +27 -0
  1505. package/ts3.4/es/core/annotation/flags.d.ts +80 -0
  1506. package/ts3.4/es/core/annotation/index.d.ts +5 -0
  1507. package/ts3.4/es/core/document/PDFCrossRefSection.d.ts +28 -0
  1508. package/ts3.4/es/core/document/PDFHeader.d.ts +11 -0
  1509. package/ts3.4/es/core/document/PDFTrailer.d.ts +10 -0
  1510. package/ts3.4/es/core/document/PDFTrailerDict.d.ts +11 -0
  1511. package/ts3.4/es/core/embedders/CMap.d.ts +4 -0
  1512. package/ts3.4/es/core/embedders/CustomFontEmbedder.d.ts +45 -0
  1513. package/ts3.4/es/core/embedders/CustomFontSubsetEmbedder.d.ts +21 -0
  1514. package/ts3.4/es/core/embedders/FileEmbedder.d.ts +34 -0
  1515. package/ts3.4/es/core/embedders/FontFlags.d.ts +14 -0
  1516. package/ts3.4/es/core/embedders/JavaScriptEmbedder.d.ts +11 -0
  1517. package/ts3.4/es/core/embedders/JpegEmbedder.d.ts +24 -0
  1518. package/ts3.4/es/core/embedders/PDFPageEmbedder.d.ts +38 -0
  1519. package/ts3.4/es/core/embedders/PngEmbedder.d.ts +20 -0
  1520. package/ts3.4/es/core/embedders/StandardFontEmbedder.d.ts +37 -0
  1521. package/ts3.4/es/core/errors.d.ts +92 -0
  1522. package/ts3.4/es/core/index.d.ts +48 -0
  1523. package/ts3.4/es/core/interactive/ViewerPreferences.d.ts +348 -0
  1524. package/ts3.4/es/core/objects/PDFArray.d.ts +64 -0
  1525. package/ts3.4/es/core/objects/PDFBool.d.ts +14 -0
  1526. package/ts3.4/es/core/objects/PDFDict.d.ts +63 -0
  1527. package/ts3.4/es/core/objects/PDFHexString.d.ts +17 -0
  1528. package/ts3.4/es/core/objects/PDFInvalidObject.d.ts +12 -0
  1529. package/ts3.4/es/core/objects/PDFName.d.ts +42 -0
  1530. package/ts3.4/es/core/objects/PDFNull.d.ts +11 -0
  1531. package/ts3.4/es/core/objects/PDFNumber.d.ts +16 -0
  1532. package/ts3.4/es/core/objects/PDFObject.d.ts +10 -0
  1533. package/ts3.4/es/core/objects/PDFRawStream.d.ts +15 -0
  1534. package/ts3.4/es/core/objects/PDFRef.d.ts +14 -0
  1535. package/ts3.4/es/core/objects/PDFStream.d.ts +17 -0
  1536. package/ts3.4/es/core/objects/PDFString.d.ts +17 -0
  1537. package/ts3.4/es/core/operators/PDFOperator.d.ts +20 -0
  1538. package/ts3.4/es/core/operators/PDFOperatorNames.d.ts +77 -0
  1539. package/ts3.4/es/core/parser/BaseParser.d.ts +15 -0
  1540. package/ts3.4/es/core/parser/ByteStream.d.ts +27 -0
  1541. package/ts3.4/es/core/parser/PDFObjectParser.d.ts +30 -0
  1542. package/ts3.4/es/core/parser/PDFObjectStreamParser.d.ts +14 -0
  1543. package/ts3.4/es/core/parser/PDFParser.d.ts +46 -0
  1544. package/ts3.4/es/core/parser/PDFXRefStreamParser.d.ts +22 -0
  1545. package/ts3.4/es/core/streams/Ascii85Stream.d.ts +10 -0
  1546. package/ts3.4/es/core/streams/AsciiHexStream.d.ts +10 -0
  1547. package/ts3.4/es/core/streams/DecodeStream.d.ts +27 -0
  1548. package/ts3.4/es/core/streams/FlateStream.d.ts +14 -0
  1549. package/ts3.4/es/core/streams/LZWStream.d.ts +13 -0
  1550. package/ts3.4/es/core/streams/RunLengthStream.d.ts +9 -0
  1551. package/ts3.4/es/core/streams/Stream.d.ts +35 -0
  1552. package/ts3.4/es/core/streams/decode.d.ts +4 -0
  1553. package/ts3.4/es/core/structures/PDFCatalog.d.ts +28 -0
  1554. package/ts3.4/es/core/structures/PDFContentStream.d.ts +16 -0
  1555. package/ts3.4/es/core/structures/PDFCrossRefStream.d.ts +54 -0
  1556. package/ts3.4/es/core/structures/PDFFlateStream.d.ts +14 -0
  1557. package/ts3.4/es/core/structures/PDFObjectStream.d.ts +21 -0
  1558. package/ts3.4/es/core/structures/PDFPageLeaf.d.ts +55 -0
  1559. package/ts3.4/es/core/structures/PDFPageTree.d.ts +42 -0
  1560. package/ts3.4/es/core/syntax/CharCodes.d.ts +62 -0
  1561. package/ts3.4/es/core/syntax/Delimiters.d.ts +2 -0
  1562. package/ts3.4/es/core/syntax/Irregular.d.ts +2 -0
  1563. package/ts3.4/es/core/syntax/Keywords.d.ts +23 -0
  1564. package/ts3.4/es/core/syntax/Numeric.d.ts +4 -0
  1565. package/ts3.4/es/core/syntax/Whitespace.d.ts +2 -0
  1566. package/ts3.4/es/core/writers/PDFStreamWriter.d.ts +22 -0
  1567. package/ts3.4/es/core/writers/PDFWriter.d.ts +33 -0
  1568. package/ts3.4/es/index.d.ts +5 -0
  1569. package/ts3.4/es/types/fontkit.d.ts +582 -0
  1570. package/ts3.4/es/types/index.d.ts +2 -0
  1571. package/ts3.4/es/types/matrix.d.ts +22 -0
  1572. package/ts3.4/es/utils/Cache.d.ts +11 -0
  1573. package/ts3.4/es/utils/arrays.d.ts +16 -0
  1574. package/ts3.4/es/utils/async.d.ts +6 -0
  1575. package/ts3.4/es/utils/base64.d.ts +11 -0
  1576. package/ts3.4/es/utils/errors.d.ts +2 -0
  1577. package/ts3.4/es/utils/index.d.ts +12 -0
  1578. package/ts3.4/es/utils/numbers.d.ts +24 -0
  1579. package/ts3.4/es/utils/objects.d.ts +16 -0
  1580. package/ts3.4/es/utils/pdfDocEncoding.d.ts +8 -0
  1581. package/ts3.4/es/utils/png.d.ts +18 -0
  1582. package/ts3.4/es/utils/rng.d.ts +14 -0
  1583. package/ts3.4/es/utils/strings.d.ts +25 -0
  1584. package/ts3.4/es/utils/unicode.d.ts +187 -0
  1585. package/ts3.4/es/utils/validators.d.ts +27 -0
  1586. package/yarn.lock +4446 -0
@@ -0,0 +1,1621 @@
1
+ import { Color, rgb } from 'src/api/colors';
2
+ import {
3
+ drawImage,
4
+ drawLine,
5
+ drawLinesOfText,
6
+ drawPage,
7
+ drawRectangle,
8
+ drawSvgPath,
9
+ drawEllipse,
10
+ } from 'src/api/operations';
11
+ import {
12
+ popGraphicsState,
13
+ pushGraphicsState,
14
+ translate,
15
+ LineCapStyle,
16
+ scale,
17
+ } from 'src/api/operators';
18
+ import PDFDocument from 'src/api/PDFDocument';
19
+ import PDFEmbeddedPage from 'src/api/PDFEmbeddedPage';
20
+ import PDFFont from 'src/api/PDFFont';
21
+ import PDFImage from 'src/api/PDFImage';
22
+ import {
23
+ PDFPageDrawCircleOptions,
24
+ PDFPageDrawEllipseOptions,
25
+ PDFPageDrawImageOptions,
26
+ PDFPageDrawLineOptions,
27
+ PDFPageDrawPageOptions,
28
+ PDFPageDrawRectangleOptions,
29
+ PDFPageDrawSquareOptions,
30
+ PDFPageDrawSVGOptions,
31
+ PDFPageDrawTextOptions,
32
+ BlendMode,
33
+ } from 'src/api/PDFPageOptions';
34
+ import { degrees, Rotation, toDegrees } from 'src/api/rotations';
35
+ import { StandardFonts } from 'src/api/StandardFonts';
36
+ import {
37
+ PDFContentStream,
38
+ PDFHexString,
39
+ PDFName,
40
+ PDFOperator,
41
+ PDFPageLeaf,
42
+ PDFRef,
43
+ PDFDict,
44
+ PDFArray,
45
+ } from 'src/core';
46
+ import {
47
+ assertEachIs,
48
+ assertIs,
49
+ assertMultiple,
50
+ assertOrUndefined,
51
+ breakTextIntoLines,
52
+ cleanText,
53
+ rectanglesAreEqual,
54
+ lineSplit,
55
+ assertRangeOrUndefined,
56
+ assertIsOneOfOrUndefined,
57
+ } from 'src/utils';
58
+
59
+ /**
60
+ * Represents a single page of a [[PDFDocument]].
61
+ */
62
+ export default class PDFPage {
63
+ /**
64
+ * > **NOTE:** You probably don't want to call this method directly. Instead,
65
+ * > consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]
66
+ * > methods, which can create instances of [[PDFPage]] for you.
67
+ *
68
+ * Create an instance of [[PDFPage]] from an existing leaf node.
69
+ *
70
+ * @param leafNode The leaf node to be wrapped.
71
+ * @param ref The unique reference for the page.
72
+ * @param doc The document to which the page will belong.
73
+ */
74
+ static of = (leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) =>
75
+ new PDFPage(leafNode, ref, doc);
76
+
77
+ /**
78
+ * > **NOTE:** You probably don't want to call this method directly. Instead,
79
+ * > consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]
80
+ * > methods, which can create instances of [[PDFPage]] for you.
81
+ *
82
+ * Create an instance of [[PDFPage]].
83
+ *
84
+ * @param doc The document to which the page will belong.
85
+ */
86
+ static create = (doc: PDFDocument) => {
87
+ assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);
88
+ const dummyRef = PDFRef.of(-1);
89
+ const pageLeaf = PDFPageLeaf.withContextAndParent(doc.context, dummyRef);
90
+ const pageRef = doc.context.register(pageLeaf);
91
+ return new PDFPage(pageLeaf, pageRef, doc);
92
+ };
93
+
94
+ /** The low-level PDFDictionary wrapped by this page. */
95
+ readonly node: PDFPageLeaf;
96
+
97
+ /** The unique reference assigned to this page within the document. */
98
+ readonly ref: PDFRef;
99
+
100
+ /** The document to which this page belongs. */
101
+ readonly doc: PDFDocument;
102
+
103
+ private fontKey?: PDFName;
104
+ private font?: PDFFont;
105
+ private fontSize = 24;
106
+ private fontColor = rgb(0, 0, 0) as Color;
107
+ private lineHeight = 24;
108
+ private x = 0;
109
+ private y = 0;
110
+ private contentStream?: PDFContentStream;
111
+ private contentStreamRef?: PDFRef;
112
+
113
+ private constructor(leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) {
114
+ assertIs(leafNode, 'leafNode', [[PDFPageLeaf, 'PDFPageLeaf']]);
115
+ assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);
116
+ assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);
117
+
118
+ this.node = leafNode;
119
+ this.ref = ref;
120
+ this.doc = doc;
121
+ }
122
+
123
+ /**
124
+ * Rotate this page by a multiple of 90 degrees. For example:
125
+ * ```js
126
+ * import { degrees } from 'pdf-lib'
127
+ *
128
+ * page.setRotation(degrees(-90))
129
+ * page.setRotation(degrees(0))
130
+ * page.setRotation(degrees(90))
131
+ * page.setRotation(degrees(180))
132
+ * page.setRotation(degrees(270))
133
+ * ```
134
+ * @param angle The angle to rotate this page.
135
+ */
136
+ setRotation(angle: Rotation): void {
137
+ const degreesAngle = toDegrees(angle);
138
+ assertMultiple(degreesAngle, 'degreesAngle', 90);
139
+ this.node.set(PDFName.of('Rotate'), this.doc.context.obj(degreesAngle));
140
+ }
141
+
142
+ /**
143
+ * Get this page's rotation angle in degrees. For example:
144
+ * ```js
145
+ * const rotationAngle = page.getRotation().angle;
146
+ * ```
147
+ * @returns The rotation angle of the page in degrees (always a multiple of
148
+ * 90 degrees).
149
+ */
150
+ getRotation(): Rotation {
151
+ const Rotate = this.node.Rotate();
152
+ return degrees(Rotate ? Rotate.asNumber() : 0);
153
+ }
154
+
155
+ /**
156
+ * Resize this page by increasing or decreasing its width and height. For
157
+ * example:
158
+ * ```js
159
+ * page.setSize(250, 500)
160
+ * page.setSize(page.getWidth() + 50, page.getHeight() + 100)
161
+ * page.setSize(page.getWidth() - 50, page.getHeight() - 100)
162
+ * ```
163
+ *
164
+ * Note that the PDF specification does not allow for pages to have explicit
165
+ * widths and heights. Instead it defines the "size" of a page in terms of
166
+ * five rectangles: the MediaBox, CropBox, BleedBox, TrimBox, and ArtBox. As a
167
+ * result, this method cannot directly change the width and height of a page.
168
+ * Instead, it works by adjusting these five boxes.
169
+ *
170
+ * This method performs the following steps:
171
+ * 1. Set width & height of MediaBox.
172
+ * 2. Set width & height of CropBox, if it has same dimensions as MediaBox.
173
+ * 3. Set width & height of BleedBox, if it has same dimensions as MediaBox.
174
+ * 4. Set width & height of TrimBox, if it has same dimensions as MediaBox.
175
+ * 5. Set width & height of ArtBox, if it has same dimensions as MediaBox.
176
+ *
177
+ * This approach works well for most PDF documents as all PDF pages must
178
+ * have a MediaBox, but relatively few have a CropBox, BleedBox, TrimBox, or
179
+ * ArtBox. And when they do have these additional boxes, they often have the
180
+ * same dimensions as the MediaBox. However, if you find this method does not
181
+ * work for your document, consider setting the boxes directly:
182
+ * * [[PDFPage.setMediaBox]]
183
+ * * [[PDFPage.setCropBox]]
184
+ * * [[PDFPage.setBleedBox]]
185
+ * * [[PDFPage.setTrimBox]]
186
+ * * [[PDFPage.setArtBox]]
187
+ *
188
+ * @param width The new width of the page.
189
+ * @param height The new height of the page.
190
+ */
191
+ setSize(width: number, height: number): void {
192
+ assertIs(width, 'width', ['number']);
193
+ assertIs(height, 'height', ['number']);
194
+
195
+ const mediaBox = this.getMediaBox();
196
+ this.setMediaBox(mediaBox.x, mediaBox.y, width, height);
197
+
198
+ const cropBox = this.getCropBox();
199
+ const bleedBox = this.getBleedBox();
200
+ const trimBox = this.getTrimBox();
201
+ const artBox = this.getArtBox();
202
+
203
+ const hasCropBox = this.node.CropBox()!!;
204
+ const hasBleedBox = this.node.BleedBox()!!;
205
+ const hasTrimBox = this.node.TrimBox()!!;
206
+ const hasArtBox = this.node.ArtBox()!!;
207
+
208
+ if (hasCropBox && rectanglesAreEqual(cropBox, mediaBox)) {
209
+ this.setCropBox(mediaBox.x, mediaBox.y, width, height);
210
+ }
211
+ if (hasBleedBox && rectanglesAreEqual(bleedBox, mediaBox)) {
212
+ this.setBleedBox(mediaBox.x, mediaBox.y, width, height);
213
+ }
214
+ if (hasTrimBox && rectanglesAreEqual(trimBox, mediaBox)) {
215
+ this.setTrimBox(mediaBox.x, mediaBox.y, width, height);
216
+ }
217
+ if (hasArtBox && rectanglesAreEqual(artBox, mediaBox)) {
218
+ this.setArtBox(mediaBox.x, mediaBox.y, width, height);
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Resize this page by increasing or decreasing its width. For example:
224
+ * ```js
225
+ * page.setWidth(250)
226
+ * page.setWidth(page.getWidth() + 50)
227
+ * page.setWidth(page.getWidth() - 50)
228
+ * ```
229
+ *
230
+ * This method uses [[PDFPage.setSize]] to set the page's width.
231
+ *
232
+ * @param width The new width of the page.
233
+ */
234
+ setWidth(width: number): void {
235
+ assertIs(width, 'width', ['number']);
236
+ this.setSize(width, this.getSize().height);
237
+ }
238
+
239
+ /**
240
+ * Resize this page by increasing or decreasing its height. For example:
241
+ * ```js
242
+ * page.setHeight(500)
243
+ * page.setHeight(page.getWidth() + 100)
244
+ * page.setHeight(page.getWidth() - 100)
245
+ * ```
246
+ *
247
+ * This method uses [[PDFPage.setSize]] to set the page's height.
248
+ *
249
+ * @param height The new height of the page.
250
+ */
251
+ setHeight(height: number): void {
252
+ assertIs(height, 'height', ['number']);
253
+ this.setSize(this.getSize().width, height);
254
+ }
255
+
256
+ /**
257
+ * Set the MediaBox of this page. For example:
258
+ * ```js
259
+ * const mediaBox = page.getMediaBox()
260
+ *
261
+ * page.setMediaBox(0, 0, 250, 500)
262
+ * page.setMediaBox(mediaBox.x, mediaBox.y, 50, 100)
263
+ * page.setMediaBox(15, 5, mediaBox.width - 50, mediaBox.height - 100)
264
+ * ```
265
+ *
266
+ * See [[PDFPage.getMediaBox]] for details about what the MediaBox represents.
267
+ *
268
+ * @param x The x coordinate of the lower left corner of the new MediaBox.
269
+ * @param y The y coordinate of the lower left corner of the new MediaBox.
270
+ * @param width The width of the new MediaBox.
271
+ * @param height The height of the new MediaBox.
272
+ */
273
+ setMediaBox(x: number, y: number, width: number, height: number): void {
274
+ assertIs(x, 'x', ['number']);
275
+ assertIs(y, 'y', ['number']);
276
+ assertIs(width, 'width', ['number']);
277
+ assertIs(height, 'height', ['number']);
278
+ const mediaBox = this.doc.context.obj([x, y, x + width, y + height]);
279
+ this.node.set(PDFName.MediaBox, mediaBox);
280
+ }
281
+
282
+ /**
283
+ * Set the CropBox of this page. For example:
284
+ * ```js
285
+ * const cropBox = page.getCropBox()
286
+ *
287
+ * page.setCropBox(0, 0, 250, 500)
288
+ * page.setCropBox(cropBox.x, cropBox.y, 50, 100)
289
+ * page.setCropBox(15, 5, cropBox.width - 50, cropBox.height - 100)
290
+ * ```
291
+ *
292
+ * See [[PDFPage.getCropBox]] for details about what the CropBox represents.
293
+ *
294
+ * @param x The x coordinate of the lower left corner of the new CropBox.
295
+ * @param y The y coordinate of the lower left corner of the new CropBox.
296
+ * @param width The width of the new CropBox.
297
+ * @param height The height of the new CropBox.
298
+ */
299
+ setCropBox(x: number, y: number, width: number, height: number): void {
300
+ assertIs(x, 'x', ['number']);
301
+ assertIs(y, 'y', ['number']);
302
+ assertIs(width, 'width', ['number']);
303
+ assertIs(height, 'height', ['number']);
304
+ const cropBox = this.doc.context.obj([x, y, x + width, y + height]);
305
+ this.node.set(PDFName.CropBox, cropBox);
306
+ }
307
+
308
+ /**
309
+ * Set the BleedBox of this page. For example:
310
+ * ```js
311
+ * const bleedBox = page.getBleedBox()
312
+ *
313
+ * page.setBleedBox(0, 0, 250, 500)
314
+ * page.setBleedBox(bleedBox.x, bleedBox.y, 50, 100)
315
+ * page.setBleedBox(15, 5, bleedBox.width - 50, bleedBox.height - 100)
316
+ * ```
317
+ *
318
+ * See [[PDFPage.getBleedBox]] for details about what the BleedBox represents.
319
+ *
320
+ * @param x The x coordinate of the lower left corner of the new BleedBox.
321
+ * @param y The y coordinate of the lower left corner of the new BleedBox.
322
+ * @param width The width of the new BleedBox.
323
+ * @param height The height of the new BleedBox.
324
+ */
325
+ setBleedBox(x: number, y: number, width: number, height: number): void {
326
+ assertIs(x, 'x', ['number']);
327
+ assertIs(y, 'y', ['number']);
328
+ assertIs(width, 'width', ['number']);
329
+ assertIs(height, 'height', ['number']);
330
+ const bleedBox = this.doc.context.obj([x, y, x + width, y + height]);
331
+ this.node.set(PDFName.BleedBox, bleedBox);
332
+ }
333
+
334
+ /**
335
+ * Set the TrimBox of this page. For example:
336
+ * ```js
337
+ * const trimBox = page.getTrimBox()
338
+ *
339
+ * page.setTrimBox(0, 0, 250, 500)
340
+ * page.setTrimBox(trimBox.x, trimBox.y, 50, 100)
341
+ * page.setTrimBox(15, 5, trimBox.width - 50, trimBox.height - 100)
342
+ * ```
343
+ *
344
+ * See [[PDFPage.getTrimBox]] for details about what the TrimBox represents.
345
+ *
346
+ * @param x The x coordinate of the lower left corner of the new TrimBox.
347
+ * @param y The y coordinate of the lower left corner of the new TrimBox.
348
+ * @param width The width of the new TrimBox.
349
+ * @param height The height of the new TrimBox.
350
+ */
351
+ setTrimBox(x: number, y: number, width: number, height: number): void {
352
+ assertIs(x, 'x', ['number']);
353
+ assertIs(y, 'y', ['number']);
354
+ assertIs(width, 'width', ['number']);
355
+ assertIs(height, 'height', ['number']);
356
+ const trimBox = this.doc.context.obj([x, y, x + width, y + height]);
357
+ this.node.set(PDFName.TrimBox, trimBox);
358
+ }
359
+
360
+ /**
361
+ * Set the ArtBox of this page. For example:
362
+ * ```js
363
+ * const artBox = page.getArtBox()
364
+ *
365
+ * page.setArtBox(0, 0, 250, 500)
366
+ * page.setArtBox(artBox.x, artBox.y, 50, 100)
367
+ * page.setArtBox(15, 5, artBox.width - 50, artBox.height - 100)
368
+ * ```
369
+ *
370
+ * See [[PDFPage.getArtBox]] for details about what the ArtBox represents.
371
+ *
372
+ * @param x The x coordinate of the lower left corner of the new ArtBox.
373
+ * @param y The y coordinate of the lower left corner of the new ArtBox.
374
+ * @param width The width of the new ArtBox.
375
+ * @param height The height of the new ArtBox.
376
+ */
377
+ setArtBox(x: number, y: number, width: number, height: number): void {
378
+ assertIs(x, 'x', ['number']);
379
+ assertIs(y, 'y', ['number']);
380
+ assertIs(width, 'width', ['number']);
381
+ assertIs(height, 'height', ['number']);
382
+ const artBox = this.doc.context.obj([x, y, x + width, y + height]);
383
+ this.node.set(PDFName.ArtBox, artBox);
384
+ }
385
+
386
+ /**
387
+ * Get this page's width and height. For example:
388
+ * ```js
389
+ * const { width, height } = page.getSize()
390
+ * ```
391
+ *
392
+ * This method uses [[PDFPage.getMediaBox]] to obtain the page's
393
+ * width and height.
394
+ *
395
+ * @returns The width and height of the page.
396
+ */
397
+ getSize(): { width: number; height: number } {
398
+ const { width, height } = this.getMediaBox();
399
+ return { width, height };
400
+ }
401
+
402
+ /**
403
+ * Get this page's width. For example:
404
+ * ```js
405
+ * const width = page.getWidth()
406
+ * ```
407
+ *
408
+ * This method uses [[PDFPage.getSize]] to obtain the page's size.
409
+ *
410
+ * @returns The width of the page.
411
+ */
412
+ getWidth(): number {
413
+ return this.getSize().width;
414
+ }
415
+
416
+ /**
417
+ * Get this page's height. For example:
418
+ * ```js
419
+ * const height = page.getHeight()
420
+ * ```
421
+ *
422
+ * This method uses [[PDFPage.getSize]] to obtain the page's size.
423
+ *
424
+ * @returns The height of the page.
425
+ */
426
+ getHeight(): number {
427
+ return this.getSize().height;
428
+ }
429
+
430
+ /**
431
+ * Get the rectangle defining this page's MediaBox. For example:
432
+ * ```js
433
+ * const { x, y, width, height } = page.getMediaBox()
434
+ * ```
435
+ *
436
+ * The MediaBox of a page defines the boundaries of the physical medium on
437
+ * which the page is to be displayed/printed. It may include extended area
438
+ * surrounding the page content for bleed marks, printing marks, etc...
439
+ * It may also include areas close to the edges of the medium that cannot be
440
+ * marked because of physical limitations of the output device. Content
441
+ * falling outside this boundary may safely be discarded without affecting
442
+ * the meaning of the PDF file.
443
+ *
444
+ * @returns An object defining the lower left corner of the MediaBox and its
445
+ * width & height.
446
+ */
447
+ getMediaBox(): { x: number; y: number; width: number; height: number } {
448
+ const mediaBox = this.node.MediaBox();
449
+ return mediaBox.asRectangle();
450
+ }
451
+
452
+ /**
453
+ * Get the rectangle defining this page's CropBox. For example:
454
+ * ```js
455
+ * const { x, y, width, height } = page.getCropBox()
456
+ * ```
457
+ *
458
+ * The CropBox of a page defines the region to which the contents of the page
459
+ * shall be clipped when displayed or printed. Unlike the other boxes, the
460
+ * CropBox does not necessarily represent the physical page geometry. It
461
+ * merely imposes clipping on the page contents.
462
+ *
463
+ * The CropBox's default value is the page's MediaBox.
464
+ *
465
+ * @returns An object defining the lower left corner of the CropBox and its
466
+ * width & height.
467
+ */
468
+ getCropBox(): { x: number; y: number; width: number; height: number } {
469
+ const cropBox = this.node.CropBox();
470
+ return cropBox?.asRectangle() ?? this.getMediaBox();
471
+ }
472
+
473
+ /**
474
+ * Get the rectangle defining this page's BleedBox. For example:
475
+ * ```js
476
+ * const { x, y, width, height } = page.getBleedBox()
477
+ * ```
478
+ *
479
+ * The BleedBox of a page defines the region to which the contents of the
480
+ * page shall be clipped when output in a production environment. This may
481
+ * include any extra bleed area needed to accommodate the physical
482
+ * limitations of cutting, folding, and trimming equipment. The actual
483
+ * printed page may include printing marks that fall outside the BleedBox.
484
+ *
485
+ * The BleedBox's default value is the page's CropBox.
486
+ *
487
+ * @returns An object defining the lower left corner of the BleedBox and its
488
+ * width & height.
489
+ */
490
+ getBleedBox(): { x: number; y: number; width: number; height: number } {
491
+ const bleedBox = this.node.BleedBox();
492
+ return bleedBox?.asRectangle() ?? this.getCropBox();
493
+ }
494
+
495
+ /**
496
+ * Get the rectangle defining this page's TrimBox. For example:
497
+ * ```js
498
+ * const { x, y, width, height } = page.getTrimBox()
499
+ * ```
500
+ *
501
+ * The TrimBox of a page defines the intended dimensions of the finished
502
+ * page after trimming. It may be smaller than the MediaBox to allow for
503
+ * production-related content, such as printing instructions, cut marks, or
504
+ * color bars.
505
+ *
506
+ * The TrimBox's default value is the page's CropBox.
507
+ *
508
+ * @returns An object defining the lower left corner of the TrimBox and its
509
+ * width & height.
510
+ */
511
+ getTrimBox(): { x: number; y: number; width: number; height: number } {
512
+ const trimBox = this.node.TrimBox();
513
+ return trimBox?.asRectangle() ?? this.getCropBox();
514
+ }
515
+
516
+ /**
517
+ * Get the rectangle defining this page's ArtBox. For example:
518
+ * ```js
519
+ * const { x, y, width, height } = page.getArtBox()
520
+ * ```
521
+ *
522
+ * The ArtBox of a page defines the extent of the page's meaningful content
523
+ * (including potential white space).
524
+ *
525
+ * The ArtBox's default value is the page's CropBox.
526
+ *
527
+ * @returns An object defining the lower left corner of the ArtBox and its
528
+ * width & height.
529
+ */
530
+ getArtBox(): { x: number; y: number; width: number; height: number } {
531
+ const artBox = this.node.ArtBox();
532
+ return artBox?.asRectangle() ?? this.getCropBox();
533
+ }
534
+
535
+ /**
536
+ * Translate this page's content to a new location on the page. This operation
537
+ * is often useful after resizing the page with [[setSize]]. For example:
538
+ * ```js
539
+ * // Add 50 units of whitespace to the top and right of the page
540
+ * page.setSize(page.getWidth() + 50, page.getHeight() + 50)
541
+ *
542
+ * // Move the page's content from the lower-left corner of the page
543
+ * // to the top-right corner.
544
+ * page.translateContent(50, 50)
545
+ *
546
+ * // Now there are 50 units of whitespace to the left and bottom of the page
547
+ * ```
548
+ * See also: [[resetPosition]]
549
+ * @param x The new position on the x-axis for this page's content.
550
+ * @param y The new position on the y-axis for this page's content.
551
+ */
552
+ translateContent(x: number, y: number): void {
553
+ assertIs(x, 'x', ['number']);
554
+ assertIs(y, 'y', ['number']);
555
+
556
+ this.node.normalize();
557
+ this.getContentStream();
558
+
559
+ const start = this.createContentStream(
560
+ pushGraphicsState(),
561
+ translate(x, y),
562
+ );
563
+ const startRef = this.doc.context.register(start);
564
+
565
+ const end = this.createContentStream(popGraphicsState());
566
+ const endRef = this.doc.context.register(end);
567
+
568
+ this.node.wrapContentStreams(startRef, endRef);
569
+ }
570
+
571
+ /**
572
+ * Scale the size, content, and annotations of a page.
573
+ *
574
+ * For example:
575
+ * ```js
576
+ * page.scale(0.5, 0.5);
577
+ * ```
578
+ *
579
+ * @param x The factor by which the width for the page should be scaled
580
+ * (e.g. `0.5` is 50%).
581
+ * @param y The factor by which the height for the page should be scaled
582
+ * (e.g. `2.0` is 200%).
583
+ */
584
+ scale(x: number, y: number): void {
585
+ assertIs(x, 'x', ['number']);
586
+ assertIs(y, 'y', ['number']);
587
+ this.setSize(this.getWidth() * x, this.getHeight() * y);
588
+ this.scaleContent(x, y);
589
+ this.scaleAnnotations(x, y);
590
+ }
591
+
592
+ /**
593
+ * Scale the content of a page. This is useful after resizing an existing
594
+ * page. This scales only the content, not the annotations.
595
+ *
596
+ * For example:
597
+ * ```js
598
+ * // Bisect the size of the page
599
+ * page.setSize(page.getWidth() / 2, page.getHeight() / 2);
600
+ *
601
+ * // Scale the content of the page down by 50% in x and y
602
+ * page.scaleContent(0.5, 0.5);
603
+ * ```
604
+ * See also: [[scaleAnnotations]]
605
+ * @param x The factor by which the x-axis for the content should be scaled
606
+ * (e.g. `0.5` is 50%).
607
+ * @param y The factor by which the y-axis for the content should be scaled
608
+ * (e.g. `2.0` is 200%).
609
+ */
610
+ scaleContent(x: number, y: number): void {
611
+ assertIs(x, 'x', ['number']);
612
+ assertIs(y, 'y', ['number']);
613
+
614
+ this.node.normalize();
615
+ this.getContentStream();
616
+
617
+ const start = this.createContentStream(pushGraphicsState(), scale(x, y));
618
+ const startRef = this.doc.context.register(start);
619
+
620
+ const end = this.createContentStream(popGraphicsState());
621
+ const endRef = this.doc.context.register(end);
622
+
623
+ this.node.wrapContentStreams(startRef, endRef);
624
+ }
625
+
626
+ /**
627
+ * Scale the annotations of a page. This is useful if you want to scale a
628
+ * page with comments or other annotations.
629
+ * ```js
630
+ * // Scale the content of the page down by 50% in x and y
631
+ * page.scaleContent(0.5, 0.5);
632
+ *
633
+ * // Scale the content of the page down by 50% in x and y
634
+ * page.scaleAnnotations(0.5, 0.5);
635
+ * ```
636
+ * See also: [[scaleContent]]
637
+ * @param x The factor by which the x-axis for the annotations should be
638
+ * scaled (e.g. `0.5` is 50%).
639
+ * @param y The factor by which the y-axis for the annotations should be
640
+ * scaled (e.g. `2.0` is 200%).
641
+ */
642
+ scaleAnnotations(x: number, y: number) {
643
+ assertIs(x, 'x', ['number']);
644
+ assertIs(y, 'y', ['number']);
645
+
646
+ const annots = this.node.Annots();
647
+ if (!annots) return;
648
+
649
+ for (let idx = 0; idx < annots.size(); idx++) {
650
+ const annot = annots.lookup(idx);
651
+ if (annot instanceof PDFDict) this.scaleAnnot(annot, x, y);
652
+ }
653
+ }
654
+
655
+ /**
656
+ * Reset the x and y coordinates of this page to `(0, 0)`. This operation is
657
+ * often useful after calling [[translateContent]]. For example:
658
+ * ```js
659
+ * // Shift the page's contents up and to the right by 50 units
660
+ * page.translateContent(50, 50)
661
+ *
662
+ * // This text will shifted - it will be drawn at (50, 50)
663
+ * page.drawText('I am shifted')
664
+ *
665
+ * // Move back to (0, 0)
666
+ * page.resetPosition()
667
+ *
668
+ * // This text will not be shifted - it will be drawn at (0, 0)
669
+ * page.drawText('I am not shifted')
670
+ * ```
671
+ */
672
+ resetPosition(): void {
673
+ this.getContentStream(false);
674
+ this.x = 0;
675
+ this.y = 0;
676
+ }
677
+
678
+ /**
679
+ * Choose a default font for this page. The default font will be used whenever
680
+ * text is drawn on this page and no font is specified. For example:
681
+ * ```js
682
+ * import { StandardFonts } from 'pdf-lib'
683
+ *
684
+ * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
685
+ * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)
686
+ * const courierFont = await pdfDoc.embedFont(StandardFonts.Courier)
687
+ *
688
+ * const page = pdfDoc.addPage()
689
+ *
690
+ * page.setFont(helveticaFont)
691
+ * page.drawText('I will be drawn in Helvetica')
692
+ *
693
+ * page.setFont(timesRomanFont)
694
+ * page.drawText('I will be drawn in Courier', { font: courierFont })
695
+ * ```
696
+ * @param font The default font to be used when drawing text on this page.
697
+ */
698
+ setFont(font: PDFFont): void {
699
+ // TODO: Reuse image Font name if we've already added this image to Resources.Fonts
700
+ assertIs(font, 'font', [[PDFFont, 'PDFFont']]);
701
+ this.font = font;
702
+ this.fontKey = this.node.newFontDictionary(this.font.name, this.font.ref);
703
+ }
704
+
705
+ /**
706
+ * Choose a default font size for this page. The default font size will be
707
+ * used whenever text is drawn on this page and no font size is specified.
708
+ * For example:
709
+ * ```js
710
+ * page.setFontSize(12)
711
+ * page.drawText('I will be drawn in size 12')
712
+ *
713
+ * page.setFontSize(36)
714
+ * page.drawText('I will be drawn in size 24', { fontSize: 24 })
715
+ * ```
716
+ * @param fontSize The default font size to be used when drawing text on this
717
+ * page.
718
+ */
719
+ setFontSize(fontSize: number): void {
720
+ assertIs(fontSize, 'fontSize', ['number']);
721
+ this.fontSize = fontSize;
722
+ }
723
+
724
+ /**
725
+ * Choose a default font color for this page. The default font color will be
726
+ * used whenever text is drawn on this page and no font color is specified.
727
+ * For example:
728
+ * ```js
729
+ * import { rgb, cmyk, grayscale } from 'pdf-lib'
730
+ *
731
+ * page.setFontColor(rgb(0.97, 0.02, 0.97))
732
+ * page.drawText('I will be drawn in pink')
733
+ *
734
+ * page.setFontColor(cmyk(0.4, 0.7, 0.39, 0.15))
735
+ * page.drawText('I will be drawn in gray', { color: grayscale(0.5) })
736
+ * ```
737
+ * @param fontColor The default font color to be used when drawing text on
738
+ * this page.
739
+ */
740
+ setFontColor(fontColor: Color): void {
741
+ assertIs(fontColor, 'fontColor', [[Object, 'Color']]);
742
+ this.fontColor = fontColor;
743
+ }
744
+
745
+ /**
746
+ * Choose a default line height for this page. The default line height will be
747
+ * used whenever text is drawn on this page and no line height is specified.
748
+ * For example:
749
+ * ```js
750
+ * page.setLineHeight(12);
751
+ * page.drawText('These lines will be vertically \n separated by 12 units')
752
+ *
753
+ * page.setLineHeight(36);
754
+ * page.drawText('These lines will be vertically \n separated by 24 units', {
755
+ * lineHeight: 24
756
+ * })
757
+ * ```
758
+ * @param lineHeight The default line height to be used when drawing text on
759
+ * this page.
760
+ */
761
+ setLineHeight(lineHeight: number): void {
762
+ assertIs(lineHeight, 'lineHeight', ['number']);
763
+ this.lineHeight = lineHeight;
764
+ }
765
+
766
+ /**
767
+ * Get the default position of this page. For example:
768
+ * ```js
769
+ * const { x, y } = page.getPosition()
770
+ * ```
771
+ * @returns The default position of the page.
772
+ */
773
+ getPosition(): { x: number; y: number } {
774
+ return { x: this.x, y: this.y };
775
+ }
776
+
777
+ /**
778
+ * Get the default x coordinate of this page. For example:
779
+ * ```js
780
+ * const x = page.getX()
781
+ * ```
782
+ * @returns The default x coordinate of the page.
783
+ */
784
+ getX(): number {
785
+ return this.x;
786
+ }
787
+
788
+ /**
789
+ * Get the default y coordinate of this page. For example:
790
+ * ```js
791
+ * const y = page.getY()
792
+ * ```
793
+ * @returns The default y coordinate of the page.
794
+ */
795
+ getY(): number {
796
+ return this.y;
797
+ }
798
+
799
+ /**
800
+ * Change the default position of this page. For example:
801
+ * ```js
802
+ * page.moveTo(0, 0)
803
+ * page.drawText('I will be drawn at the origin')
804
+ *
805
+ * page.moveTo(0, 25)
806
+ * page.drawText('I will be drawn 25 units up')
807
+ *
808
+ * page.moveTo(25, 25)
809
+ * page.drawText('I will be drawn 25 units up and 25 units to the right')
810
+ * ```
811
+ * @param x The new default position on the x-axis for this page.
812
+ * @param y The new default position on the y-axis for this page.
813
+ */
814
+ moveTo(x: number, y: number): void {
815
+ assertIs(x, 'x', ['number']);
816
+ assertIs(y, 'y', ['number']);
817
+ this.x = x;
818
+ this.y = y;
819
+ }
820
+
821
+ /**
822
+ * Change the default position of this page to be further down the y-axis.
823
+ * For example:
824
+ * ```js
825
+ * page.moveTo(50, 50)
826
+ * page.drawText('I will be drawn at (50, 50)')
827
+ *
828
+ * page.moveDown(10)
829
+ * page.drawText('I will be drawn at (50, 40)')
830
+ * ```
831
+ * @param yDecrease The amount by which the page's default position along the
832
+ * y-axis should be decreased.
833
+ */
834
+ moveDown(yDecrease: number): void {
835
+ assertIs(yDecrease, 'yDecrease', ['number']);
836
+ this.y -= yDecrease;
837
+ }
838
+
839
+ /**
840
+ * Change the default position of this page to be further up the y-axis.
841
+ * For example:
842
+ * ```js
843
+ * page.moveTo(50, 50)
844
+ * page.drawText('I will be drawn at (50, 50)')
845
+ *
846
+ * page.moveUp(10)
847
+ * page.drawText('I will be drawn at (50, 60)')
848
+ * ```
849
+ * @param yIncrease The amount by which the page's default position along the
850
+ * y-axis should be increased.
851
+ */
852
+ moveUp(yIncrease: number): void {
853
+ assertIs(yIncrease, 'yIncrease', ['number']);
854
+ this.y += yIncrease;
855
+ }
856
+
857
+ /**
858
+ * Change the default position of this page to be further left on the x-axis.
859
+ * For example:
860
+ * ```js
861
+ * page.moveTo(50, 50)
862
+ * page.drawText('I will be drawn at (50, 50)')
863
+ *
864
+ * page.moveLeft(10)
865
+ * page.drawText('I will be drawn at (40, 50)')
866
+ * ```
867
+ * @param xDecrease The amount by which the page's default position along the
868
+ * x-axis should be decreased.
869
+ */
870
+ moveLeft(xDecrease: number): void {
871
+ assertIs(xDecrease, 'xDecrease', ['number']);
872
+ this.x -= xDecrease;
873
+ }
874
+
875
+ /**
876
+ * Change the default position of this page to be further right on the y-axis.
877
+ * For example:
878
+ * ```js
879
+ * page.moveTo(50, 50)
880
+ * page.drawText('I will be drawn at (50, 50)')
881
+ *
882
+ * page.moveRight(10)
883
+ * page.drawText('I will be drawn at (60, 50)')
884
+ * ```
885
+ * @param xIncrease The amount by which the page's default position along the
886
+ * x-axis should be increased.
887
+ */
888
+ moveRight(xIncrease: number): void {
889
+ assertIs(xIncrease, 'xIncrease', ['number']);
890
+ this.x += xIncrease;
891
+ }
892
+
893
+ /**
894
+ * Push one or more operators to the end of this page's current content
895
+ * stream. For example:
896
+ * ```js
897
+ * import {
898
+ * pushGraphicsState,
899
+ * moveTo,
900
+ * lineTo,
901
+ * closePath,
902
+ * setFillingColor,
903
+ * rgb,
904
+ * fill,
905
+ * popGraphicsState,
906
+ * } from 'pdf-lib'
907
+ *
908
+ * // Draw a green triangle in the lower-left corner of the page
909
+ * page.pushOperators(
910
+ * pushGraphicsState(),
911
+ * moveTo(0, 0),
912
+ * lineTo(100, 0),
913
+ * lineTo(50, 100),
914
+ * closePath(),
915
+ * setFillingColor(rgb(0.0, 1.0, 0.0)),
916
+ * fill(),
917
+ * popGraphicsState(),
918
+ * )
919
+ * ```
920
+ * @param operator The operators to be pushed.
921
+ */
922
+ pushOperators(...operator: PDFOperator[]): void {
923
+ assertEachIs(operator, 'operator', [[PDFOperator, 'PDFOperator']]);
924
+ const contentStream = this.getContentStream();
925
+ contentStream.push(...operator);
926
+ }
927
+
928
+ /**
929
+ * Draw one or more lines of text on this page. For example:
930
+ * ```js
931
+ * import { StandardFonts, rgb } from 'pdf-lib'
932
+ *
933
+ * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)
934
+ * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
935
+ *
936
+ * const page = pdfDoc.addPage()
937
+ *
938
+ * page.setFont(helveticaFont)
939
+ *
940
+ * page.moveTo(5, 200)
941
+ * page.drawText('The Life of an Egg', { size: 36 })
942
+ *
943
+ * page.moveDown(36)
944
+ * page.drawText('An Epic Tale of Woe', { size: 30 })
945
+ *
946
+ * page.drawText(
947
+ * `Humpty Dumpty sat on a wall \n` +
948
+ * `Humpty Dumpty had a great fall; \n` +
949
+ * `All the king's horses and all the king's men \n` +
950
+ * `Couldn't put Humpty together again. \n`,
951
+ * {
952
+ * x: 25,
953
+ * y: 100,
954
+ * font: timesRomanFont,
955
+ * size: 24,
956
+ * color: rgb(1, 0, 0),
957
+ * lineHeight: 24,
958
+ * opacity: 0.75,
959
+ * },
960
+ * )
961
+ * ```
962
+ * @param text The text to be drawn.
963
+ * @param options The options to be used when drawing the text.
964
+ */
965
+ drawText(text: string, options: PDFPageDrawTextOptions = {}): void {
966
+ assertIs(text, 'text', ['string']);
967
+ assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);
968
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
969
+ assertOrUndefined(options.font, 'options.font', [[PDFFont, 'PDFFont']]);
970
+ assertOrUndefined(options.size, 'options.size', ['number']);
971
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
972
+ assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);
973
+ assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);
974
+ assertOrUndefined(options.x, 'options.x', ['number']);
975
+ assertOrUndefined(options.y, 'options.y', ['number']);
976
+ assertOrUndefined(options.lineHeight, 'options.lineHeight', ['number']);
977
+ assertOrUndefined(options.maxWidth, 'options.maxWidth', ['number']);
978
+ assertOrUndefined(options.wordBreaks, 'options.wordBreaks', [Array]);
979
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
980
+
981
+ const { oldFont, newFont, newFontKey } = this.setOrEmbedFont(options.font);
982
+ const fontSize = options.size || this.fontSize;
983
+
984
+ const wordBreaks = options.wordBreaks || this.doc.defaultWordBreaks;
985
+ const textWidth = (t: string) => newFont.widthOfTextAtSize(t, fontSize);
986
+ const lines =
987
+ options.maxWidth === undefined
988
+ ? lineSplit(cleanText(text))
989
+ : breakTextIntoLines(text, wordBreaks, options.maxWidth, textWidth);
990
+
991
+ const encodedLines = new Array(lines.length) as PDFHexString[];
992
+ for (let idx = 0, len = lines.length; idx < len; idx++) {
993
+ encodedLines[idx] = newFont.encodeText(lines[idx]);
994
+ }
995
+
996
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
997
+ opacity: options.opacity,
998
+ blendMode: options.blendMode,
999
+ });
1000
+
1001
+ const contentStream = this.getContentStream();
1002
+ contentStream.push(
1003
+ ...drawLinesOfText(encodedLines, {
1004
+ color: options.color ?? this.fontColor,
1005
+ font: newFontKey,
1006
+ size: fontSize,
1007
+ rotate: options.rotate ?? degrees(0),
1008
+ xSkew: options.xSkew ?? degrees(0),
1009
+ ySkew: options.ySkew ?? degrees(0),
1010
+ x: options.x ?? this.x,
1011
+ y: options.y ?? this.y,
1012
+ lineHeight: options.lineHeight ?? this.lineHeight,
1013
+ graphicsState: graphicsStateKey,
1014
+ }),
1015
+ );
1016
+
1017
+ if (options.font) {
1018
+ if (oldFont) this.setFont(oldFont);
1019
+ else this.resetFont();
1020
+ }
1021
+ }
1022
+
1023
+ /**
1024
+ * Draw an image on this page. For example:
1025
+ * ```js
1026
+ * import { degrees } from 'pdf-lib'
1027
+ *
1028
+ * const jpgUrl = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'
1029
+ * const jpgImageBytes = await fetch(jpgUrl).then((res) => res.arrayBuffer())
1030
+ *
1031
+ * const jpgImage = await pdfDoc.embedJpg(jpgImageBytes)
1032
+ * const jpgDims = jpgImage.scale(0.5)
1033
+ *
1034
+ * const page = pdfDoc.addPage()
1035
+ *
1036
+ * page.drawImage(jpgImage, {
1037
+ * x: 25,
1038
+ * y: 25,
1039
+ * width: jpgDims.width,
1040
+ * height: jpgDims.height,
1041
+ * rotate: degrees(30),
1042
+ * opacity: 0.75,
1043
+ * })
1044
+ * ```
1045
+ * @param image The image to be drawn.
1046
+ * @param options The options to be used when drawing the image.
1047
+ */
1048
+ drawImage(image: PDFImage, options: PDFPageDrawImageOptions = {}): void {
1049
+ // TODO: Reuse image XObject name if we've already added this image to Resources.XObjects
1050
+ assertIs(image, 'image', [[PDFImage, 'PDFImage']]);
1051
+ assertOrUndefined(options.x, 'options.x', ['number']);
1052
+ assertOrUndefined(options.y, 'options.y', ['number']);
1053
+ assertOrUndefined(options.width, 'options.width', ['number']);
1054
+ assertOrUndefined(options.height, 'options.height', ['number']);
1055
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
1056
+ assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);
1057
+ assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);
1058
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1059
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1060
+
1061
+ const xObjectKey = this.node.newXObject('Image', image.ref);
1062
+
1063
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1064
+ opacity: options.opacity,
1065
+ blendMode: options.blendMode,
1066
+ });
1067
+
1068
+ const contentStream = this.getContentStream();
1069
+ contentStream.push(
1070
+ ...drawImage(xObjectKey, {
1071
+ x: options.x ?? this.x,
1072
+ y: options.y ?? this.y,
1073
+ width: options.width ?? image.size().width,
1074
+ height: options.height ?? image.size().height,
1075
+ rotate: options.rotate ?? degrees(0),
1076
+ xSkew: options.xSkew ?? degrees(0),
1077
+ ySkew: options.ySkew ?? degrees(0),
1078
+ graphicsState: graphicsStateKey,
1079
+ }),
1080
+ );
1081
+ }
1082
+
1083
+ /**
1084
+ * Draw an embedded PDF page on this page. For example:
1085
+ * ```js
1086
+ * import { degrees } from 'pdf-lib'
1087
+ *
1088
+ * const pdfDoc = await PDFDocument.create()
1089
+ * const page = pdfDoc.addPage()
1090
+ *
1091
+ * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'
1092
+ * const sourcePdf = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer())
1093
+ *
1094
+ * // Embed page 74 from the PDF
1095
+ * const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, 73)
1096
+ *
1097
+ * page.drawPage(embeddedPage, {
1098
+ * x: 250,
1099
+ * y: 200,
1100
+ * xScale: 0.5,
1101
+ * yScale: 0.5,
1102
+ * rotate: degrees(30),
1103
+ * opacity: 0.75,
1104
+ * })
1105
+ * ```
1106
+ *
1107
+ * The `options` argument accepts both `width`/`height` and `xScale`/`yScale`
1108
+ * as options. Since each of these options defines the size of the drawn page,
1109
+ * if both options are given, `width` and `height` take precedence and the
1110
+ * corresponding scale variants are ignored.
1111
+ *
1112
+ * @param embeddedPage The embedded page to be drawn.
1113
+ * @param options The options to be used when drawing the embedded page.
1114
+ */
1115
+ drawPage(
1116
+ embeddedPage: PDFEmbeddedPage,
1117
+ options: PDFPageDrawPageOptions = {},
1118
+ ): void {
1119
+ // TODO: Reuse embeddedPage XObject name if we've already added this embeddedPage to Resources.XObjects
1120
+ assertIs(embeddedPage, 'embeddedPage', [
1121
+ [PDFEmbeddedPage, 'PDFEmbeddedPage'],
1122
+ ]);
1123
+ assertOrUndefined(options.x, 'options.x', ['number']);
1124
+ assertOrUndefined(options.y, 'options.y', ['number']);
1125
+ assertOrUndefined(options.xScale, 'options.xScale', ['number']);
1126
+ assertOrUndefined(options.yScale, 'options.yScale', ['number']);
1127
+ assertOrUndefined(options.width, 'options.width', ['number']);
1128
+ assertOrUndefined(options.height, 'options.height', ['number']);
1129
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
1130
+ assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);
1131
+ assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);
1132
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1133
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1134
+
1135
+ const xObjectKey = this.node.newXObject(
1136
+ 'EmbeddedPdfPage',
1137
+ embeddedPage.ref,
1138
+ );
1139
+
1140
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1141
+ opacity: options.opacity,
1142
+ blendMode: options.blendMode,
1143
+ });
1144
+
1145
+ // prettier-ignore
1146
+ const xScale = (
1147
+ options.width !== undefined ? options.width / embeddedPage.width
1148
+ : options.xScale !== undefined ? options.xScale
1149
+ : 1
1150
+ );
1151
+
1152
+ // prettier-ignore
1153
+ const yScale = (
1154
+ options.height !== undefined ? options.height / embeddedPage.height
1155
+ : options.yScale !== undefined ? options.yScale
1156
+ : 1
1157
+ );
1158
+
1159
+ const contentStream = this.getContentStream();
1160
+ contentStream.push(
1161
+ ...drawPage(xObjectKey, {
1162
+ x: options.x ?? this.x,
1163
+ y: options.y ?? this.y,
1164
+ xScale,
1165
+ yScale,
1166
+ rotate: options.rotate ?? degrees(0),
1167
+ xSkew: options.xSkew ?? degrees(0),
1168
+ ySkew: options.ySkew ?? degrees(0),
1169
+ graphicsState: graphicsStateKey,
1170
+ }),
1171
+ );
1172
+ }
1173
+
1174
+ /**
1175
+ * Draw an SVG path on this page. For example:
1176
+ * ```js
1177
+ * import { rgb } from 'pdf-lib'
1178
+ *
1179
+ * const svgPath = 'M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90'
1180
+ *
1181
+ * // Draw path as black line
1182
+ * page.drawSvgPath(svgPath, { x: 25, y: 75 })
1183
+ *
1184
+ * // Change border style and opacity
1185
+ * page.drawSvgPath(svgPath, {
1186
+ * x: 25,
1187
+ * y: 275,
1188
+ * borderColor: rgb(0.5, 0.5, 0.5),
1189
+ * borderWidth: 2,
1190
+ * borderOpacity: 0.75,
1191
+ * })
1192
+ *
1193
+ * // Set fill color and opacity
1194
+ * page.drawSvgPath(svgPath, {
1195
+ * x: 25,
1196
+ * y: 475,
1197
+ * color: rgb(1.0, 0, 0),
1198
+ * opacity: 0.75,
1199
+ * })
1200
+ *
1201
+ * // Draw 50% of original size
1202
+ * page.drawSvgPath(svgPath, {
1203
+ * x: 25,
1204
+ * y: 675,
1205
+ * scale: 0.5,
1206
+ * })
1207
+ * ```
1208
+ * @param path The SVG path to be drawn.
1209
+ * @param options The options to be used when drawing the SVG path.
1210
+ */
1211
+ drawSvgPath(path: string, options: PDFPageDrawSVGOptions = {}): void {
1212
+ assertIs(path, 'path', ['string']);
1213
+ assertOrUndefined(options.x, 'options.x', ['number']);
1214
+ assertOrUndefined(options.y, 'options.y', ['number']);
1215
+ assertOrUndefined(options.scale, 'options.scale', ['number']);
1216
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
1217
+ assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);
1218
+ assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);
1219
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1220
+ assertOrUndefined(options.borderColor, 'options.borderColor', [
1221
+ [Object, 'Color'],
1222
+ ]);
1223
+ assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [
1224
+ Array,
1225
+ ]);
1226
+ assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [
1227
+ 'number',
1228
+ ]);
1229
+ assertIsOneOfOrUndefined(
1230
+ options.borderLineCap,
1231
+ 'options.borderLineCap',
1232
+ LineCapStyle,
1233
+ );
1234
+ assertRangeOrUndefined(
1235
+ options.borderOpacity,
1236
+ 'options.borderOpacity',
1237
+ 0,
1238
+ 1,
1239
+ );
1240
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1241
+
1242
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1243
+ opacity: options.opacity,
1244
+ borderOpacity: options.borderOpacity,
1245
+ blendMode: options.blendMode,
1246
+ });
1247
+
1248
+ if (!('color' in options) && !('borderColor' in options)) {
1249
+ options.borderColor = rgb(0, 0, 0);
1250
+ }
1251
+
1252
+ const contentStream = this.getContentStream();
1253
+ contentStream.push(
1254
+ ...drawSvgPath(path, {
1255
+ x: options.x ?? this.x,
1256
+ y: options.y ?? this.y,
1257
+ scale: options.scale,
1258
+ rotate: options.rotate ?? degrees(0),
1259
+ color: options.color ?? undefined,
1260
+ borderColor: options.borderColor ?? undefined,
1261
+ borderWidth: options.borderWidth ?? 0,
1262
+ borderDashArray: options.borderDashArray ?? undefined,
1263
+ borderDashPhase: options.borderDashPhase ?? undefined,
1264
+ borderLineCap: options.borderLineCap ?? undefined,
1265
+ graphicsState: graphicsStateKey,
1266
+ }),
1267
+ );
1268
+ }
1269
+
1270
+ /**
1271
+ * Draw a line on this page. For example:
1272
+ * ```js
1273
+ * import { rgb } from 'pdf-lib'
1274
+ *
1275
+ * page.drawLine({
1276
+ * start: { x: 25, y: 75 },
1277
+ * end: { x: 125, y: 175 },
1278
+ * thickness: 2,
1279
+ * color: rgb(0.75, 0.2, 0.2),
1280
+ * opacity: 0.75,
1281
+ * })
1282
+ * ```
1283
+ * @param options The options to be used when drawing the line.
1284
+ */
1285
+ drawLine(options: PDFPageDrawLineOptions): void {
1286
+ assertIs(options.start, 'options.start', [
1287
+ [Object, '{ x: number, y: number }'],
1288
+ ]);
1289
+ assertIs(options.end, 'options.end', [
1290
+ [Object, '{ x: number, y: number }'],
1291
+ ]);
1292
+ assertIs(options.start.x, 'options.start.x', ['number']);
1293
+ assertIs(options.start.y, 'options.start.y', ['number']);
1294
+ assertIs(options.end.x, 'options.end.x', ['number']);
1295
+ assertIs(options.end.y, 'options.end.y', ['number']);
1296
+ assertOrUndefined(options.thickness, 'options.thickness', ['number']);
1297
+ assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);
1298
+ assertOrUndefined(options.dashArray, 'options.dashArray', [Array]);
1299
+ assertOrUndefined(options.dashPhase, 'options.dashPhase', ['number']);
1300
+ assertIsOneOfOrUndefined(options.lineCap, 'options.lineCap', LineCapStyle);
1301
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1302
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1303
+
1304
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1305
+ borderOpacity: options.opacity,
1306
+ blendMode: options.blendMode,
1307
+ });
1308
+
1309
+ if (!('color' in options)) {
1310
+ options.color = rgb(0, 0, 0);
1311
+ }
1312
+
1313
+ const contentStream = this.getContentStream();
1314
+ contentStream.push(
1315
+ ...drawLine({
1316
+ start: options.start,
1317
+ end: options.end,
1318
+ thickness: options.thickness ?? 1,
1319
+ color: options.color ?? undefined,
1320
+ dashArray: options.dashArray ?? undefined,
1321
+ dashPhase: options.dashPhase ?? undefined,
1322
+ lineCap: options.lineCap ?? undefined,
1323
+ graphicsState: graphicsStateKey,
1324
+ }),
1325
+ );
1326
+ }
1327
+
1328
+ /**
1329
+ * Draw a rectangle on this page. For example:
1330
+ * ```js
1331
+ * import { degrees, grayscale, rgb } from 'pdf-lib'
1332
+ *
1333
+ * page.drawRectangle({
1334
+ * x: 25,
1335
+ * y: 75,
1336
+ * width: 250,
1337
+ * height: 75,
1338
+ * rotate: degrees(-15),
1339
+ * borderWidth: 5,
1340
+ * borderColor: grayscale(0.5),
1341
+ * color: rgb(0.75, 0.2, 0.2),
1342
+ * opacity: 0.5,
1343
+ * borderOpacity: 0.75,
1344
+ * })
1345
+ * ```
1346
+ * @param options The options to be used when drawing the rectangle.
1347
+ */
1348
+ drawRectangle(options: PDFPageDrawRectangleOptions = {}): void {
1349
+ assertOrUndefined(options.x, 'options.x', ['number']);
1350
+ assertOrUndefined(options.y, 'options.y', ['number']);
1351
+ assertOrUndefined(options.width, 'options.width', ['number']);
1352
+ assertOrUndefined(options.height, 'options.height', ['number']);
1353
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
1354
+ assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);
1355
+ assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);
1356
+ assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);
1357
+ assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);
1358
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1359
+ assertOrUndefined(options.borderColor, 'options.borderColor', [
1360
+ [Object, 'Color'],
1361
+ ]);
1362
+ assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [
1363
+ Array,
1364
+ ]);
1365
+ assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [
1366
+ 'number',
1367
+ ]);
1368
+ assertIsOneOfOrUndefined(
1369
+ options.borderLineCap,
1370
+ 'options.borderLineCap',
1371
+ LineCapStyle,
1372
+ );
1373
+ assertRangeOrUndefined(
1374
+ options.borderOpacity,
1375
+ 'options.borderOpacity',
1376
+ 0,
1377
+ 1,
1378
+ );
1379
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1380
+
1381
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1382
+ opacity: options.opacity,
1383
+ borderOpacity: options.borderOpacity,
1384
+ blendMode: options.blendMode,
1385
+ });
1386
+
1387
+ if (!('color' in options) && !('borderColor' in options)) {
1388
+ options.color = rgb(0, 0, 0);
1389
+ }
1390
+
1391
+ const contentStream = this.getContentStream();
1392
+ contentStream.push(
1393
+ ...drawRectangle({
1394
+ x: options.x ?? this.x,
1395
+ y: options.y ?? this.y,
1396
+ width: options.width ?? 150,
1397
+ height: options.height ?? 100,
1398
+ rotate: options.rotate ?? degrees(0),
1399
+ xSkew: options.xSkew ?? degrees(0),
1400
+ ySkew: options.ySkew ?? degrees(0),
1401
+ borderWidth: options.borderWidth ?? 0,
1402
+ color: options.color ?? undefined,
1403
+ borderColor: options.borderColor ?? undefined,
1404
+ borderDashArray: options.borderDashArray ?? undefined,
1405
+ borderDashPhase: options.borderDashPhase ?? undefined,
1406
+ graphicsState: graphicsStateKey,
1407
+ borderLineCap: options.borderLineCap ?? undefined,
1408
+ }),
1409
+ );
1410
+ }
1411
+
1412
+ /**
1413
+ * Draw a square on this page. For example:
1414
+ * ```js
1415
+ * import { degrees, grayscale, rgb } from 'pdf-lib'
1416
+ *
1417
+ * page.drawSquare({
1418
+ * x: 25,
1419
+ * y: 75,
1420
+ * size: 100,
1421
+ * rotate: degrees(-15),
1422
+ * borderWidth: 5,
1423
+ * borderColor: grayscale(0.5),
1424
+ * color: rgb(0.75, 0.2, 0.2),
1425
+ * opacity: 0.5,
1426
+ * borderOpacity: 0.75,
1427
+ * })
1428
+ * ```
1429
+ * @param options The options to be used when drawing the square.
1430
+ */
1431
+ drawSquare(options: PDFPageDrawSquareOptions = {}): void {
1432
+ const { size } = options;
1433
+ assertOrUndefined(size, 'size', ['number']);
1434
+ this.drawRectangle({ ...options, width: size, height: size });
1435
+ }
1436
+
1437
+ /**
1438
+ * Draw an ellipse on this page. For example:
1439
+ * ```js
1440
+ * import { grayscale, rgb } from 'pdf-lib'
1441
+ *
1442
+ * page.drawEllipse({
1443
+ * x: 200,
1444
+ * y: 75,
1445
+ * xScale: 100,
1446
+ * yScale: 50,
1447
+ * borderWidth: 5,
1448
+ * borderColor: grayscale(0.5),
1449
+ * color: rgb(0.75, 0.2, 0.2),
1450
+ * opacity: 0.5,
1451
+ * borderOpacity: 0.75,
1452
+ * })
1453
+ * ```
1454
+ * @param options The options to be used when drawing the ellipse.
1455
+ */
1456
+ drawEllipse(options: PDFPageDrawEllipseOptions = {}): void {
1457
+ assertOrUndefined(options.x, 'options.x', ['number']);
1458
+ assertOrUndefined(options.y, 'options.y', ['number']);
1459
+ assertOrUndefined(options.xScale, 'options.xScale', ['number']);
1460
+ assertOrUndefined(options.yScale, 'options.yScale', ['number']);
1461
+ assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);
1462
+ assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);
1463
+ assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);
1464
+ assertOrUndefined(options.borderColor, 'options.borderColor', [
1465
+ [Object, 'Color'],
1466
+ ]);
1467
+ assertRangeOrUndefined(
1468
+ options.borderOpacity,
1469
+ 'options.borderOpacity',
1470
+ 0,
1471
+ 1,
1472
+ );
1473
+ assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);
1474
+ assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [
1475
+ Array,
1476
+ ]);
1477
+ assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [
1478
+ 'number',
1479
+ ]);
1480
+ assertIsOneOfOrUndefined(
1481
+ options.borderLineCap,
1482
+ 'options.borderLineCap',
1483
+ LineCapStyle,
1484
+ );
1485
+ assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);
1486
+ const graphicsStateKey = this.maybeEmbedGraphicsState({
1487
+ opacity: options.opacity,
1488
+ borderOpacity: options.borderOpacity,
1489
+ blendMode: options.blendMode,
1490
+ });
1491
+
1492
+ if (!('color' in options) && !('borderColor' in options)) {
1493
+ options.color = rgb(0, 0, 0);
1494
+ }
1495
+
1496
+ const contentStream = this.getContentStream();
1497
+ contentStream.push(
1498
+ ...drawEllipse({
1499
+ x: options.x ?? this.x,
1500
+ y: options.y ?? this.y,
1501
+ xScale: options.xScale ?? 100,
1502
+ yScale: options.yScale ?? 100,
1503
+ rotate: options.rotate ?? undefined,
1504
+ color: options.color ?? undefined,
1505
+ borderColor: options.borderColor ?? undefined,
1506
+ borderWidth: options.borderWidth ?? 0,
1507
+ borderDashArray: options.borderDashArray ?? undefined,
1508
+ borderDashPhase: options.borderDashPhase ?? undefined,
1509
+ borderLineCap: options.borderLineCap ?? undefined,
1510
+ graphicsState: graphicsStateKey,
1511
+ }),
1512
+ );
1513
+ }
1514
+
1515
+ /**
1516
+ * Draw a circle on this page. For example:
1517
+ * ```js
1518
+ * import { grayscale, rgb } from 'pdf-lib'
1519
+ *
1520
+ * page.drawCircle({
1521
+ * x: 200,
1522
+ * y: 150,
1523
+ * size: 100,
1524
+ * borderWidth: 5,
1525
+ * borderColor: grayscale(0.5),
1526
+ * color: rgb(0.75, 0.2, 0.2),
1527
+ * opacity: 0.5,
1528
+ * borderOpacity: 0.75,
1529
+ * })
1530
+ * ```
1531
+ * @param options The options to be used when drawing the ellipse.
1532
+ */
1533
+ drawCircle(options: PDFPageDrawCircleOptions = {}): void {
1534
+ const { size = 100 } = options;
1535
+ assertOrUndefined(size, 'size', ['number']);
1536
+ this.drawEllipse({ ...options, xScale: size, yScale: size });
1537
+ }
1538
+
1539
+ private setOrEmbedFont(font?: PDFFont) {
1540
+ const oldFont = this.font;
1541
+ const oldFontKey = this.fontKey;
1542
+
1543
+ if (font) this.setFont(font);
1544
+ else this.getFont();
1545
+
1546
+ const newFont = this.font!;
1547
+ const newFontKey = this.fontKey!;
1548
+
1549
+ return { oldFont, oldFontKey, newFont, newFontKey };
1550
+ }
1551
+
1552
+ private getFont(): [PDFFont, PDFName] {
1553
+ if (!this.font || !this.fontKey) {
1554
+ const font = this.doc.embedStandardFont(StandardFonts.Helvetica);
1555
+ this.setFont(font);
1556
+ }
1557
+ return [this.font!, this.fontKey!];
1558
+ }
1559
+
1560
+ private resetFont(): void {
1561
+ this.font = undefined;
1562
+ this.fontKey = undefined;
1563
+ }
1564
+
1565
+ private getContentStream(useExisting = true): PDFContentStream {
1566
+ if (useExisting && this.contentStream) return this.contentStream;
1567
+ this.contentStream = this.createContentStream();
1568
+ this.contentStreamRef = this.doc.context.register(this.contentStream);
1569
+ this.node.addContentStream(this.contentStreamRef);
1570
+ return this.contentStream;
1571
+ }
1572
+
1573
+ private createContentStream(...operators: PDFOperator[]): PDFContentStream {
1574
+ const dict = this.doc.context.obj({});
1575
+ const contentStream = PDFContentStream.of(dict, operators);
1576
+ return contentStream;
1577
+ }
1578
+
1579
+ private maybeEmbedGraphicsState(options: {
1580
+ opacity?: number;
1581
+ borderOpacity?: number;
1582
+ blendMode?: BlendMode;
1583
+ }): PDFName | undefined {
1584
+ const { opacity, borderOpacity, blendMode } = options;
1585
+
1586
+ if (
1587
+ opacity === undefined &&
1588
+ borderOpacity === undefined &&
1589
+ blendMode === undefined
1590
+ ) {
1591
+ return undefined;
1592
+ }
1593
+
1594
+ const graphicsState = this.doc.context.obj({
1595
+ Type: 'ExtGState',
1596
+ ca: opacity,
1597
+ CA: borderOpacity,
1598
+ BM: blendMode,
1599
+ });
1600
+
1601
+ const key = this.node.newExtGState('GS', graphicsState);
1602
+
1603
+ return key;
1604
+ }
1605
+
1606
+ private scaleAnnot(annot: PDFDict, x: number, y: number) {
1607
+ const selectors = ['RD', 'CL', 'Vertices', 'QuadPoints', 'L', 'Rect'];
1608
+ for (let idx = 0, len = selectors.length; idx < len; idx++) {
1609
+ const list = annot.lookup(PDFName.of(selectors[idx]));
1610
+ if (list instanceof PDFArray) list.scalePDFNumbers(x, y);
1611
+ }
1612
+
1613
+ const inkLists = annot.lookup(PDFName.of('InkList'));
1614
+ if (inkLists instanceof PDFArray) {
1615
+ for (let idx = 0, len = inkLists.size(); idx < len; idx++) {
1616
+ const arr = inkLists.lookup(idx);
1617
+ if (arr instanceof PDFArray) arr.scalePDFNumbers(x, y);
1618
+ }
1619
+ }
1620
+ }
1621
+ }