@pdfluent/sdk-wasm 1.0.0 → 1.2.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-COMMERCIAL +8 -0
- package/NOTICE +7 -0
- package/README.md +1 -1
- package/THIRD_PARTY_LICENSES.txt +149 -3
- package/package.json +16 -5
- package/xfa_wasm.augment.d.ts +188 -0
- package/xfa_wasm.d.ts +242 -0
- package/xfa_wasm.js +498 -2
- package/xfa_wasm_bg.wasm +0 -0
- package/xfa_wasm_bg.wasm.d.ts +13 -0
- /package/snippets/{xfa-wasm-df2db187f9a0e994 → xfa-wasm-0357326a9eb2f21e}/inline0.js +0 -0
package/LICENSE-COMMERCIAL
CHANGED
|
@@ -98,6 +98,14 @@ to relicense and need no licence from PDFluent. `NOTICE` records which they are;
|
|
|
98
98
|
|
|
99
99
|
This licence covers the components on PDFluent's side of that boundary.
|
|
100
100
|
|
|
101
|
+
Optional model files and runtime libraries that the software downloads on
|
|
102
|
+
your explicit request (for example with `pdfluent models install`) are
|
|
103
|
+
licensed as follows. Model files trained by PDFluent are licensed under
|
|
104
|
+
the same terms as the software. Third-party model files and runtime
|
|
105
|
+
libraries are licensed to you under their own terms, listed in the notice
|
|
106
|
+
that accompanies them, and are provided as-is; PDFluent gives no warranty
|
|
107
|
+
or indemnity for them.
|
|
108
|
+
|
|
101
109
|
|
|
102
110
|
4. Attribution
|
|
103
111
|
--------------
|
package/NOTICE
CHANGED
|
@@ -71,6 +71,9 @@ that. See https://pdfluent.com/sdk/pricing.
|
|
|
71
71
|
|
|
72
72
|
pdfluent — the unified facade SDK
|
|
73
73
|
pdf-engine — orchestration and document model
|
|
74
|
+
(the TATR post-processing behind `ort-tables` is a port of
|
|
75
|
+
Microsoft's table-transformer, © Microsoft Corporation,
|
|
76
|
+
MIT; that notice ships inside the crate as THIRD_PARTY.md)
|
|
74
77
|
pdf-manip — page-level manipulation (merge, split, rotate, etc.)
|
|
75
78
|
(six unmodified Adobe CMap resources, compiled in
|
|
76
79
|
to read the character codes of a predefined CMap;
|
|
@@ -81,11 +84,14 @@ that. See https://pdfluent.com/sdk/pricing.
|
|
|
81
84
|
pdfluent-sign — digital signatures (PAdES, S/MIME)
|
|
82
85
|
pdf-compliance — PDF/A, PDF/UA, PDF/X validation and conversion
|
|
83
86
|
pdfluent-extract — text and image extraction
|
|
87
|
+
epub-extract — EPUB content extraction
|
|
84
88
|
pdfluent-forms — AcroForm support
|
|
85
89
|
pdf-annot — annotations
|
|
86
90
|
pdf-docx — DOCX export
|
|
87
91
|
pdf-xlsx — XLSX export and table extraction
|
|
92
|
+
xlsx-extract — XLSX workbook extraction to engine blocks
|
|
88
93
|
pdf-pptx — PowerPoint PPTX export
|
|
94
|
+
pptx-extract — PowerPoint PPTX extraction to blocks
|
|
89
95
|
pdf-invoice — FDF/XFDF form data exchange and ZUGFeRD/Factur-X
|
|
90
96
|
pdf-text-format — text run formatting
|
|
91
97
|
pdf-standard-fonts — the Standard 14 font programs, compiled in
|
|
@@ -107,6 +113,7 @@ that. See https://pdfluent.com/sdk/pricing.
|
|
|
107
113
|
xfa-js-sandboxed — sandboxed JavaScript runtime for XFA scripts
|
|
108
114
|
formcalc-interpreter — FormCalc evaluation
|
|
109
115
|
xfa-json — XFA JSON conversion
|
|
116
|
+
pdfluent-cli — command-line interface over the facade
|
|
110
117
|
|
|
111
118
|
The Software produces the same output whether or not a commercial licence is
|
|
112
119
|
held: there is no licence key, nothing is withheld and no marker is added
|
package/README.md
CHANGED
|
@@ -295,4 +295,4 @@ add-on). The two texts are `LICENSE` and `LICENSE-COMMERCIAL` in this package.
|
|
|
295
295
|
- **Documentation:** <https://pdfluent.com/docs>
|
|
296
296
|
- **Pricing:** <https://pdfluent.com/sdk/pricing>
|
|
297
297
|
- **PDFluent editor** (source-available): <https://github.com/pdfluent/pdfluent>. The free desktop app this SDK powers.
|
|
298
|
-
- Built by [Innovation Trigger
|
|
298
|
+
- Built by [Innovation Trigger B.V.](https://pdfluent.com)
|
package/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -321,7 +321,8 @@ unic-char-range, unic-common, unic-ucd-ident, unic-ucd-version, unicode-bidi,
|
|
|
321
321
|
unicode-normalization, unicode-properties, unicode-segmentation, unicode-width,
|
|
322
322
|
unicode-xid, url, utf-8, utf8_iter, utf8parse, uuid, vello_common, vello_cpu,
|
|
323
323
|
wasm-bindgen, wasm-bindgen-futures, wasm-bindgen-macro,
|
|
324
|
-
wasm-bindgen-macro-support, wasm-bindgen-shared, wasm-streams,
|
|
324
|
+
wasm-bindgen-macro-support, wasm-bindgen-shared, wasm-streams, wasmi, wasmi_collections, wasmi_core,
|
|
325
|
+
wasmi_ir, web-sys,
|
|
325
326
|
web-time, web_atoms, weezl, winapi, winapi-i686-pc-windows-gnu,
|
|
326
327
|
winapi-x86_64-pc-windows-gnu, window-vibrancy, windows, windows-collections,
|
|
327
328
|
windows-core, windows-future, windows-implement, windows-interface,
|
|
@@ -412,8 +413,7 @@ new_debug_unreachable, nom, nom_locate, noop_proc_macro, nu-ansi-term,
|
|
|
412
413
|
number_prefix, objc2, objc2-encode, objc2-foundation, open, openssl-sys,
|
|
413
414
|
os_pipe, pango, pango-sys, pdf-bench, pdf-desktop, pdf-diff, pdf-java,
|
|
414
415
|
pdfluent-lopdf, phf, phf_generator, phf_macros, phf_shared, plist,
|
|
415
|
-
precomputed-hash, quick-xml, redox_syscall, redox_users, rfd, rgb,
|
|
416
|
-
rquickjs-core, rquickjs-macro, rquickjs-sys, rusqlite, schannel, schemars,
|
|
416
|
+
precomputed-hash, quick-xml, redox_syscall, redox_users, rfd, rgb, rusqlite, schannel, schemars,
|
|
417
417
|
schemars_derive, sharded-slab, shared_child, sigchld, simd-adler32,
|
|
418
418
|
simd_helpers, slab, soup3, soup3-sys, spin, strsim, synstructure, tiff,
|
|
419
419
|
tokio, tokio-macros, tokio-native-tls, tokio-util, tower, tower-http,
|
|
@@ -731,6 +731,152 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
731
731
|
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
732
732
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
733
733
|
|
|
734
|
+
================================================================================
|
|
735
|
+
QuickJS-ng — the script engine, compiled into xfa-js-sandboxed's WebAssembly module
|
|
736
|
+
https://github.com/quickjs-ng/quickjs (version 0.7.0)
|
|
737
|
+
================================================================================
|
|
738
|
+
|
|
739
|
+
QuickJS (MIT) is a component of crates/xfa-js-sandboxed/wasm-guest/qjs_guest.wasm:
|
|
740
|
+
the module is compiled from the C sources in wasm-guest/quickjs/ (two changes,
|
|
741
|
+
listed in wasm-guest/PATCHES.md) and is interpreted by the wasmi crate. No native
|
|
742
|
+
C code runs. The module also contains code from wasi-libc (Apache-2.0 WITH
|
|
743
|
+
LLVM-exception; MIT and BSD-2-Clause parts derived from musl) and LLVM
|
|
744
|
+
compiler-rt (Apache-2.0 WITH LLVM-exception), linked in by the toolchain
|
|
745
|
+
(zig 0.16.0, build tooling only, not shipped). See wasm-guest/NOTICE.
|
|
746
|
+
|
|
747
|
+
The MIT License (MIT)
|
|
748
|
+
|
|
749
|
+
Copyright (c) 2017-2021 Fabrice Bellard
|
|
750
|
+
Copyright (c) 2017-2021 Charlie Gordon
|
|
751
|
+
Copyright (c) 2023 Ben Noordhuis
|
|
752
|
+
Copyright (c) 2023 Saúl Ibarra Corretgé
|
|
753
|
+
|
|
754
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
755
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
756
|
+
in the Software without restriction, including without limitation the rights
|
|
757
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
758
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
759
|
+
furnished to do so, subject to the following conditions:
|
|
760
|
+
|
|
761
|
+
The above copyright notice and this permission notice shall be included in
|
|
762
|
+
all copies or substantial portions of the Software.
|
|
763
|
+
|
|
764
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
765
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
766
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
767
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
768
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
769
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
770
|
+
THE SOFTWARE.
|
|
771
|
+
|
|
772
|
+
================================================================================
|
|
773
|
+
tract — ONNX inference for the optional vision layer (#636)
|
|
774
|
+
https://github.com/sonos/tract
|
|
775
|
+
================================================================================
|
|
776
|
+
|
|
777
|
+
The `vision` cargo feature of pdf-engine (off by default; passthrough in
|
|
778
|
+
pdfluent) runs ONNX models through tract-onnx 0.23 (default-features off, so
|
|
779
|
+
without the `transformers` op-set). No trained model ships; the only ONNX
|
|
780
|
+
bytes in the tree are the 152-byte identity fixture the tests run.
|
|
781
|
+
|
|
782
|
+
Copyright (c) Mathieu Poumeyrol and the tract contributors.
|
|
783
|
+
|
|
784
|
+
Dual-licensed under MIT and Apache-2.0, at our option. The crates as resolved
|
|
785
|
+
(tract-onnx, tract-onnx-opl, tract-hir, tract-core, tract-data,
|
|
786
|
+
tract-extra, tract-nnef, tract-linalg and their transitive dependencies
|
|
787
|
+
bytes, derive-new, log, memmap2, nom, nom-language, num-integer,
|
|
788
|
+
num-rational, num-traits, prost, smallvec and the tract-*-sys/metal
|
|
789
|
+
helpers) each declare MIT OR Apache-2.0 and are covered by the texts below;
|
|
790
|
+
both are permissive and impose no copyleft obligation on the product. This
|
|
791
|
+
entry stands outside the `cargo license 2026-05-26` list above because that
|
|
792
|
+
list predates the dependency; the next regeneration absorbs these crates.
|
|
793
|
+
|
|
794
|
+
--- MIT License ---
|
|
795
|
+
|
|
796
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
797
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
798
|
+
in the Software without restriction, including without limitation the rights
|
|
799
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
800
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
801
|
+
furnished to do so, subject to the following conditions:
|
|
802
|
+
|
|
803
|
+
The above copyright notice and this permission notice shall be included in all
|
|
804
|
+
copies or substantial portions of the Software.
|
|
805
|
+
|
|
806
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
807
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
808
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
809
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
810
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
811
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
812
|
+
SOFTWARE.
|
|
813
|
+
|
|
814
|
+
--- Apache License, Version 2.0 ---
|
|
815
|
+
|
|
816
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
817
|
+
you may not use this file except in compliance with the License.
|
|
818
|
+
You may obtain a copy of the License at
|
|
819
|
+
|
|
820
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
821
|
+
|
|
822
|
+
Unless required by applicable law or agreed to in writing, software
|
|
823
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
824
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
825
|
+
See the License for the specific language governing permissions and
|
|
826
|
+
limitations under the License.
|
|
827
|
+
|
|
828
|
+
================================================================================
|
|
829
|
+
table-transformer — Table Transformer structure post-processing (MIT)
|
|
830
|
+
https://github.com/microsoft/table-transformer
|
|
831
|
+
commit 16d124f616109746b7785f03085100f1f6247575
|
|
832
|
+
================================================================================
|
|
833
|
+
|
|
834
|
+
Copyright (c) Microsoft Corporation.
|
|
835
|
+
|
|
836
|
+
What is used, in two forms:
|
|
837
|
+
|
|
838
|
+
crates/pdf-engine/src/learned/tables_tatr.rs a Rust port of the
|
|
839
|
+
publisher's row/column/header/spanning-cell reconciliation and
|
|
840
|
+
grid-cell construction (`objects_to_cells` and everything it
|
|
841
|
+
calls), behind the `ort-tables` feature of pdf-engine. Same
|
|
842
|
+
thresholds, same refinement, same cells; the parity test feeds
|
|
843
|
+
raw ONNX outputs and requires the Python-decoded cells, value
|
|
844
|
+
for value.
|
|
845
|
+
scripts/extraction/tables_b/tatr_postprocess.py the Python original,
|
|
846
|
+
`src/postprocess.py` at the commit above, vendored verbatim
|
|
847
|
+
(see the header in that file). The zero-shot eval runs TATR
|
|
848
|
+
through it rather than through a reimplementation, so a TATR
|
|
849
|
+
number is the publisher's reading of its own boxes.
|
|
850
|
+
|
|
851
|
+
MIT is permissive, no copyleft: the licence text below is that commit's
|
|
852
|
+
LICENSE, word for word. The same copyright line and text ship inside the
|
|
853
|
+
pdf-engine crate as THIRD_PARTY.md, because a crates.io reader has this
|
|
854
|
+
file's section in front of them only through the repository.
|
|
855
|
+
|
|
856
|
+
--- MIT License ---
|
|
857
|
+
|
|
858
|
+
MIT License
|
|
859
|
+
|
|
860
|
+
Copyright (c) Microsoft Corporation.
|
|
861
|
+
|
|
862
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
863
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
864
|
+
in the Software without restriction, including without limitation the rights
|
|
865
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
866
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
867
|
+
furnished to do so, subject to the following conditions:
|
|
868
|
+
|
|
869
|
+
The above copyright notice and this permission notice shall be included in all
|
|
870
|
+
copies or substantial portions of the Software.
|
|
871
|
+
|
|
872
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
873
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
874
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
875
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
876
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
877
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
878
|
+
SOFTWARE
|
|
879
|
+
|
|
734
880
|
================================================================================
|
|
735
881
|
END OF THIRD PARTY LICENSES
|
|
736
882
|
================================================================================
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@pdfluent/sdk-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "PDFluent browser SDK — find and replace PDF text programmatically while preserving fonts and layout, plus edit, annotate, redact, sign and validate PDFs (including XFA), entirely client-side via WASM.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE-OFFER",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"LICENSE-COMMERCIAL",
|
|
19
19
|
"LICENSE-OFFER",
|
|
20
20
|
"NOTICE",
|
|
21
|
-
"THIRD_PARTY_LICENSES.txt"
|
|
21
|
+
"THIRD_PARTY_LICENSES.txt",
|
|
22
|
+
"xfa_wasm.augment.d.ts"
|
|
22
23
|
],
|
|
23
24
|
"main": "xfa_wasm.js",
|
|
24
25
|
"types": "xfa_wasm.d.ts",
|
|
@@ -43,11 +44,21 @@
|
|
|
43
44
|
"redact"
|
|
44
45
|
],
|
|
45
46
|
"homepage": "https://pdfluent.com",
|
|
46
|
-
"author": "Innovation Trigger
|
|
47
|
+
"author": "Innovation Trigger B.V. <team@pdfluent.com>",
|
|
47
48
|
"bugs": {
|
|
48
49
|
"url": "https://github.com/pdfluent/pdfluent-sdk/issues"
|
|
49
50
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./xfa_wasm.d.ts",
|
|
54
|
+
"import": "./xfa_wasm.js",
|
|
55
|
+
"default": "./xfa_wasm.js"
|
|
56
|
+
},
|
|
57
|
+
"./augment": {
|
|
58
|
+
"types": "./xfa_wasm.augment.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./xfa_wasm_bg.wasm": "./xfa_wasm_bg.wasm",
|
|
61
|
+
"./package.json": "./package.json",
|
|
62
|
+
"./*": "./*"
|
|
52
63
|
}
|
|
53
64
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-maintained TypeScript supplement for `@pdfluent/sdk-wasm`.
|
|
3
|
+
*
|
|
4
|
+
* Augments the generated `xfa_wasm.d.ts` with:
|
|
5
|
+
* - `PdfluentError` class declaration (errors thrown by all WASM methods)
|
|
6
|
+
* - `XfaWasmError` legacy alias (kept for older consumer code that imported
|
|
7
|
+
* the pre-1.0 type name)
|
|
8
|
+
* - `free()` lifecycle documentation for `PdfDoc` and `XfaEngine`
|
|
9
|
+
*
|
|
10
|
+
* Usage: import this file alongside the main module in projects that need
|
|
11
|
+
* strict error handling:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import init, { PdfDoc } from '@pdfluent/sdk-wasm';
|
|
15
|
+
* import type { PdfluentError } from '@pdfluent/sdk-wasm/pkg-types/xfa_wasm.augment';
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Or add this file to your `tsconfig.json` `types` array for global augmentation.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/* --- Typed error class ----------------------------------------------------- */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Structured error thrown by every fallible PDFluent WASM operation.
|
|
25
|
+
*
|
|
26
|
+
* `PdfluentError` is a real `class` (extends `Error`) registered on
|
|
27
|
+
* `globalThis.__PdfluentError` the first time the WASM module loads. The
|
|
28
|
+
* thrown instance is a true subclass of `Error`, so
|
|
29
|
+
* `error instanceof PdfluentError` works in user code.
|
|
30
|
+
*
|
|
31
|
+
* ## Example
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import init, { PdfDoc, PdfluentError } from '@pdfluent/sdk-wasm';
|
|
35
|
+
* await init();
|
|
36
|
+
*
|
|
37
|
+
* try {
|
|
38
|
+
* using doc = PdfDoc.open(corruptBytes);
|
|
39
|
+
* } catch (e) {
|
|
40
|
+
* if (e instanceof PdfluentError) {
|
|
41
|
+
* console.error(`[${e.code}] ${e.message} (in ${e.operation})`);
|
|
42
|
+
* if (e.code === 'E-PARSE-INVALID-PDF') {
|
|
43
|
+
* // show "not a valid PDF" UI feedback
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ## Properties
|
|
50
|
+
*
|
|
51
|
+
* | Property | Type | Description |
|
|
52
|
+
* |----------|------|-------------|
|
|
53
|
+
* | `code` | `string` | Stable C8 catalogue code, format `E-<CATEGORY>-<SPECIFIC>`. |
|
|
54
|
+
* | `message` | `string` | Human-readable description. |
|
|
55
|
+
* | `operation` | `string` | API call that failed (e.g. `"PdfDoc.open"`). |
|
|
56
|
+
* | `help` | `string` | Optional actionable hint (may be empty). |
|
|
57
|
+
* | `docsUrl` | `string` | Deep-link to documentation at `https://pdfluent.com/errors/<code>`. |
|
|
58
|
+
* | `legacyCode` | `string` | Pre-1.0 SCREAMING_SNAKE_CASE identifier, preserved for backward compatibility. |
|
|
59
|
+
*
|
|
60
|
+
* ## C8 Error codes (canonical, from `docs/error_catalogue.md`)
|
|
61
|
+
*
|
|
62
|
+
* | Code | Thrown by |
|
|
63
|
+
* |------|-----------|
|
|
64
|
+
* | `E-PARSE-INVALID-PDF` | `PdfDoc.open` — bytes are not a valid PDF |
|
|
65
|
+
* | `E-IO-GENERIC` | I/O failure |
|
|
66
|
+
* | `E-PARSE-UNSUPPORTED-VERSION` | `PdfDoc.open` — PDF version too new |
|
|
67
|
+
* | `E-COMPLIANCE-PDFA-INVALID` | `convertToPdfa`, `validatePdfA` |
|
|
68
|
+
* | `E-ENV-UNSUPPORTED-ON-WASM` | Native-only operation invoked from WASM |
|
|
69
|
+
* | `E-INTERNAL` | Internal safety-net |
|
|
70
|
+
* | `E-WASM-INVALID-ARGUMENT` | Argument validation (e.g. `validatePdfA("xyz")`) |
|
|
71
|
+
* | `E-WASM-PAGE-OUT-OF-RANGE` | Page index outside `0..page_count` |
|
|
72
|
+
* | `E-WASM-RENDER-FAILED` | `renderPage`, `renderPageToCanvas` |
|
|
73
|
+
* | `E-WASM-RENDER-FALLBACK` | Vector renderer hit unsupported feature |
|
|
74
|
+
* | `E-WASM-TEXT-EXTRACT-FAILED` | `getTextPositions` |
|
|
75
|
+
* | `E-WASM-XFA-FAILED` | `flattenXfa` |
|
|
76
|
+
* | `E-WASM-MERGE-FAILED` | `merge` |
|
|
77
|
+
* | `E-WASM-SAVE-FAILED` | Internal save / serialize |
|
|
78
|
+
* | `E-WASM-INVALID-JSON` | `fromFields`, `fromJson`, `importJson`, schema export |
|
|
79
|
+
* | `E-WASM-FORMCALC-FAILED` | `runCalculations` |
|
|
80
|
+
* | `E-SECURITY-DECRYPTION-FAILED` | `decryptPdf`, `signPdf`: wrong password, or one that does not entitle the call |
|
|
81
|
+
* | `E-WASM-SIGN-FAILED` | `signPdf` |
|
|
82
|
+
*
|
|
83
|
+
* ## Backward compatibility
|
|
84
|
+
*
|
|
85
|
+
* Before 1.0 the WASM binding threw `XfaWasmError` with a SCREAMING_SNAKE_CASE
|
|
86
|
+
* `.code` property. That identifier is preserved on the new `.legacyCode`
|
|
87
|
+
* property and on the `XfaWasmError` type alias (see below) so existing
|
|
88
|
+
* consumer code keeps working. Newly-written code should use `.code` with the
|
|
89
|
+
* `E-<CATEGORY>-<SPECIFIC>` strings.
|
|
90
|
+
*/
|
|
91
|
+
export declare class PdfluentError extends Error {
|
|
92
|
+
/** Stable C8 catalogue code in `E-<CATEGORY>-<SPECIFIC>` format. */
|
|
93
|
+
readonly code: string;
|
|
94
|
+
/** Short identifier of the API call that failed (e.g. `"PdfDoc.open"`). */
|
|
95
|
+
readonly operation: string;
|
|
96
|
+
/** Optional actionable hint for developers. May be empty string. */
|
|
97
|
+
readonly help: string;
|
|
98
|
+
/** Deep-link into the error documentation. */
|
|
99
|
+
readonly docsUrl: string;
|
|
100
|
+
/** Pre-1.0 SCREAMING_SNAKE_CASE identifier, kept for backward compatibility. */
|
|
101
|
+
readonly legacyCode: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Legacy alias for `PdfluentError`. Existing code that does
|
|
106
|
+
* `import { XfaWasmError }` keeps compiling; new code should use
|
|
107
|
+
* `PdfluentError`.
|
|
108
|
+
*
|
|
109
|
+
* @deprecated Use {@link PdfluentError}.
|
|
110
|
+
*/
|
|
111
|
+
export type XfaWasmError = PdfluentError;
|
|
112
|
+
|
|
113
|
+
/* --- Type guards ----------------------------------------------------------- */
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Type guard: returns `true` when `e` is a `PdfluentError` thrown by the WASM module.
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* try {
|
|
120
|
+
* doc.flattenXfa();
|
|
121
|
+
* } catch (e) {
|
|
122
|
+
* if (isPdfluentError(e)) {
|
|
123
|
+
* console.error(e.code, e.help);
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function isPdfluentError(e: unknown): e is PdfluentError;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Legacy alias for {@link isPdfluentError}.
|
|
132
|
+
* @deprecated Use {@link isPdfluentError}.
|
|
133
|
+
*/
|
|
134
|
+
export declare function isXfaWasmError(e: unknown): e is PdfluentError;
|
|
135
|
+
|
|
136
|
+
/* --- Lifecycle augmentation ----------------------------------------------- */
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Lifecycle contract for WASM objects that hold native memory.
|
|
140
|
+
*
|
|
141
|
+
* Both `PdfDoc` and `XfaEngine` allocate memory in the WASM heap. The JavaScript
|
|
142
|
+
* garbage collector does **not** free WASM heap memory — you must call `free()`
|
|
143
|
+
* explicitly, or use the `using` keyword (TypeScript 5.2+, requires `--target ES2022`
|
|
144
|
+
* or newer and `lib: ["ESNext.Disposable"]`).
|
|
145
|
+
*
|
|
146
|
+
* ### Option 1 — `using` (recommended, TypeScript 5.2+)
|
|
147
|
+
*
|
|
148
|
+
* ```ts
|
|
149
|
+
* {
|
|
150
|
+
* using doc = PdfDoc.open(bytes);
|
|
151
|
+
* const count = doc.pageCount();
|
|
152
|
+
* } // doc.free() called automatically here
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* ### Option 2 — explicit `free()`
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* const doc = PdfDoc.open(bytes);
|
|
159
|
+
* try {
|
|
160
|
+
* const count = doc.pageCount();
|
|
161
|
+
* } finally {
|
|
162
|
+
* doc.free();
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* ### After `free()`
|
|
167
|
+
*
|
|
168
|
+
* Once `free()` is called, the object's native pointer is invalidated. Any
|
|
169
|
+
* subsequent method call throws a `PdfluentError` with code `"E-INTERNAL"`.
|
|
170
|
+
*/
|
|
171
|
+
export interface WasmLifecycle {
|
|
172
|
+
/**
|
|
173
|
+
* Release all native WASM heap memory owned by this object.
|
|
174
|
+
*
|
|
175
|
+
* - Must be called when you are done with the object, unless you used `using`.
|
|
176
|
+
* - After calling `free()`, all methods throw.
|
|
177
|
+
* - Calling `free()` twice is safe (no-op).
|
|
178
|
+
* - Equivalent to `[Symbol.dispose]()`.
|
|
179
|
+
*/
|
|
180
|
+
free(): void;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Alias for `free()`, called automatically by the `using` statement.
|
|
184
|
+
*
|
|
185
|
+
* See {@link WasmLifecycle.free} for full lifecycle documentation.
|
|
186
|
+
*/
|
|
187
|
+
[Symbol.dispose](): void;
|
|
188
|
+
}
|