@hussmartinez/pdf-sdk 0.0.0-stage → 0.1.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.
- package/LICENSE +202 -0
- package/NOTICE +66 -0
- package/README.md +84 -2
- package/dist/assets/pdfjs/build/pdf.worker.min.mjs +28 -0
- package/dist/assets/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/assets/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/assets/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/dist/assets/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/LICENSE +36 -0
- package/dist/assets/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/assets/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/assets/pdfjs/iccs/LICENSE +116 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/assets/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/assets/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/assets/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/assets/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/assets/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/assets/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/assets/processing/processing.worker.js +57 -0
- package/dist/assets/processing/qpdf.wasm +0 -0
- package/dist/element.d.ts +12 -0
- package/dist/element.js +0 -0
- package/dist/index.d.ts +1286 -0
- package/dist/index.js +1 -0
- package/dist/lazy/78-EUC-H.bcmap-sYP3SMNV.js +3 -0
- package/dist/lazy/78-EUC-V.bcmap-w3SY_Y_q.js +3 -0
- package/dist/lazy/78-H.bcmap-CeA2DrtT.js +3 -0
- package/dist/lazy/78-RKSJ-H.bcmap-D4cLhL3_.js +3 -0
- package/dist/lazy/78-RKSJ-V.bcmap-DdK1ZiTU.js +3 -0
- package/dist/lazy/78-V.bcmap-CVoLO4i0.js +3 -0
- package/dist/lazy/78ms-RKSJ-H.bcmap-B20DW4UH.js +3 -0
- package/dist/lazy/78ms-RKSJ-V.bcmap-CLnY5REh.js +3 -0
- package/dist/lazy/83pv-RKSJ-H.bcmap-Ck3Sc38p.js +3 -0
- package/dist/lazy/90ms-RKSJ-H.bcmap-C-vgp7Oe.js +3 -0
- package/dist/lazy/90ms-RKSJ-V.bcmap-CnYvCBfH.js +3 -0
- package/dist/lazy/90msp-RKSJ-H.bcmap-BIx2U_Lw.js +3 -0
- package/dist/lazy/90msp-RKSJ-V.bcmap-LSpKnFnA.js +3 -0
- package/dist/lazy/90pv-RKSJ-H.bcmap-ohvXiazb.js +3 -0
- package/dist/lazy/90pv-RKSJ-V.bcmap-DiMSuPqu.js +3 -0
- package/dist/lazy/Add-H.bcmap-D50q_cPt.js +3 -0
- package/dist/lazy/Add-RKSJ-H.bcmap-DLQ79XiS.js +3 -0
- package/dist/lazy/Add-RKSJ-V.bcmap-DgMvx1Yl.js +3 -0
- package/dist/lazy/Add-V.bcmap-njFd39xE.js +3 -0
- package/dist/lazy/Adobe-CNS1-0.bcmap-DC9aIYc6.js +3 -0
- package/dist/lazy/Adobe-CNS1-1.bcmap-CjXhkA0W.js +3 -0
- package/dist/lazy/Adobe-CNS1-2.bcmap-BfDCyJYh.js +3 -0
- package/dist/lazy/Adobe-CNS1-3.bcmap-C5_dNXD-.js +3 -0
- package/dist/lazy/Adobe-CNS1-4.bcmap-DkB6y9PJ.js +3 -0
- package/dist/lazy/Adobe-CNS1-5.bcmap-13hTC0vp.js +3 -0
- package/dist/lazy/Adobe-CNS1-6.bcmap-CcQ66yT1.js +3 -0
- package/dist/lazy/Adobe-CNS1-UCS2.bcmap-jD7ZNdHN.js +3 -0
- package/dist/lazy/Adobe-GB1-0.bcmap-CwfHCw6h.js +3 -0
- package/dist/lazy/Adobe-GB1-1.bcmap-DRWrCran.js +3 -0
- package/dist/lazy/Adobe-GB1-2.bcmap-0nedEhcq.js +3 -0
- package/dist/lazy/Adobe-GB1-3.bcmap-Cq3lCVsW.js +3 -0
- package/dist/lazy/Adobe-GB1-4.bcmap-BzTb6Nsg.js +3 -0
- package/dist/lazy/Adobe-GB1-5.bcmap-BUHSmz5c.js +3 -0
- package/dist/lazy/Adobe-GB1-UCS2.bcmap-DUfIxWQW.js +3 -0
- package/dist/lazy/Adobe-Japan1-0.bcmap-BjG9GiRM.js +3 -0
- package/dist/lazy/Adobe-Japan1-1.bcmap-DQTj-iQt.js +3 -0
- package/dist/lazy/Adobe-Japan1-2.bcmap-BOsCSmmm.js +3 -0
- package/dist/lazy/Adobe-Japan1-3.bcmap-ChGf7g8t.js +3 -0
- package/dist/lazy/Adobe-Japan1-4.bcmap-CI6iUMgQ.js +3 -0
- package/dist/lazy/Adobe-Japan1-5.bcmap-kbwPceJO.js +3 -0
- package/dist/lazy/Adobe-Japan1-6.bcmap-CAvvqYpW.js +3 -0
- package/dist/lazy/Adobe-Japan1-UCS2.bcmap-DbZiEgfC.js +3 -0
- package/dist/lazy/Adobe-Korea1-0.bcmap-Der5jvBG.js +3 -0
- package/dist/lazy/Adobe-Korea1-1.bcmap-DafpcUyn.js +3 -0
- package/dist/lazy/Adobe-Korea1-2.bcmap-D1nh75yR.js +3 -0
- package/dist/lazy/Adobe-Korea1-UCS2.bcmap-CNeMfPHO.js +3 -0
- package/dist/lazy/B5-H.bcmap-gyhuoKf7.js +3 -0
- package/dist/lazy/B5-V.bcmap-BGqDqEjZ.js +3 -0
- package/dist/lazy/B5pc-H.bcmap-C8B_dVbb.js +3 -0
- package/dist/lazy/B5pc-V.bcmap-ETo7py2B.js +3 -0
- package/dist/lazy/CNS-EUC-H.bcmap-BgwyrNdN.js +3 -0
- package/dist/lazy/CNS-EUC-V.bcmap-BbC68G9k.js +3 -0
- package/dist/lazy/CNS1-H.bcmap-DZIguuvp.js +3 -0
- package/dist/lazy/CNS1-V.bcmap-DjthPwLF.js +3 -0
- package/dist/lazy/CNS2-H.bcmap-CTuiQP8Z.js +3 -0
- package/dist/lazy/CNS2-V.bcmap-BU5ZzL4C.js +3 -0
- package/dist/lazy/ETHK-B5-H.bcmap-AYx-kODg.js +3 -0
- package/dist/lazy/ETHK-B5-V.bcmap-C_2Sxwdm.js +3 -0
- package/dist/lazy/ETen-B5-H.bcmap-BAKuplan.js +3 -0
- package/dist/lazy/ETen-B5-V.bcmap-Dnm6aXlS.js +3 -0
- package/dist/lazy/ETenms-B5-H.bcmap-DZ8Y3Rnc.js +3 -0
- package/dist/lazy/ETenms-B5-V.bcmap-DPnnTEiA.js +3 -0
- package/dist/lazy/EUC-H.bcmap-B1COGDXX.js +3 -0
- package/dist/lazy/EUC-V.bcmap-BRvFq5yx.js +3 -0
- package/dist/lazy/Ext-H.bcmap-CNU3PCfs.js +3 -0
- package/dist/lazy/Ext-RKSJ-H.bcmap-T22CGXk4.js +3 -0
- package/dist/lazy/Ext-RKSJ-V.bcmap-K2DXeZ3P.js +3 -0
- package/dist/lazy/Ext-V.bcmap-3sNuPEfV.js +3 -0
- package/dist/lazy/FoxitDingbats.pfb-DVieKaw5.js +3 -0
- package/dist/lazy/FoxitFixed.pfb-Cxgpn9hN.js +3 -0
- package/dist/lazy/FoxitFixedBold.pfb-SBojmP3G.js +3 -0
- package/dist/lazy/FoxitFixedBoldItalic.pfb-DhsbZ2IP.js +3 -0
- package/dist/lazy/FoxitFixedItalic.pfb-Dm09mdyI.js +3 -0
- package/dist/lazy/FoxitSerif.pfb-DyMzSE_0.js +3 -0
- package/dist/lazy/FoxitSerifBold.pfb-DTzLt76W.js +3 -0
- package/dist/lazy/FoxitSerifBoldItalic.pfb-X3fHgghe.js +3 -0
- package/dist/lazy/FoxitSerifItalic.pfb-Nz1cnSKc.js +3 -0
- package/dist/lazy/FoxitSymbol.pfb-BL-rU8nS.js +3 -0
- package/dist/lazy/GB-EUC-H.bcmap-CsgH6-Rh.js +3 -0
- package/dist/lazy/GB-EUC-V.bcmap-DUouvrJu.js +3 -0
- package/dist/lazy/GB-H.bcmap-CuVli79K.js +3 -0
- package/dist/lazy/GB-V.bcmap-C3uPsDRC.js +3 -0
- package/dist/lazy/GBK-EUC-H.bcmap-BBDA5YUr.js +3 -0
- package/dist/lazy/GBK-EUC-V.bcmap-CjEpjWSW.js +3 -0
- package/dist/lazy/GBK2K-H.bcmap-DEJkj1gN.js +3 -0
- package/dist/lazy/GBK2K-V.bcmap-NYgNeNsu.js +3 -0
- package/dist/lazy/GBKp-EUC-H.bcmap-BIQuHkue.js +3 -0
- package/dist/lazy/GBKp-EUC-V.bcmap-BNBPmQ4v.js +3 -0
- package/dist/lazy/GBT-EUC-H.bcmap-D7OWs_0J.js +3 -0
- package/dist/lazy/GBT-EUC-V.bcmap-D_rNNyCu.js +3 -0
- package/dist/lazy/GBT-H.bcmap-B4SLNj_c.js +3 -0
- package/dist/lazy/GBT-V.bcmap-Cq6Niv8e.js +3 -0
- package/dist/lazy/GBTpc-EUC-H.bcmap-CX8SXrun.js +3 -0
- package/dist/lazy/GBTpc-EUC-V.bcmap-hM7BhuwC.js +3 -0
- package/dist/lazy/GBpc-EUC-H.bcmap-BIEXt7KG.js +3 -0
- package/dist/lazy/GBpc-EUC-V.bcmap-DWeqNOzl.js +3 -0
- package/dist/lazy/H.bcmap-DsMNeuh7.js +3 -0
- package/dist/lazy/HKdla-B5-H.bcmap-CI5u0d4T.js +3 -0
- package/dist/lazy/HKdla-B5-V.bcmap-yk9YM4CN.js +3 -0
- package/dist/lazy/HKdlb-B5-H.bcmap-DenLwP2C.js +3 -0
- package/dist/lazy/HKdlb-B5-V.bcmap-BKFxIrzq.js +3 -0
- package/dist/lazy/HKgccs-B5-H.bcmap-i607pEmt.js +3 -0
- package/dist/lazy/HKgccs-B5-V.bcmap-BA9Nvcnu.js +3 -0
- package/dist/lazy/HKm314-B5-H.bcmap-BamdAWrg.js +3 -0
- package/dist/lazy/HKm314-B5-V.bcmap-JIFeW7D_.js +3 -0
- package/dist/lazy/HKm471-B5-H.bcmap-CIOwD0zn.js +3 -0
- package/dist/lazy/HKm471-B5-V.bcmap-BkDoTPME.js +3 -0
- package/dist/lazy/HKscs-B5-H.bcmap--SdxOf4z.js +3 -0
- package/dist/lazy/HKscs-B5-V.bcmap-DmqMO-Th.js +3 -0
- package/dist/lazy/Hankaku.bcmap-B2fyvO8A.js +3 -0
- package/dist/lazy/Hiragana.bcmap-DP3YLVOE.js +3 -0
- package/dist/lazy/KSC-EUC-H.bcmap-DQ5YvjA7.js +3 -0
- package/dist/lazy/KSC-EUC-V.bcmap-BNvwGfQX.js +3 -0
- package/dist/lazy/KSC-H.bcmap-Ca-HYPS4.js +3 -0
- package/dist/lazy/KSC-Johab-H.bcmap-CfF2UvBc.js +3 -0
- package/dist/lazy/KSC-Johab-V.bcmap-LBN9I8dg.js +3 -0
- package/dist/lazy/KSC-V.bcmap-5U7FPho3.js +3 -0
- package/dist/lazy/KSCms-UHC-H.bcmap-CmoPtsRN.js +3 -0
- package/dist/lazy/KSCms-UHC-HW-H.bcmap-CVBsfTPV.js +3 -0
- package/dist/lazy/KSCms-UHC-HW-V.bcmap-Dv90XUw-.js +3 -0
- package/dist/lazy/KSCms-UHC-V.bcmap-BlaojGc1.js +3 -0
- package/dist/lazy/KSCpc-EUC-H.bcmap-FrupvwaV.js +3 -0
- package/dist/lazy/KSCpc-EUC-V.bcmap-MG3GiZE4.js +3 -0
- package/dist/lazy/Katakana.bcmap-C8Bmgyhi.js +3 -0
- package/dist/lazy/NWP-H.bcmap-CAdIwPDs.js +3 -0
- package/dist/lazy/NWP-V.bcmap-DJ8FpnB4.js +3 -0
- package/dist/lazy/RKSJ-H.bcmap-qGRAHcEF.js +3 -0
- package/dist/lazy/RKSJ-V.bcmap-Dg3ddxaN.js +3 -0
- package/dist/lazy/Roman.bcmap-D4SBc9em.js +3 -0
- package/dist/lazy/UniCNS-UCS2-H.bcmap-CAjdESaO.js +3 -0
- package/dist/lazy/UniCNS-UCS2-V.bcmap-BHZM4Vzw.js +3 -0
- package/dist/lazy/UniCNS-UTF16-H.bcmap-Cm4ZnlrX.js +3 -0
- package/dist/lazy/UniCNS-UTF16-V.bcmap-BP1BFVyb.js +3 -0
- package/dist/lazy/UniCNS-UTF32-H.bcmap-DGLG7zQ_.js +3 -0
- package/dist/lazy/UniCNS-UTF32-V.bcmap-C6v0CIVn.js +3 -0
- package/dist/lazy/UniCNS-UTF8-H.bcmap-97YD5l2o.js +3 -0
- package/dist/lazy/UniCNS-UTF8-V.bcmap-B_zdNm-u.js +3 -0
- package/dist/lazy/UniGB-UCS2-H.bcmap-BcioIbCK.js +3 -0
- package/dist/lazy/UniGB-UCS2-V.bcmap-Cu-XDS3_.js +3 -0
- package/dist/lazy/UniGB-UTF16-H.bcmap-DPDBbQj_.js +3 -0
- package/dist/lazy/UniGB-UTF16-V.bcmap-Bwwxp3b7.js +3 -0
- package/dist/lazy/UniGB-UTF32-H.bcmap-D-uBJmmw.js +3 -0
- package/dist/lazy/UniGB-UTF32-V.bcmap-CLe_N_q5.js +3 -0
- package/dist/lazy/UniGB-UTF8-H.bcmap-CadVYdlJ.js +3 -0
- package/dist/lazy/UniGB-UTF8-V.bcmap-B9mD6Kt7.js +3 -0
- package/dist/lazy/UniJIS-UCS2-H.bcmap-BaCSu9QA.js +3 -0
- package/dist/lazy/UniJIS-UCS2-HW-H.bcmap-CYQj9xSp.js +3 -0
- package/dist/lazy/UniJIS-UCS2-HW-V.bcmap-CDzIwh-J.js +3 -0
- package/dist/lazy/UniJIS-UCS2-V.bcmap-DqCxM_EZ.js +3 -0
- package/dist/lazy/UniJIS-UTF16-H.bcmap-9TPLuUCU.js +3 -0
- package/dist/lazy/UniJIS-UTF16-V.bcmap-D6-nIWTQ.js +3 -0
- package/dist/lazy/UniJIS-UTF32-H.bcmap-CzmUWSLA.js +3 -0
- package/dist/lazy/UniJIS-UTF32-V.bcmap--KhJJEJE.js +3 -0
- package/dist/lazy/UniJIS-UTF8-H.bcmap-BwrhFSFd.js +3 -0
- package/dist/lazy/UniJIS-UTF8-V.bcmap-DGwbFkaL.js +3 -0
- package/dist/lazy/UniJIS2004-UTF16-H.bcmap-CdsS_d3_.js +3 -0
- package/dist/lazy/UniJIS2004-UTF16-V.bcmap-BnlV29Vf.js +3 -0
- package/dist/lazy/UniJIS2004-UTF32-H.bcmap-DSULVyIs.js +3 -0
- package/dist/lazy/UniJIS2004-UTF32-V.bcmap-CzBB970E.js +3 -0
- package/dist/lazy/UniJIS2004-UTF8-H.bcmap-BBuoGqhC.js +3 -0
- package/dist/lazy/UniJIS2004-UTF8-V.bcmap-dXgQhdTV.js +3 -0
- package/dist/lazy/UniJISPro-UCS2-HW-V.bcmap-ePVViljk.js +3 -0
- package/dist/lazy/UniJISPro-UCS2-V.bcmap-b2Oljrl4.js +3 -0
- package/dist/lazy/UniJISPro-UTF8-V.bcmap-CbPXe9gt.js +3 -0
- package/dist/lazy/UniJISX0213-UTF32-H.bcmap-Blmknifg.js +3 -0
- package/dist/lazy/UniJISX0213-UTF32-V.bcmap-Dtggmq9y.js +3 -0
- package/dist/lazy/UniJISX02132004-UTF32-H.bcmap-3YBd8tyQ.js +3 -0
- package/dist/lazy/UniJISX02132004-UTF32-V.bcmap-B8VdB9qS.js +3 -0
- package/dist/lazy/UniKS-UCS2-H.bcmap-CIhkpKgh.js +3 -0
- package/dist/lazy/UniKS-UCS2-V.bcmap-Cg-GDuqq.js +3 -0
- package/dist/lazy/UniKS-UTF16-H.bcmap-EZHb2IFq.js +3 -0
- package/dist/lazy/UniKS-UTF16-V.bcmap-BhqhAhYP.js +3 -0
- package/dist/lazy/UniKS-UTF32-H.bcmap-Cgay0dIp.js +3 -0
- package/dist/lazy/UniKS-UTF32-V.bcmap-DYXyatLV.js +3 -0
- package/dist/lazy/UniKS-UTF8-H.bcmap-BvHYimUT.js +3 -0
- package/dist/lazy/UniKS-UTF8-V.bcmap-DStcP2w0.js +3 -0
- package/dist/lazy/V.bcmap-DuWGSyNm.js +3 -0
- package/dist/lazy/WP-Symbol.bcmap-GltcyRl-.js +3 -0
- package/dist/lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js +194 -0
- package/dist/lazy/jbig2.wasm-CUnHTdWi.js +3 -0
- package/dist/lazy/openjpeg.wasm-bdyxAnqz.js +3 -0
- package/dist/lazy/processing-worker-CxoVSxEZ.js +30 -0
- package/dist/lazy/processing-worker-CxoVSxEZ.js.map +1 -0
- package/dist/lazy/render-worker-WgnZ-czI.js +30 -0
- package/dist/lazy/render-worker-WgnZ-czI.js.map +1 -0
- package/dist/lazy/runtime-G4hlayVF.js +22652 -0
- package/dist/lazy/runtime-G4hlayVF.js.map +1 -0
- package/dist/react.d.ts +1332 -0
- package/dist/react.js +899 -0
- package/dist/react.js.map +1 -0
- package/dist/shared/en-B0u26URn.js +1244 -0
- package/dist/shared/en-B0u26URn.js.map +1 -0
- package/dist/styles.css +335 -0
- package/package.json +107 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless core of the PDF SDK: contracts, errors, the document session and
|
|
3
|
+
* operations.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This entry is server-safe: it has no React and touches no DOM on import, so
|
|
7
|
+
* Server Components and Node can import it (ADR 0004, ADR 0007).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { FilePolicy } from '@hussmartinez/sdk-core';
|
|
13
|
+
import { FilePolicyOverrides } from '@hussmartinez/sdk-core';
|
|
14
|
+
import { Limits } from '@hussmartinez/sdk-core';
|
|
15
|
+
import { SdkCoreErrorCode } from '@hussmartinez/sdk-core';
|
|
16
|
+
import { SdkError } from '@hussmartinez/sdk-core';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Adds two rotations, such as a page's own `/Rotate` and the rotation the
|
|
20
|
+
* page plan adds to it.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* addRotation(270, 180); // 90
|
|
25
|
+
* addRotation(90, -90); // 0
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param rotation - The current rotation.
|
|
29
|
+
* @param angle - The angle to add, positive clockwise, in multiples of 90.
|
|
30
|
+
* @throws `RangeError` if `angle` isn't a multiple of 90.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare function addRotation(rotation: PdfRotation, angle: number): PdfRotation;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates the SDK's {@link PdfEngine}, backed by pdf.js (ADR 0001, ADR 0002).
|
|
37
|
+
*
|
|
38
|
+
* Nothing loads until the first `open()`: then pdf.js's display layer is
|
|
39
|
+
* imported, and its worker starts. Every document the engine opens shares one
|
|
40
|
+
* worker, and pdf.js runs without scripting or XFA (docs/adr/0001).
|
|
41
|
+
*
|
|
42
|
+
* By default everything is inlined: the worker, and the CMaps, standard
|
|
43
|
+
* fonts and image decoders that some documents need, each loaded only when a
|
|
44
|
+
* document needs it, with no network request. With `assetsUrl`, they load
|
|
45
|
+
* from your own origin instead (docs/adr/0002, docs/adr/0006).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const engine = createPdfJsEngine();
|
|
50
|
+
* const document = await engine.open(await file.arrayBuffer(), { signal });
|
|
51
|
+
* await document.renderPage(0, canvas, { scale: 1.5, pixelRatio: devicePixelRatio });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export declare function createPdfJsEngine(options?: PdfJsEngineOptions): PdfEngine;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Creates the SDK's {@link PdfProcessor}, backed by qpdf and pdf-lib in a
|
|
60
|
+
* worker (docs/adr/0001, docs/adr/0002).
|
|
61
|
+
*
|
|
62
|
+
* Nothing starts until the first `build()`. By default the worker is
|
|
63
|
+
* inlined, which needs `worker-src blob:` and `script-src 'wasm-unsafe-eval'`
|
|
64
|
+
* in a Content Security Policy, and it never fetches anything. With
|
|
65
|
+
* `assetsUrl`, it loads from your own origin instead. A build that can't stop
|
|
66
|
+
* when cancelled terminates its worker, which starts again on the next build.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const processor = createPdfProcessor();
|
|
71
|
+
* const protectedPdf = await processor.build({
|
|
72
|
+
* sources: [{ id: "a", bytes }],
|
|
73
|
+
* pages: [{ source: "a", pageIndex: 0 }, { source: "a", pageIndex: 1, rotation: 90 }],
|
|
74
|
+
* encrypt: { userPassword: "correct horse" },
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare function createPdfProcessor(options?: PdfProcessorOptions): PdfProcessor;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Creates a {@link PdfSession}. Pass the engine to use; the headless core
|
|
84
|
+
* doesn't choose one, so it can't pull pdf.js into applications that don't
|
|
85
|
+
* want it.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const session = createPdfSession({ engine: createPdfJsEngine() });
|
|
90
|
+
* await session.open(file);
|
|
91
|
+
* const [first] = session.getSnapshot().plan.pages;
|
|
92
|
+
* session.execute({ type: "pdf.rotatePages", pages: [first.key], angle: 90 });
|
|
93
|
+
* session.undo();
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export declare function createPdfSession(options: PdfSessionOptions): PdfSession;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Checks whether a value is a {@link PdfError}, optionally with a given code.
|
|
102
|
+
*
|
|
103
|
+
* Unlike `instanceof`, it recognises errors from another copy of this
|
|
104
|
+
* package or another realm, and errors rebuilt after crossing a worker
|
|
105
|
+
* boundary.
|
|
106
|
+
*
|
|
107
|
+
* @param value - Any thrown value.
|
|
108
|
+
* @param code - When given, the error must also have this code.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare function isPdfError<Code extends PdfErrorCode = PdfErrorCode>(value: unknown, code?: Code): value is PdfError & {
|
|
112
|
+
readonly code: Code;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What a link really leads to, for people to check before following it: the
|
|
117
|
+
* host of a web link, without `www.`, or the address of an email link.
|
|
118
|
+
* Undefined for a URL `safeLinkUrl` refuses.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export declare function linkDestination(url: string): string | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The most pixels an engine draws into one canvas. Larger renders are drawn
|
|
126
|
+
* at a lower resolution instead, because iOS Safari, the strictest
|
|
127
|
+
* supported browser, refuses larger canvases (ADR 0004).
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export declare const PDF_MAX_CANVAS_PIXELS = 16777216;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Adds an annotation to a page.
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
export declare interface PdfAddAnnotationCommand {
|
|
139
|
+
readonly type: "pdf.addAnnotation";
|
|
140
|
+
/** The page's key. */
|
|
141
|
+
readonly page: string;
|
|
142
|
+
readonly annotation: PdfAnnotation;
|
|
143
|
+
/** Its position among the page's annotations. Defaults to the end. */
|
|
144
|
+
readonly index?: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Anything the editor draws on top of a page until it's flattened on export
|
|
149
|
+
* (ADR 0003). Annotations are plain data, so they can be stored in commands
|
|
150
|
+
* and sent to the processing worker.
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export declare type PdfAnnotation = PdfStrokeAnnotation | PdfTextAnnotation | PdfImageAnnotation;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Everything needed to build an output document from the page plan, in one
|
|
158
|
+
* call to the processor (ADR 0003): the sources, the pages in order, and the
|
|
159
|
+
* export options. Plain data, so it crosses the worker boundary as it is.
|
|
160
|
+
*
|
|
161
|
+
* The processor runs the steps in this order, skipping those with nothing to
|
|
162
|
+
* do: fill each source's form values, assemble the pages with their
|
|
163
|
+
* rotations, flatten the annotations, compress, encrypt.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export declare interface PdfBuildJob {
|
|
168
|
+
readonly sources: readonly PdfBuildSource[];
|
|
169
|
+
readonly pages: readonly PdfBuildPage[];
|
|
170
|
+
readonly compress?: PdfCompression;
|
|
171
|
+
readonly encrypt?: PdfEncryption;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Options for {@link PdfProcessor.build}.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
export declare interface PdfBuildOptions extends PdfTransferOptions {
|
|
180
|
+
/** Called as the build moves through its steps. */
|
|
181
|
+
readonly onProgress?: (progress: PdfBuildProgress) => void;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* One page of the output: a page of a source, with a rotation added to the
|
|
186
|
+
* page's own, and the annotations to draw on it.
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
export declare interface PdfBuildPage {
|
|
191
|
+
/** The {@link PdfBuildSource.id} the page comes from. */
|
|
192
|
+
readonly source: string;
|
|
193
|
+
/** The page's zero-based index in its source. */
|
|
194
|
+
readonly pageIndex: number;
|
|
195
|
+
/** Rotation added to the page's own `/Rotate`. Defaults to 0. */
|
|
196
|
+
readonly rotation?: PdfRotation;
|
|
197
|
+
/** Annotations to flatten into the page's content. */
|
|
198
|
+
readonly annotations?: readonly PdfAnnotation[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Progress of a build: the step running now, and the fraction of the whole
|
|
203
|
+
* build that's done, from 0 to 1.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare interface PdfBuildProgress {
|
|
208
|
+
readonly step: PdfBuildStep;
|
|
209
|
+
readonly fraction: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* One source document of a {@link PdfBuildJob}.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
export declare interface PdfBuildSource {
|
|
218
|
+
/** An identifier, unique within the job, that pages and form values refer to. */
|
|
219
|
+
readonly id: string;
|
|
220
|
+
readonly bytes: PdfBytes;
|
|
221
|
+
/** Form values to fill into this source before its pages are assembled. */
|
|
222
|
+
readonly formValues?: Readonly<Record<string, PdfFieldValue>>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The steps of a build, reported as progress.
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare type PdfBuildStep = "fill" | "assemble" | "flatten" | "compress" | "encrypt";
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* PDF bytes as callers pass them. A `Uint8Array` may be a view into a larger
|
|
234
|
+
* buffer; only its own bytes are used.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
export declare type PdfBytes = ArrayBuffer | Uint8Array;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Options every port call accepts.
|
|
242
|
+
*
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
export declare interface PdfCallOptions {
|
|
246
|
+
/**
|
|
247
|
+
* Cancels the call. It then rejects with a `PdfError` whose code is
|
|
248
|
+
* `ABORTED`, `TIMEOUT`, or the code of an `SdkError` given as the abort
|
|
249
|
+
* reason, such as `PROCESSING_TIME_EXCEEDED`.
|
|
250
|
+
*/
|
|
251
|
+
readonly signal?: AbortSignal;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* A colour as `#rrggbb`.
|
|
256
|
+
*
|
|
257
|
+
* @public
|
|
258
|
+
*/
|
|
259
|
+
export declare type PdfColor = `#${string}`;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* An edit to the page plan (docs/adr/0003). Commands are plain,
|
|
263
|
+
* structured-cloneable data, never carry bytes, and each has an exact
|
|
264
|
+
* inverse, which is how undo works (ADR 0010).
|
|
265
|
+
*
|
|
266
|
+
* @public
|
|
267
|
+
*/
|
|
268
|
+
export declare type PdfCommand = PdfRotatePagesCommand | PdfDeletePagesCommand | PdfRestorePagesCommand | PdfMovePagesCommand | PdfReorderPagesCommand | PdfInsertPagesCommand | PdfSetFieldValueCommand | PdfAddAnnotationCommand | PdfRemoveAnnotationCommand;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* How to compress the output. Compression is lossless unless `images` is set.
|
|
272
|
+
*
|
|
273
|
+
* @public
|
|
274
|
+
*/
|
|
275
|
+
export declare interface PdfCompression {
|
|
276
|
+
readonly images?: PdfImageCompression;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Removes pages from the plan. Their sources stay, so undo can bring them back.
|
|
281
|
+
*
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
export declare interface PdfDeletePagesCommand {
|
|
285
|
+
readonly type: "pdf.deletePages";
|
|
286
|
+
readonly pages: readonly string[];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* An open document. Pages are addressed by zero-based index.
|
|
291
|
+
*
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
export declare interface PdfDocumentHandle {
|
|
295
|
+
/** The number of pages. */
|
|
296
|
+
readonly pageCount: number;
|
|
297
|
+
/**
|
|
298
|
+
* Reads a page's size and rotation.
|
|
299
|
+
*
|
|
300
|
+
* @throws `RangeError` for an index outside the document.
|
|
301
|
+
*/
|
|
302
|
+
getPage(pageIndex: number, options?: PdfCallOptions): Promise<PdfPageInfo>;
|
|
303
|
+
/**
|
|
304
|
+
* Draws a page into a canvas, sizing the canvas's pixel dimensions and its
|
|
305
|
+
* CSS `width` and `height`.
|
|
306
|
+
*
|
|
307
|
+
* @throws `RangeError` for an index outside the document.
|
|
308
|
+
*/
|
|
309
|
+
renderPage(pageIndex: number, canvas: HTMLCanvasElement, options: PdfRenderOptions): Promise<void>;
|
|
310
|
+
/**
|
|
311
|
+
* Reads a page's text, for the text layer and search.
|
|
312
|
+
*
|
|
313
|
+
* @throws `RangeError` for an index outside the document.
|
|
314
|
+
*/
|
|
315
|
+
getTextContent(pageIndex: number, options?: PdfCallOptions): Promise<PdfTextContent>;
|
|
316
|
+
/**
|
|
317
|
+
* Reads the form fields on a page.
|
|
318
|
+
*
|
|
319
|
+
* @throws `RangeError` for an index outside the document.
|
|
320
|
+
*/
|
|
321
|
+
getFormFields(pageIndex: number, options?: PdfCallOptions): Promise<readonly PdfFormField[]>;
|
|
322
|
+
/**
|
|
323
|
+
* Reads the links on a page to web pages and email addresses, filtered
|
|
324
|
+
* with `safeLinkUrl` (ADR 0012).
|
|
325
|
+
*
|
|
326
|
+
* @throws `RangeError` for an index outside the document.
|
|
327
|
+
*/
|
|
328
|
+
getLinks(pageIndex: number, options?: PdfCallOptions): Promise<readonly PdfLink[]>;
|
|
329
|
+
/** Releases the document. Pending calls reject, and later calls throw. */
|
|
330
|
+
destroy(): Promise<void>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* How to encrypt the output. Encryption is always AES-256.
|
|
335
|
+
*
|
|
336
|
+
* @public
|
|
337
|
+
*/
|
|
338
|
+
export declare interface PdfEncryption {
|
|
339
|
+
/** The password needed to open the document. */
|
|
340
|
+
readonly userPassword: string;
|
|
341
|
+
/** The password that grants full access. Defaults to the user password. */
|
|
342
|
+
readonly ownerPassword?: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The port for viewing PDFs: open a document, then read and render its pages
|
|
347
|
+
* (ADR 0008). The SDK's pdf.js adapter implements it; hosts can pass their
|
|
348
|
+
* own to the editor's `engine` prop, and every implementation must pass the
|
|
349
|
+
* engine's contract tests.
|
|
350
|
+
*
|
|
351
|
+
* Failures reject with `PdfError`: `INVALID_PDF` for a file that can't be
|
|
352
|
+
* parsed, `PASSWORD_REQUIRED` for an encrypted one, and sdk-core's codes for
|
|
353
|
+
* cancellation and worker failures.
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
export declare interface PdfEngine {
|
|
358
|
+
/**
|
|
359
|
+
* Opens a document. The bytes are copied unless `transfer` is set.
|
|
360
|
+
*/
|
|
361
|
+
open(source: PdfBytes, options?: PdfTransferOptions): Promise<PdfDocumentHandle>;
|
|
362
|
+
/** Releases the engine and its worker. Open documents are destroyed. */
|
|
363
|
+
destroy(): Promise<void>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* The error `@hussmartinez/pdf-sdk` throws and rejects with, with a stable
|
|
368
|
+
* `code`, structured `details` and the engine's error as `cause`. Show users
|
|
369
|
+
* the text for its code from {@link pdfMessages}, never its `message`, which
|
|
370
|
+
* is for developers and may contain text from the file.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* try {
|
|
375
|
+
* await session.open(file);
|
|
376
|
+
* } catch (error) {
|
|
377
|
+
* if (isPdfError(error, "PASSWORD_REQUIRED")) {
|
|
378
|
+
* askForPassword();
|
|
379
|
+
* } else {
|
|
380
|
+
* show(messages.error(error));
|
|
381
|
+
* }
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
export declare class PdfError extends SdkError<PdfErrorCode> {
|
|
388
|
+
/** Always `"PdfError"`, which survives minification and worker boundaries. */
|
|
389
|
+
readonly name = "PdfError";
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Error codes of `@hussmartinez/pdf-sdk`: sdk-core's own codes, such as
|
|
394
|
+
* `ABORTED`, `WORKER_CRASHED` and `FILE_TOO_LARGE`, plus the PDF SDK's. They
|
|
395
|
+
* never change meaning once released.
|
|
396
|
+
*
|
|
397
|
+
* - `INVALID_PDF`: the file isn't a PDF, or is too damaged to open.
|
|
398
|
+
* - `PASSWORD_REQUIRED`: the PDF is encrypted, and opening it needs a
|
|
399
|
+
* password.
|
|
400
|
+
* - `PROCESSING_FAILED`: a PDF engine failed in a way no other code
|
|
401
|
+
* describes. `cause` holds the engine's error.
|
|
402
|
+
* - `TOO_MANY_PAGES`: a document, or the pages after an insert, exceed the
|
|
403
|
+
* `maxPages` limit.
|
|
404
|
+
* - `SESSION_TOO_LARGE`: the documents the session holds exceed the
|
|
405
|
+
* `maxSessionSize` limit.
|
|
406
|
+
* - `IMAGE_TOO_LARGE`: an image exceeds the `maxImagePixels` limit. It's
|
|
407
|
+
* reported as a warning, because the image is skipped rather than the
|
|
408
|
+
* document failing (ADR 0004).
|
|
409
|
+
*
|
|
410
|
+
* Limit codes carry `details` with the `limit`, its `maximum`, the `actual`
|
|
411
|
+
* value and the `unit`.
|
|
412
|
+
*
|
|
413
|
+
* @public
|
|
414
|
+
*/
|
|
415
|
+
export declare type PdfErrorCode = SdkCoreErrorCode | "INVALID_PDF" | "PASSWORD_REQUIRED" | "PROCESSING_FAILED" | "TOO_MANY_PAGES" | "SESSION_TOO_LARGE" | "IMAGE_TOO_LARGE";
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Options for {@link PdfSession.export}.
|
|
419
|
+
*
|
|
420
|
+
* @public
|
|
421
|
+
*/
|
|
422
|
+
export declare interface PdfExportOptions extends PdfCallOptions {
|
|
423
|
+
/** Compress the result, losslessly unless `images` is set. */
|
|
424
|
+
readonly compress?: PdfCompression;
|
|
425
|
+
/** Encrypt the result with AES-256. */
|
|
426
|
+
readonly encrypt?: PdfEncryption;
|
|
427
|
+
/** Called as the export moves through its steps. */
|
|
428
|
+
readonly onProgress?: PdfBuildOptions["onProgress"];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* A form field's value: text for text fields, checked or not for checkboxes.
|
|
433
|
+
*
|
|
434
|
+
* @public
|
|
435
|
+
*/
|
|
436
|
+
export declare type PdfFieldValue = string | boolean;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* A resolved file policy for the PDF SDK. Violations throw {@link PdfError}.
|
|
440
|
+
*
|
|
441
|
+
* @public
|
|
442
|
+
*/
|
|
443
|
+
export declare type PdfFilePolicy = FilePolicy<PdfLimitDefinitions>;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* A host's `filePolicy`: a new maximum, or `{ maximum, warning }`, for any of
|
|
447
|
+
* the PDF SDK's limits. `Infinity` disables a maximum, which removes a
|
|
448
|
+
* protection against hostile files, or disables a warning. Unknown limit
|
|
449
|
+
* names throw `TypeError` when the policy is resolved.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* const filePolicy: PdfFilePolicyOverrides = {
|
|
454
|
+
* maxFileSize: { maximum: 300e6, warning: 100e6 },
|
|
455
|
+
* maxSessionSize: 600e6,
|
|
456
|
+
* };
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* @public
|
|
460
|
+
*/
|
|
461
|
+
export declare type PdfFilePolicyOverrides = FilePolicyOverrides<PdfLimitDefinitions>;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* An AcroForm field widget on a page.
|
|
465
|
+
*
|
|
466
|
+
* @public
|
|
467
|
+
*/
|
|
468
|
+
export declare interface PdfFormField {
|
|
469
|
+
/** The field's fully qualified name, unique within its document. */
|
|
470
|
+
readonly name: string;
|
|
471
|
+
/** The kind of field. Other kinds are not reported yet. */
|
|
472
|
+
readonly type: "text" | "checkbox";
|
|
473
|
+
/** Where the widget sits on the page. */
|
|
474
|
+
readonly rect: PdfRect;
|
|
475
|
+
/** The value stored in the document. */
|
|
476
|
+
readonly value: PdfFieldValue;
|
|
477
|
+
/** Whether the document marks the field as read-only. */
|
|
478
|
+
readonly readOnly: boolean;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* A drawn signature, or another image, placed on the page.
|
|
483
|
+
*
|
|
484
|
+
* @public
|
|
485
|
+
*/
|
|
486
|
+
export declare interface PdfImageAnnotation {
|
|
487
|
+
readonly id: string;
|
|
488
|
+
readonly type: "signature";
|
|
489
|
+
/** The top-left corner of the image, in page fractions. */
|
|
490
|
+
readonly at: PdfPoint;
|
|
491
|
+
/** Width, as a fraction of the page's width. */
|
|
492
|
+
readonly width: number;
|
|
493
|
+
/** Height, as a fraction of the page's height. */
|
|
494
|
+
readonly height: number;
|
|
495
|
+
/** The image as PNG bytes. */
|
|
496
|
+
readonly png: Uint8Array;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Lossy image recompression, on top of lossless compression.
|
|
501
|
+
*
|
|
502
|
+
* @public
|
|
503
|
+
*/
|
|
504
|
+
export declare interface PdfImageCompression {
|
|
505
|
+
/** JPEG quality, from 0 to 1. */
|
|
506
|
+
readonly quality: number;
|
|
507
|
+
/** The longest image edge to keep, in pixels. Larger images are scaled down. */
|
|
508
|
+
readonly maxDimension: number;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Options for {@link PdfSession.insert}.
|
|
513
|
+
*
|
|
514
|
+
* @public
|
|
515
|
+
*/
|
|
516
|
+
export declare interface PdfInsertOptions extends PdfCallOptions {
|
|
517
|
+
/** The position of the first inserted page. Defaults to the end. */
|
|
518
|
+
readonly at?: number;
|
|
519
|
+
/** Zero-based indexes of the pages to insert. Defaults to every page. */
|
|
520
|
+
readonly pageIndexes?: readonly number[];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Inserts pages of a registered source document. The session registers the
|
|
525
|
+
* source and fills in `keys`, so redo inserts the same pages.
|
|
526
|
+
*
|
|
527
|
+
* @public
|
|
528
|
+
*/
|
|
529
|
+
export declare interface PdfInsertPagesCommand {
|
|
530
|
+
readonly type: "pdf.insertPages";
|
|
531
|
+
/** The source's ID. */
|
|
532
|
+
readonly source: string;
|
|
533
|
+
/** Zero-based indexes of the source's pages to insert, in order. */
|
|
534
|
+
readonly pageIndexes: readonly number[];
|
|
535
|
+
/** The zero-based position of the first inserted page in the resulting plan. */
|
|
536
|
+
readonly at: number;
|
|
537
|
+
/** The keys of the new pages, one per index. */
|
|
538
|
+
readonly keys: readonly string[];
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Options for {@link createPdfJsEngine}.
|
|
543
|
+
*
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
export declare interface PdfJsEngineOptions {
|
|
547
|
+
/**
|
|
548
|
+
* Where your application serves the package's `dist/assets/` directory,
|
|
549
|
+
* on its own origin, such as `"/pdf-sdk/"`. pdf.js then loads its worker
|
|
550
|
+
* and its data files from its `pdfjs/` subdirectory, rather than from the
|
|
551
|
+
* inlined copies. Use it for Content Security Policies without
|
|
552
|
+
* `worker-src blob:`, and for accurate ICC colour, which only this mode
|
|
553
|
+
* supports (docs/adr/0006, docs/adr/0007). Pass the same URL to
|
|
554
|
+
* `createPdfProcessor`.
|
|
555
|
+
*/
|
|
556
|
+
readonly assetsUrl?: string | URL;
|
|
557
|
+
/**
|
|
558
|
+
* The largest image pdf.js decodes, in pixels. Larger images are left
|
|
559
|
+
* unpainted. Defaults to the `maxImagePixels` limit, 100 megapixels.
|
|
560
|
+
*/
|
|
561
|
+
readonly maxImagePixels?: number;
|
|
562
|
+
/* Excluded from this release type: _onDataRequest */
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* The type of {@link pdfLimitDefinitions}.
|
|
567
|
+
*
|
|
568
|
+
* @public
|
|
569
|
+
*/
|
|
570
|
+
export declare type PdfLimitDefinitions = typeof pdfLimitDefinitions;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* The PDF SDK's limit definitions: sdk-core's core limits plus three for PDFs
|
|
574
|
+
* (ADR 0004).
|
|
575
|
+
*
|
|
576
|
+
* | Limit | Code | Default maximum | Default warning |
|
|
577
|
+
* |---|---|---|---|
|
|
578
|
+
* | `maxFileSize` | `FILE_TOO_LARGE` | 100 MB | 50 MB |
|
|
579
|
+
* | `maxFiles` | `TOO_MANY_FILES` | 20 | none |
|
|
580
|
+
* | `maxDecodedSize` | `DECODED_SIZE_TOO_LARGE` | 500 MB | none |
|
|
581
|
+
* | `maxProcessingTime` | `PROCESSING_TIME_EXCEEDED` | 120 s | none |
|
|
582
|
+
* | `maxPages` | `TOO_MANY_PAGES` | 5,000 | 1,000 |
|
|
583
|
+
* | `maxSessionSize` | `SESSION_TOO_LARGE` | 300 MB | 150 MB |
|
|
584
|
+
* | `maxImagePixels` | `IMAGE_TOO_LARGE` | 100 megapixels | none |
|
|
585
|
+
*
|
|
586
|
+
* Sizes are decimal: 1 MB is 1,000,000 bytes.
|
|
587
|
+
*
|
|
588
|
+
* @public
|
|
589
|
+
*/
|
|
590
|
+
export declare const pdfLimitDefinitions: {
|
|
591
|
+
readonly maxPages: {
|
|
592
|
+
readonly code: "TOO_MANY_PAGES";
|
|
593
|
+
readonly unit: "count";
|
|
594
|
+
readonly default: 5000;
|
|
595
|
+
readonly warning: 1000;
|
|
596
|
+
};
|
|
597
|
+
readonly maxSessionSize: {
|
|
598
|
+
readonly code: "SESSION_TOO_LARGE";
|
|
599
|
+
readonly unit: "bytes";
|
|
600
|
+
readonly default: 300000000;
|
|
601
|
+
readonly warning: 150000000;
|
|
602
|
+
};
|
|
603
|
+
readonly maxImagePixels: {
|
|
604
|
+
readonly code: "IMAGE_TOO_LARGE";
|
|
605
|
+
readonly unit: "pixels";
|
|
606
|
+
readonly default: 100000000;
|
|
607
|
+
};
|
|
608
|
+
readonly maxFileSize: {
|
|
609
|
+
readonly code: "FILE_TOO_LARGE";
|
|
610
|
+
readonly unit: "bytes";
|
|
611
|
+
readonly default: 100000000;
|
|
612
|
+
readonly warning: 50000000;
|
|
613
|
+
};
|
|
614
|
+
readonly maxFiles: {
|
|
615
|
+
readonly code: "TOO_MANY_FILES";
|
|
616
|
+
readonly unit: "count";
|
|
617
|
+
readonly default: 20;
|
|
618
|
+
};
|
|
619
|
+
readonly maxDecodedSize: {
|
|
620
|
+
readonly code: "DECODED_SIZE_TOO_LARGE";
|
|
621
|
+
readonly unit: "bytes";
|
|
622
|
+
readonly default: 500000000;
|
|
623
|
+
};
|
|
624
|
+
readonly maxProcessingTime: {
|
|
625
|
+
readonly code: "PROCESSING_TIME_EXCEEDED";
|
|
626
|
+
readonly unit: "milliseconds";
|
|
627
|
+
readonly default: 120000;
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The names of the PDF SDK's limits.
|
|
633
|
+
*
|
|
634
|
+
* @public
|
|
635
|
+
*/
|
|
636
|
+
export declare type PdfLimitName = keyof PdfLimitDefinitions;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The PDF SDK's limits, ready to resolve a host's `filePolicy`. Violations
|
|
640
|
+
* are thrown as {@link PdfError}, with `details` naming the limit.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```ts
|
|
644
|
+
* const policy = pdfLimits.resolve(props.filePolicy);
|
|
645
|
+
* policy.check("maxPages", pageCount); // throws PdfError("TOO_MANY_PAGES") above 5,000
|
|
646
|
+
* ```
|
|
647
|
+
*
|
|
648
|
+
* @public
|
|
649
|
+
*/
|
|
650
|
+
export declare const pdfLimits: Limits<PdfLimitDefinitions>;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* A link on a page to a web page or an email address. Only `http`, `https`
|
|
654
|
+
* and `mailto` links are reported (ADR 0012); links into the document and
|
|
655
|
+
* every other scheme, such as `javascript:`, are left out.
|
|
656
|
+
*
|
|
657
|
+
* @public
|
|
658
|
+
*/
|
|
659
|
+
export declare interface PdfLink {
|
|
660
|
+
/** Where the link sits on the page, in fractions of the unrotated page. */
|
|
661
|
+
readonly rect: PdfRect;
|
|
662
|
+
/** The absolute URL, normalised. */
|
|
663
|
+
readonly url: string;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* The type of {@link pdfMessages}, for typing a host's overrides with
|
|
668
|
+
* `MessageOverrides<PdfMessageCatalogue>`.
|
|
669
|
+
*
|
|
670
|
+
* @public
|
|
671
|
+
*/
|
|
672
|
+
export declare type PdfMessageCatalogue = typeof pdfMessages;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* The PDF SDK's English message catalogue: sdk-core's messages, and text for
|
|
676
|
+
* every {@link PdfErrorCode} and every limit's warning. Pass it to
|
|
677
|
+
* `createMessages` from `@hussmartinez/sdk-core`, with the host's locale and
|
|
678
|
+
* overrides.
|
|
679
|
+
*
|
|
680
|
+
* Error text is looked up by code, with the error's `details` as
|
|
681
|
+
* parameters, and never taken from `error.message` (ADR 0019).
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* const messages = createMessages(pdfMessages, { locale: "en", overrides: props.messages });
|
|
686
|
+
* messages.error(error); // "This document has 6,200 pages, which is over the 5,000-page limit."
|
|
687
|
+
* messages.t("warnings.maxPages", { actual: 1_200 });
|
|
688
|
+
* ```
|
|
689
|
+
*
|
|
690
|
+
* @public
|
|
691
|
+
*/
|
|
692
|
+
export declare const pdfMessages: {
|
|
693
|
+
readonly "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.";
|
|
694
|
+
readonly "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.";
|
|
695
|
+
readonly "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.";
|
|
696
|
+
readonly "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.";
|
|
697
|
+
readonly "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.";
|
|
698
|
+
readonly "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.";
|
|
699
|
+
readonly "warnings.maxPages": {
|
|
700
|
+
readonly $plural: "actual";
|
|
701
|
+
} & {
|
|
702
|
+
readonly one: "This document has {actual} page. Large documents may be slow.";
|
|
703
|
+
readonly other: "This document has {actual} pages. Large documents may be slow.";
|
|
704
|
+
};
|
|
705
|
+
readonly "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.";
|
|
706
|
+
readonly "warnings.maxImagePixels": "Some images are very large and may be slow to show.";
|
|
707
|
+
readonly "viewer.label": "Document";
|
|
708
|
+
readonly "viewer.empty": "No document is open.";
|
|
709
|
+
readonly "viewer.page": "Page {page} of {count}";
|
|
710
|
+
readonly "viewer.webLink": "Link to {destination}, opens in a new tab";
|
|
711
|
+
readonly "viewer.emailLink": "Email {destination}";
|
|
712
|
+
readonly "thumbnails.label": "Pages";
|
|
713
|
+
readonly "thumbnails.page": "Page {page} of {count}";
|
|
714
|
+
readonly "thumbnails.number": "{page}";
|
|
715
|
+
readonly "editor.label": "PDF editor";
|
|
716
|
+
readonly "editor.start.title": "Open a PDF to get started";
|
|
717
|
+
readonly "editor.start.retryTitle": "Try another PDF";
|
|
718
|
+
readonly "editor.start.choose": "Choose a PDF";
|
|
719
|
+
readonly "editor.start.retry": "Choose another PDF";
|
|
720
|
+
readonly "editor.start.hint": "Or drop one here. Your file stays on this device and is never uploaded.";
|
|
721
|
+
readonly "editor.opening": "Opening the PDF…";
|
|
722
|
+
readonly "editor.opened": {
|
|
723
|
+
readonly $plural: "count";
|
|
724
|
+
} & {
|
|
725
|
+
readonly one: "Opened a PDF with {count} page.";
|
|
726
|
+
readonly other: "Opened a PDF with {count} pages.";
|
|
727
|
+
};
|
|
728
|
+
readonly "editor.closed": "The PDF was closed.";
|
|
729
|
+
readonly "errors.UNKNOWN": "Something went wrong. Please try again.";
|
|
730
|
+
readonly "errors.ABORTED": "The operation was cancelled.";
|
|
731
|
+
readonly "errors.TIMEOUT": "The operation took too long and was stopped.";
|
|
732
|
+
readonly "errors.WORKER_START_FAILED": "The file processor couldn't start. Reload the page and try again.";
|
|
733
|
+
readonly "errors.WORKER_PROTOCOL_MISMATCH": "The file processor is out of date. Reload the page to update it.";
|
|
734
|
+
readonly "errors.WORKER_CRASHED": "The file processor stopped unexpectedly. Please try again.";
|
|
735
|
+
readonly "errors.WORKER_TERMINATED": "The operation was stopped before it finished. Please try again.";
|
|
736
|
+
readonly "errors.WORKER_METHOD_NOT_FOUND": "This operation isn't available. Reload the page and try again.";
|
|
737
|
+
readonly "errors.WORKER_DATA_NOT_CLONEABLE": "Something went wrong while processing the file. Please try again.";
|
|
738
|
+
readonly "errors.UNSUPPORTED_ENVIRONMENT": "This browser doesn't support a feature this tool needs. Update your browser, or try another one.";
|
|
739
|
+
readonly "errors.FILE_TOO_LARGE": "This file is {actual, fileSize}, which is over the {maximum, fileSize} limit.";
|
|
740
|
+
readonly "errors.TOO_MANY_FILES": {
|
|
741
|
+
readonly $plural: "maximum";
|
|
742
|
+
} & {
|
|
743
|
+
readonly one: "You can add {maximum} file at a time.";
|
|
744
|
+
readonly other: "You can add up to {maximum} files at a time.";
|
|
745
|
+
};
|
|
746
|
+
readonly "errors.DECODED_SIZE_TOO_LARGE": "This file expands to more than {maximum, fileSize} when opened, which is over the limit.";
|
|
747
|
+
readonly "errors.PROCESSING_TIME_EXCEEDED": "Processing this file took too long and was stopped.";
|
|
748
|
+
readonly "warnings.maxFileSize": "This file is {actual, fileSize}. Large files may be slow to process.";
|
|
749
|
+
readonly "warnings.maxFiles": "Adding {actual} files at once may be slow.";
|
|
750
|
+
readonly "warnings.maxDecodedSize": "This file is very large once opened and may be slow to process.";
|
|
751
|
+
readonly "warnings.maxProcessingTime": "This is taking longer than usual.";
|
|
752
|
+
readonly "keys.control": "Ctrl";
|
|
753
|
+
readonly "keys.alt": "Alt";
|
|
754
|
+
readonly "keys.shift": "Shift";
|
|
755
|
+
readonly "keys.meta": "Meta";
|
|
756
|
+
readonly "keys.apple.control": "\u2303";
|
|
757
|
+
readonly "keys.apple.alt": "\u2325";
|
|
758
|
+
readonly "keys.apple.shift": "\u21E7";
|
|
759
|
+
readonly "keys.apple.meta": "\u2318";
|
|
760
|
+
readonly "keys.space": "Space";
|
|
761
|
+
readonly "keys.enter": "Enter";
|
|
762
|
+
readonly "keys.escape": "Esc";
|
|
763
|
+
readonly "keys.tab": "Tab";
|
|
764
|
+
readonly "keys.delete": "Delete";
|
|
765
|
+
readonly "keys.backspace": "Backspace";
|
|
766
|
+
readonly "keys.arrowUp": "\u2191";
|
|
767
|
+
readonly "keys.arrowDown": "\u2193";
|
|
768
|
+
readonly "keys.arrowLeft": "\u2190";
|
|
769
|
+
readonly "keys.arrowRight": "\u2192";
|
|
770
|
+
readonly "keys.home": "Home";
|
|
771
|
+
readonly "keys.end": "End";
|
|
772
|
+
readonly "keys.pageUp": "Page Up";
|
|
773
|
+
readonly "keys.pageDown": "Page Down";
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Moves pages, keeping their relative order, so that the first of them ends
|
|
778
|
+
* up at position `to` of the resulting plan.
|
|
779
|
+
*
|
|
780
|
+
* @public
|
|
781
|
+
*/
|
|
782
|
+
export declare interface PdfMovePagesCommand {
|
|
783
|
+
readonly type: "pdf.movePages";
|
|
784
|
+
readonly pages: readonly string[];
|
|
785
|
+
/** The zero-based position of the first moved page in the resulting plan. */
|
|
786
|
+
readonly to: number;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Facts about one page of a source document.
|
|
791
|
+
*
|
|
792
|
+
* @public
|
|
793
|
+
*/
|
|
794
|
+
export declare interface PdfPageInfo {
|
|
795
|
+
/** Width of the unrotated media box, in PDF points (1/72 inch). */
|
|
796
|
+
readonly width: number;
|
|
797
|
+
/** Height of the unrotated media box, in PDF points. */
|
|
798
|
+
readonly height: number;
|
|
799
|
+
/** The page's own rotation, from its `/Rotate` entry. */
|
|
800
|
+
readonly rotation: PdfRotation;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* The document being edited, as a plan over immutable sources
|
|
805
|
+
* (docs/adr/0003): the pages in order, and form values per source. Bytes
|
|
806
|
+
* are only built from it on export.
|
|
807
|
+
*
|
|
808
|
+
* @public
|
|
809
|
+
*/
|
|
810
|
+
export declare interface PdfPlan {
|
|
811
|
+
readonly pages: readonly PdfPlanPage[];
|
|
812
|
+
/** Form values set in the session, by source ID, then field name. */
|
|
813
|
+
readonly formValues: Readonly<Record<string, Readonly<Record<string, PdfFieldValue>>>>;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* One page of the page plan (docs/adr/0003): a page of a source document,
|
|
818
|
+
* with a rotation added to its own, and the annotations drawn on it. The key
|
|
819
|
+
* is stable while the page moves, so annotations, thumbnails and the
|
|
820
|
+
* selection follow it.
|
|
821
|
+
*
|
|
822
|
+
* @public
|
|
823
|
+
*/
|
|
824
|
+
export declare interface PdfPlanPage {
|
|
825
|
+
/** Unique within the session, and never reused. */
|
|
826
|
+
readonly key: string;
|
|
827
|
+
/** The ID of the source document the page comes from. */
|
|
828
|
+
readonly source: string;
|
|
829
|
+
/** The page's zero-based index in its source. */
|
|
830
|
+
readonly pageIndex: number;
|
|
831
|
+
/** Rotation added to the page's own `/Rotate`. */
|
|
832
|
+
readonly rotation: PdfRotation;
|
|
833
|
+
/** Annotations drawn on the page, in drawing order. */
|
|
834
|
+
readonly annotations: readonly PdfAnnotation[];
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* A point on a page, as fractions of the page's unrotated media box: `x`
|
|
839
|
+
* from the left edge and `y` from the top edge, each from 0 to 1. Fractions
|
|
840
|
+
* keep positions independent of zoom and of the rotation the page is shown
|
|
841
|
+
* with (ADR 0003).
|
|
842
|
+
*
|
|
843
|
+
* @public
|
|
844
|
+
*/
|
|
845
|
+
export declare interface PdfPoint {
|
|
846
|
+
readonly x: number;
|
|
847
|
+
readonly y: number;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* The port for transforming PDFs: build an output document from sources,
|
|
852
|
+
* pages and export options (ADR 0003, ADR 0008). The SDK's qpdf adapter
|
|
853
|
+
* implements it in a worker; hosts can pass their own to the editor's
|
|
854
|
+
* `processor` prop, and every implementation must pass the processor's
|
|
855
|
+
* contract tests.
|
|
856
|
+
*
|
|
857
|
+
* One call runs the whole pipeline, so the bytes cross the worker boundary
|
|
858
|
+
* once in each direction. Failures reject with `PdfError`.
|
|
859
|
+
*
|
|
860
|
+
* @public
|
|
861
|
+
*/
|
|
862
|
+
export declare interface PdfProcessor {
|
|
863
|
+
/**
|
|
864
|
+
* Builds a document. The sources' bytes are copied unless `transfer` is
|
|
865
|
+
* set. The result is a new buffer the caller owns.
|
|
866
|
+
*
|
|
867
|
+
* @throws `PdfError` with `INVALID_PDF` when a source can't be read,
|
|
868
|
+
* `PASSWORD_REQUIRED` when one is encrypted, and `TypeError` or
|
|
869
|
+
* `RangeError` for a job that refers to an unknown source or page.
|
|
870
|
+
*/
|
|
871
|
+
build(job: PdfBuildJob, options?: PdfBuildOptions): Promise<Uint8Array>;
|
|
872
|
+
/** Releases the processor and its worker. Pending builds reject. */
|
|
873
|
+
destroy(): Promise<void>;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Options for {@link createPdfProcessor}.
|
|
878
|
+
*
|
|
879
|
+
* @public
|
|
880
|
+
*/
|
|
881
|
+
export declare interface PdfProcessorOptions {
|
|
882
|
+
/**
|
|
883
|
+
* Where your application serves the package's `dist/assets/` directory,
|
|
884
|
+
* on its own origin, such as `"/pdf-sdk/"`, the same URL as the engine's.
|
|
885
|
+
* The worker then loads from `processing/processing.worker.js`, and
|
|
886
|
+
* fetches `processing/qpdf.wasm`, which it checks against this version's
|
|
887
|
+
* hash before using it. Use it for Content Security Policies without
|
|
888
|
+
* `worker-src blob:` (docs/adr/0007). By default the worker is inlined.
|
|
889
|
+
*/
|
|
890
|
+
readonly assetsUrl?: string | URL;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* A rectangle on a page, in the same fractions as {@link PdfPoint}: its
|
|
895
|
+
* top-left corner, width and height.
|
|
896
|
+
*
|
|
897
|
+
* @public
|
|
898
|
+
*/
|
|
899
|
+
export declare interface PdfRect {
|
|
900
|
+
readonly x: number;
|
|
901
|
+
readonly y: number;
|
|
902
|
+
readonly width: number;
|
|
903
|
+
readonly height: number;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Removes an annotation from a page.
|
|
908
|
+
*
|
|
909
|
+
* @public
|
|
910
|
+
*/
|
|
911
|
+
export declare interface PdfRemoveAnnotationCommand {
|
|
912
|
+
readonly type: "pdf.removeAnnotation";
|
|
913
|
+
readonly page: string;
|
|
914
|
+
/** The annotation's ID. */
|
|
915
|
+
readonly id: string;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* How to render a page.
|
|
920
|
+
*
|
|
921
|
+
* @public
|
|
922
|
+
*/
|
|
923
|
+
export declare interface PdfRenderOptions extends PdfCallOptions {
|
|
924
|
+
/** CSS pixels per PDF point. `1` renders a US Letter page 612 CSS pixels wide. */
|
|
925
|
+
readonly scale: number;
|
|
926
|
+
/**
|
|
927
|
+
* Device pixels per CSS pixel, usually `window.devicePixelRatio`. Defaults
|
|
928
|
+
* to 1. The engine lowers it as needed to stay within
|
|
929
|
+
* {@link PDF_MAX_CANVAS_PIXELS}.
|
|
930
|
+
*/
|
|
931
|
+
readonly pixelRatio?: number;
|
|
932
|
+
/** Rotation added to the page's own, for the page plan (ADR 0003). Defaults to 0. */
|
|
933
|
+
readonly rotation?: PdfRotation;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Puts every page in a new order, given as every key exactly once. It's what
|
|
938
|
+
* undoing a move runs.
|
|
939
|
+
*
|
|
940
|
+
* @public
|
|
941
|
+
*/
|
|
942
|
+
export declare interface PdfReorderPagesCommand {
|
|
943
|
+
readonly type: "pdf.reorderPages";
|
|
944
|
+
readonly order: readonly string[];
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Puts deleted pages back at their positions. It's what undoing a delete
|
|
949
|
+
* runs, and it can be used directly.
|
|
950
|
+
*
|
|
951
|
+
* @public
|
|
952
|
+
*/
|
|
953
|
+
export declare interface PdfRestorePagesCommand {
|
|
954
|
+
readonly type: "pdf.restorePages";
|
|
955
|
+
/** Each page, and the index it takes in the resulting plan, in increasing order. */
|
|
956
|
+
readonly entries: readonly {
|
|
957
|
+
readonly index: number;
|
|
958
|
+
readonly page: PdfPlanPage;
|
|
959
|
+
}[];
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Rotates pages by an angle, added to their current rotation.
|
|
964
|
+
*
|
|
965
|
+
* @public
|
|
966
|
+
*/
|
|
967
|
+
export declare interface PdfRotatePagesCommand {
|
|
968
|
+
readonly type: "pdf.rotatePages";
|
|
969
|
+
/** The keys of the pages to rotate. */
|
|
970
|
+
readonly pages: readonly string[];
|
|
971
|
+
/** Degrees, clockwise, in multiples of 90. Negative turns anticlockwise. */
|
|
972
|
+
readonly angle: number;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* A rotation in degrees, clockwise.
|
|
977
|
+
*
|
|
978
|
+
* @public
|
|
979
|
+
*/
|
|
980
|
+
export declare type PdfRotation = 0 | 90 | 180 | 270;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* The document being edited, as a framework-agnostic store (ADR 0008): a
|
|
984
|
+
* page plan over the documents opened and inserted, edited with commands,
|
|
985
|
+
* with undo and redo (ADR 0010, docs/adr/0003). React binds to it with
|
|
986
|
+
* `useSyncExternalStore`, and the element binds to the same store.
|
|
987
|
+
*
|
|
988
|
+
* @public
|
|
989
|
+
*/
|
|
990
|
+
export declare interface PdfSession {
|
|
991
|
+
/** The current snapshot, the same object until something changes. */
|
|
992
|
+
getSnapshot(): PdfSessionSnapshot;
|
|
993
|
+
/** Calls the listener after every change. Returns a function that unsubscribes. */
|
|
994
|
+
subscribe(listener: () => void): () => void;
|
|
995
|
+
/**
|
|
996
|
+
* Opens a document, replacing the current one and its history once it has
|
|
997
|
+
* opened. The file is checked against the file policy before it's read.
|
|
998
|
+
* Rejects with a `PdfError`, which the snapshot also holds; the current
|
|
999
|
+
* document, if any, stays open.
|
|
1000
|
+
*/
|
|
1001
|
+
open(file: Blob | PdfBytes, options?: PdfCallOptions): Promise<void>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Inserts the pages of another document, as one undoable step. If the
|
|
1004
|
+
* documents held would then exceed `maxSessionSize`, the session first
|
|
1005
|
+
* drops the redo steps, then the oldest undo steps, as far as needed to
|
|
1006
|
+
* release documents only they refer to, and sets `historyTrimmed`. If even
|
|
1007
|
+
* that isn't enough, it rejects with `SESSION_TOO_LARGE` and changes
|
|
1008
|
+
* nothing.
|
|
1009
|
+
*/
|
|
1010
|
+
insert(file: Blob | PdfBytes, options?: PdfInsertOptions): Promise<void>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Runs one command, or several as one undoable step. Throws `TypeError`
|
|
1013
|
+
* or `RangeError` for a command that doesn't fit the plan, and changes
|
|
1014
|
+
* nothing then.
|
|
1015
|
+
*/
|
|
1016
|
+
execute(commands: PdfCommand | readonly PdfCommand[]): void;
|
|
1017
|
+
undo(): void;
|
|
1018
|
+
redo(): void;
|
|
1019
|
+
/** A plan page's size, and its rotation as shown: its own plus the plan's. */
|
|
1020
|
+
getPage(key: string, options?: PdfCallOptions): Promise<PdfPageInfo>;
|
|
1021
|
+
/** Renders a plan page with its rotation. */
|
|
1022
|
+
renderPage(key: string, canvas: HTMLCanvasElement, options: Omit<PdfRenderOptions, "rotation">): Promise<void>;
|
|
1023
|
+
/** A plan page's text, positioned on the unrotated page. */
|
|
1024
|
+
getTextContent(key: string, options?: PdfCallOptions): Promise<PdfTextContent>;
|
|
1025
|
+
/** A plan page's form fields, with the session's values applied. */
|
|
1026
|
+
getFormFields(key: string, options?: PdfCallOptions): Promise<readonly PdfFormField[]>;
|
|
1027
|
+
/** A plan page's web and email links, positioned on the unrotated page. */
|
|
1028
|
+
getLinks(key: string, options?: PdfCallOptions): Promise<readonly PdfLink[]>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Builds the document as it is now: its pages in plan order, with their
|
|
1031
|
+
* rotations, form values and annotations, compressed or encrypted if asked.
|
|
1032
|
+
* An unchanged document with no options is returned as its original bytes,
|
|
1033
|
+
* without the processor. The result is a new buffer the caller owns.
|
|
1034
|
+
*/
|
|
1035
|
+
export(options?: PdfExportOptions): Promise<Uint8Array>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Selects pages, by key, replacing the selection. Keys the plan doesn't
|
|
1038
|
+
* have are ignored.
|
|
1039
|
+
*/
|
|
1040
|
+
select(keys: readonly string[]): void;
|
|
1041
|
+
/** Records the page the user is looking at, as a viewer scrolls. */
|
|
1042
|
+
setCurrentPage(key: string): void;
|
|
1043
|
+
/** Makes a page current and asks viewers to bring it into view. */
|
|
1044
|
+
goToPage(key: string): void;
|
|
1045
|
+
/** Closes the document and releases its sources. */
|
|
1046
|
+
close(): Promise<void>;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Anonymous usage events, for a host's analytics (ADR 0010). They never
|
|
1051
|
+
* contain file names, contents, form values or annotation text.
|
|
1052
|
+
*
|
|
1053
|
+
* @public
|
|
1054
|
+
*/
|
|
1055
|
+
export declare type PdfSessionEvent = {
|
|
1056
|
+
readonly type: "document_opened";
|
|
1057
|
+
readonly pageCount: number;
|
|
1058
|
+
} | {
|
|
1059
|
+
readonly type: "document_closed";
|
|
1060
|
+
} | {
|
|
1061
|
+
readonly type: "pages_inserted";
|
|
1062
|
+
readonly pageCount: number;
|
|
1063
|
+
} | {
|
|
1064
|
+
readonly type: "command";
|
|
1065
|
+
readonly commands: readonly PdfCommand["type"][];
|
|
1066
|
+
} | {
|
|
1067
|
+
readonly type: "undo";
|
|
1068
|
+
} | {
|
|
1069
|
+
readonly type: "redo";
|
|
1070
|
+
} | {
|
|
1071
|
+
readonly type: "document_exported";
|
|
1072
|
+
readonly pageCount: number;
|
|
1073
|
+
readonly compressed: boolean;
|
|
1074
|
+
readonly encrypted: boolean;
|
|
1075
|
+
} | {
|
|
1076
|
+
readonly type: "failed";
|
|
1077
|
+
readonly operation: "open" | "insert" | "export";
|
|
1078
|
+
readonly code: string;
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Options for {@link createPdfSession}.
|
|
1083
|
+
*
|
|
1084
|
+
* @public
|
|
1085
|
+
*/
|
|
1086
|
+
export declare interface PdfSessionOptions {
|
|
1087
|
+
/** Opens, reads and renders documents, such as `createPdfJsEngine()`. */
|
|
1088
|
+
readonly engine: PdfEngine;
|
|
1089
|
+
/** Builds exported documents, such as `createPdfProcessor()`. Needed for `export()`. */
|
|
1090
|
+
readonly processor?: PdfProcessor;
|
|
1091
|
+
/** Limits for untrusted files (docs/adr/0004). Unknown names throw. */
|
|
1092
|
+
readonly filePolicy?: PdfFilePolicyOverrides;
|
|
1093
|
+
/** Receives anonymous usage events. Errors it throws are ignored. */
|
|
1094
|
+
readonly onEvent?: (event: PdfSessionEvent) => void;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* The session's state at one moment. Snapshots are immutable: every change
|
|
1099
|
+
* makes a new one, so `useSyncExternalStore` and other subscribers can
|
|
1100
|
+
* compare them by identity.
|
|
1101
|
+
*
|
|
1102
|
+
* @public
|
|
1103
|
+
*/
|
|
1104
|
+
export declare interface PdfSessionSnapshot {
|
|
1105
|
+
readonly status: PdfSessionStatus;
|
|
1106
|
+
/** The document being edited: its pages, in order, and form values. */
|
|
1107
|
+
readonly plan: PdfPlan;
|
|
1108
|
+
/** The source documents the session holds. */
|
|
1109
|
+
readonly sources: readonly PdfSourceInfo[];
|
|
1110
|
+
readonly canUndo: boolean;
|
|
1111
|
+
readonly canRedo: boolean;
|
|
1112
|
+
/** Whether a document is being opened or inserted. */
|
|
1113
|
+
readonly busy: boolean;
|
|
1114
|
+
/** Why the last open or insert failed. Show its text by its code. */
|
|
1115
|
+
readonly error: PdfError | undefined;
|
|
1116
|
+
/** Limits the open documents are close to. */
|
|
1117
|
+
readonly warnings: readonly PdfWarning[];
|
|
1118
|
+
/**
|
|
1119
|
+
* The bytes of every document the session holds, which the
|
|
1120
|
+
* `maxSessionSize` limit counts: those the plan uses, and those the undo
|
|
1121
|
+
* and redo history can bring back (docs/adr/0004).
|
|
1122
|
+
*/
|
|
1123
|
+
readonly sessionBytes: number;
|
|
1124
|
+
/**
|
|
1125
|
+
* Whether undo steps were dropped since the document opened, to make room
|
|
1126
|
+
* for an insert within `maxSessionSize`. Editors say so, because the
|
|
1127
|
+
* earliest edits can no longer be undone (ADR 0010).
|
|
1128
|
+
*/
|
|
1129
|
+
readonly historyTrimmed: boolean;
|
|
1130
|
+
/**
|
|
1131
|
+
* The keys of the selected pages, in plan order. Tools act on them, such as
|
|
1132
|
+
* rotating the selection. View state: not undoable, and never in events.
|
|
1133
|
+
*/
|
|
1134
|
+
readonly selection: readonly string[];
|
|
1135
|
+
/** The key of the page the user is looking at, if a document is open. */
|
|
1136
|
+
readonly currentPage: string | undefined;
|
|
1137
|
+
/**
|
|
1138
|
+
* The latest request to bring a page into view, from `goToPage`. Viewers
|
|
1139
|
+
* scroll to `page` each time `sequence` changes.
|
|
1140
|
+
*/
|
|
1141
|
+
readonly navigation: {
|
|
1142
|
+
readonly page: string;
|
|
1143
|
+
readonly sequence: number;
|
|
1144
|
+
} | undefined;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* What the session is doing.
|
|
1149
|
+
*
|
|
1150
|
+
* - `empty`: no document is open.
|
|
1151
|
+
* - `opening`: a document is being opened, replacing any other.
|
|
1152
|
+
* - `ready`: a document is open.
|
|
1153
|
+
* - `error`: no document is open, because the last open failed; `error`
|
|
1154
|
+
* says why. A failed open while a document is open keeps that document,
|
|
1155
|
+
* with the status `ready` and `error` set.
|
|
1156
|
+
*
|
|
1157
|
+
* @public
|
|
1158
|
+
*/
|
|
1159
|
+
export declare type PdfSessionStatus = "empty" | "opening" | "ready" | "error";
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Sets a form field's value in one source, or clears the session's value with
|
|
1163
|
+
* `null`, so the document's own value applies again.
|
|
1164
|
+
*
|
|
1165
|
+
* @public
|
|
1166
|
+
*/
|
|
1167
|
+
export declare interface PdfSetFieldValueCommand {
|
|
1168
|
+
readonly type: "pdf.setFieldValue";
|
|
1169
|
+
readonly source: string;
|
|
1170
|
+
readonly field: string;
|
|
1171
|
+
readonly value: PdfFieldValue | null;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* A source document the session holds: opened or inserted, never changed.
|
|
1176
|
+
*
|
|
1177
|
+
* @public
|
|
1178
|
+
*/
|
|
1179
|
+
export declare interface PdfSourceInfo {
|
|
1180
|
+
/** Unique within the session, and never reused. */
|
|
1181
|
+
readonly id: string;
|
|
1182
|
+
readonly pageCount: number;
|
|
1183
|
+
/** The size of its bytes. */
|
|
1184
|
+
readonly byteLength: number;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* A freehand pen stroke, or a highlighter stroke, which is drawn translucent.
|
|
1189
|
+
*
|
|
1190
|
+
* @public
|
|
1191
|
+
*/
|
|
1192
|
+
export declare interface PdfStrokeAnnotation {
|
|
1193
|
+
readonly id: string;
|
|
1194
|
+
readonly type: "pen" | "highlight";
|
|
1195
|
+
/** The stroke's points, in page fractions. */
|
|
1196
|
+
readonly points: readonly PdfPoint[];
|
|
1197
|
+
readonly color: PdfColor;
|
|
1198
|
+
/** Line width, as a fraction of the page's height. */
|
|
1199
|
+
readonly width: number;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* A text note placed on the page.
|
|
1204
|
+
*
|
|
1205
|
+
* @public
|
|
1206
|
+
*/
|
|
1207
|
+
export declare interface PdfTextAnnotation {
|
|
1208
|
+
readonly id: string;
|
|
1209
|
+
readonly type: "text";
|
|
1210
|
+
/** The top-left corner of the text, in page fractions. */
|
|
1211
|
+
readonly at: PdfPoint;
|
|
1212
|
+
/** The note's text. It's drawn as text, never interpreted as markup. */
|
|
1213
|
+
readonly text: string;
|
|
1214
|
+
/** Font size, as a fraction of the page's height. */
|
|
1215
|
+
readonly size: number;
|
|
1216
|
+
readonly color: PdfColor;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* The text of one page, in reading order as the document stores it.
|
|
1221
|
+
*
|
|
1222
|
+
* @public
|
|
1223
|
+
*/
|
|
1224
|
+
export declare interface PdfTextContent {
|
|
1225
|
+
readonly items: readonly PdfTextItem[];
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* A run of text on a page, for the text layer, selection, assistive
|
|
1230
|
+
* technology and search. Positions are fractions of the unrotated media box
|
|
1231
|
+
* ({@link PdfRect}).
|
|
1232
|
+
*
|
|
1233
|
+
* @public
|
|
1234
|
+
*/
|
|
1235
|
+
export declare interface PdfTextItem {
|
|
1236
|
+
/** The text, as the document encodes it. Always rendered as text, never as markup. */
|
|
1237
|
+
readonly text: string;
|
|
1238
|
+
/** The box the text occupies. */
|
|
1239
|
+
readonly rect: PdfRect;
|
|
1240
|
+
/** Rotation of the text's baseline, in degrees, counter-clockwise. */
|
|
1241
|
+
readonly angle: number;
|
|
1242
|
+
/** Whether a line break follows this item. */
|
|
1243
|
+
readonly endOfLine: boolean;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Options for calls that take PDF bytes.
|
|
1248
|
+
*
|
|
1249
|
+
* @public
|
|
1250
|
+
*/
|
|
1251
|
+
export declare interface PdfTransferOptions extends PdfCallOptions {
|
|
1252
|
+
/**
|
|
1253
|
+
* Hand the bytes' buffers to the worker instead of copying them. The
|
|
1254
|
+
* caller's buffers are detached and must not be used afterwards. Defaults
|
|
1255
|
+
* to `false`, so a caller's bytes are never detached by surprise.
|
|
1256
|
+
*/
|
|
1257
|
+
readonly transfer?: boolean;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* A file policy warning: a value at or above a limit's warning threshold,
|
|
1262
|
+
* but within its maximum (ADR 0020). Show its text from
|
|
1263
|
+
* `warnings.<limit>` in the message catalogue, with `actual` as a parameter.
|
|
1264
|
+
*
|
|
1265
|
+
* @public
|
|
1266
|
+
*/
|
|
1267
|
+
export declare interface PdfWarning {
|
|
1268
|
+
readonly limit: PdfLimitName;
|
|
1269
|
+
readonly actual: number;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* The URL, normalised, if it's an absolute `http`, `https` or `mailto` URL
|
|
1274
|
+
* without credentials (ADR 0012), and otherwise undefined. Every engine
|
|
1275
|
+
* adapter filters links with it, and the viewer checks again before
|
|
1276
|
+
* rendering one.
|
|
1277
|
+
*
|
|
1278
|
+
* URLs with a user name or password are refused: in
|
|
1279
|
+
* `https://bank.example@evil.example/`, the part a reader notices is a user
|
|
1280
|
+
* name, and the link goes to `evil.example`, a common phishing shape.
|
|
1281
|
+
*
|
|
1282
|
+
* @public
|
|
1283
|
+
*/
|
|
1284
|
+
export declare function safeLinkUrl(url: string): string | undefined;
|
|
1285
|
+
|
|
1286
|
+
export { }
|