@pdfluent/sdk-wasm 1.0.0 → 1.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-COMMERCIAL +8 -0
- package/NOTICE +7 -0
- package/THIRD_PARTY_LICENSES.txt +108 -0
- package/package.json +4 -10
- package/xfa_wasm.d.ts +193 -0
- package/xfa_wasm.js +326 -2
- package/xfa_wasm_bg.wasm +0 -0
- package/xfa_wasm_bg.wasm.d.ts +8 -0
- /package/snippets/{xfa-wasm-df2db187f9a0e994 → xfa-wasm-d1985887593da269}/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/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -731,6 +731,114 @@ 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
|
+
tract — ONNX inference for the optional vision layer (#636)
|
|
736
|
+
https://github.com/sonos/tract
|
|
737
|
+
================================================================================
|
|
738
|
+
|
|
739
|
+
The `vision` cargo feature of pdf-engine (off by default; passthrough in
|
|
740
|
+
pdfluent) runs ONNX models through tract-onnx 0.23 (default-features off, so
|
|
741
|
+
without the `transformers` op-set). No trained model ships; the only ONNX
|
|
742
|
+
bytes in the tree are the 152-byte identity fixture the tests run.
|
|
743
|
+
|
|
744
|
+
Copyright (c) Mathieu Poumeyrol and the tract contributors.
|
|
745
|
+
|
|
746
|
+
Dual-licensed under MIT and Apache-2.0, at our option. The crates as resolved
|
|
747
|
+
(tract-onnx, tract-onnx-opl, tract-hir, tract-core, tract-data,
|
|
748
|
+
tract-extra, tract-nnef, tract-linalg and their transitive dependencies
|
|
749
|
+
bytes, derive-new, log, memmap2, nom, nom-language, num-integer,
|
|
750
|
+
num-rational, num-traits, prost, smallvec and the tract-*-sys/metal
|
|
751
|
+
helpers) each declare MIT OR Apache-2.0 and are covered by the texts below;
|
|
752
|
+
both are permissive and impose no copyleft obligation on the product. This
|
|
753
|
+
entry stands outside the `cargo license 2026-05-26` list above because that
|
|
754
|
+
list predates the dependency; the next regeneration absorbs these crates.
|
|
755
|
+
|
|
756
|
+
--- MIT License ---
|
|
757
|
+
|
|
758
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
759
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
760
|
+
in the Software without restriction, including without limitation the rights
|
|
761
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
762
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
763
|
+
furnished to do so, subject to the following conditions:
|
|
764
|
+
|
|
765
|
+
The above copyright notice and this permission notice shall be included in all
|
|
766
|
+
copies or substantial portions of the Software.
|
|
767
|
+
|
|
768
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
769
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
770
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
771
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
772
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
773
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
774
|
+
SOFTWARE.
|
|
775
|
+
|
|
776
|
+
--- Apache License, Version 2.0 ---
|
|
777
|
+
|
|
778
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
779
|
+
you may not use this file except in compliance with the License.
|
|
780
|
+
You may obtain a copy of the License at
|
|
781
|
+
|
|
782
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
783
|
+
|
|
784
|
+
Unless required by applicable law or agreed to in writing, software
|
|
785
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
786
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
787
|
+
See the License for the specific language governing permissions and
|
|
788
|
+
limitations under the License.
|
|
789
|
+
|
|
790
|
+
================================================================================
|
|
791
|
+
table-transformer — Table Transformer structure post-processing (MIT)
|
|
792
|
+
https://github.com/microsoft/table-transformer
|
|
793
|
+
commit 16d124f616109746b7785f03085100f1f6247575
|
|
794
|
+
================================================================================
|
|
795
|
+
|
|
796
|
+
Copyright (c) Microsoft Corporation.
|
|
797
|
+
|
|
798
|
+
What is used, in two forms:
|
|
799
|
+
|
|
800
|
+
crates/pdf-engine/src/learned/tables_tatr.rs a Rust port of the
|
|
801
|
+
publisher's row/column/header/spanning-cell reconciliation and
|
|
802
|
+
grid-cell construction (`objects_to_cells` and everything it
|
|
803
|
+
calls), behind the `ort-tables` feature of pdf-engine. Same
|
|
804
|
+
thresholds, same refinement, same cells; the parity test feeds
|
|
805
|
+
raw ONNX outputs and requires the Python-decoded cells, value
|
|
806
|
+
for value.
|
|
807
|
+
scripts/extraction/tables_b/tatr_postprocess.py the Python original,
|
|
808
|
+
`src/postprocess.py` at the commit above, vendored verbatim
|
|
809
|
+
(see the header in that file). The zero-shot eval runs TATR
|
|
810
|
+
through it rather than through a reimplementation, so a TATR
|
|
811
|
+
number is the publisher's reading of its own boxes.
|
|
812
|
+
|
|
813
|
+
MIT is permissive, no copyleft: the licence text below is that commit's
|
|
814
|
+
LICENSE, word for word. The same copyright line and text ship inside the
|
|
815
|
+
pdf-engine crate as THIRD_PARTY.md, because a crates.io reader has this
|
|
816
|
+
file's section in front of them only through the repository.
|
|
817
|
+
|
|
818
|
+
--- MIT License ---
|
|
819
|
+
|
|
820
|
+
MIT License
|
|
821
|
+
|
|
822
|
+
Copyright (c) Microsoft Corporation.
|
|
823
|
+
|
|
824
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
825
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
826
|
+
in the Software without restriction, including without limitation the rights
|
|
827
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
828
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
829
|
+
furnished to do so, subject to the following conditions:
|
|
830
|
+
|
|
831
|
+
The above copyright notice and this permission notice shall be included in all
|
|
832
|
+
copies or substantial portions of the Software.
|
|
833
|
+
|
|
834
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
835
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
836
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
837
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
838
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
839
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
840
|
+
SOFTWARE
|
|
841
|
+
|
|
734
842
|
================================================================================
|
|
735
843
|
END OF THIRD PARTY LICENSES
|
|
736
844
|
================================================================================
|
package/package.json
CHANGED
|
@@ -2,12 +2,8 @@
|
|
|
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.1.0",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE-OFFER",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/pdfluent/pdfluent-sdk"
|
|
10
|
-
},
|
|
11
7
|
"files": [
|
|
12
8
|
"xfa_wasm_bg.wasm",
|
|
13
9
|
"xfa_wasm.js",
|
|
@@ -44,10 +40,8 @@
|
|
|
44
40
|
],
|
|
45
41
|
"homepage": "https://pdfluent.com",
|
|
46
42
|
"author": "Innovation Trigger BV <team@pdfluent.com>",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/pdfluent/pdfluent-sdk"
|
|
52
46
|
}
|
|
53
47
|
}
|
package/xfa_wasm.d.ts
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/** A stamp with preset text, size, rotation, opacity and colour (red, 60pt, 45°, 25%). */
|
|
5
|
+
export type WatermarkPreset = "draft" | "confidential" | "approved" | "final" | "copy" | "notForDistribution";
|
|
6
|
+
|
|
7
|
+
/** Options for `PdfDoc.addWatermark`. Give `text`, `preset`, or both (then `text` wins). */
|
|
8
|
+
export interface WatermarkOptions {
|
|
9
|
+
text?: string;
|
|
10
|
+
preset?: WatermarkPreset;
|
|
11
|
+
/** Points. Default 48 (60 with a preset). */
|
|
12
|
+
fontSize?: number;
|
|
13
|
+
/** Degrees counter-clockwise. Default 45. */
|
|
14
|
+
rotation?: number;
|
|
15
|
+
/** 0..1. Default 0.3 (0.25 with a preset). */
|
|
16
|
+
opacity?: number;
|
|
17
|
+
/** `"#rrggbb"`. Default mid grey (red with a preset). */
|
|
18
|
+
color?: string;
|
|
19
|
+
/** `"center"` (default), or a corner / exact point in PDF points. */
|
|
20
|
+
position?: "center" | { anchor: "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "exact"; x: number; y: number };
|
|
21
|
+
/** Default `"foreground"`. */
|
|
22
|
+
layer?: "foreground" | "background";
|
|
23
|
+
/** Repeat across the page. `true` = 200pt spacing. */
|
|
24
|
+
tile?: boolean | { hSpacing?: number; vSpacing?: number };
|
|
25
|
+
/** `"all"` (default), `"even"`, `"odd"`, 0-based page indices, or an inclusive 0-based range. */
|
|
26
|
+
pages?: "all" | "even" | "odd" | number[] | { from: number; to: number };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/** An image exported faithfully. `page` is 0-based: the first page it is used on. */
|
|
32
|
+
export interface ExtractedImage {
|
|
33
|
+
page: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
mime: "image/png" | "image/jpeg";
|
|
37
|
+
data: Uint8Array;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** An image left out because it could not be exported without changing how it looks. */
|
|
41
|
+
export interface SkippedImage {
|
|
42
|
+
page: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
reason: "unsupported_filter" | "transparency" | "decode_array" | "cmyk_jpeg" | "color_space" | "bit_depth" | "image_mask" | "undecodable";
|
|
46
|
+
detail: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ImageExtraction {
|
|
50
|
+
images: ExtractedImage[];
|
|
51
|
+
skipped: SkippedImage[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/** Options for `signPdf`. The signature is a cryptographic (PAdES) signature, not a drawn one. */
|
|
57
|
+
export interface SignPdfOptions {
|
|
58
|
+
reason?: string;
|
|
59
|
+
location?: string;
|
|
60
|
+
contactInfo?: string;
|
|
61
|
+
/** Default "Signature1". */
|
|
62
|
+
fieldName?: string;
|
|
63
|
+
/** Show the signature on a page (0-based) at a rectangle in PDF points. Invisible when absent. */
|
|
64
|
+
visibleRect?: { page: number; x: number; y: number; width: number; height: number };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/** What a user who opens the file with the user password may do. Every flag defaults to `true`. */
|
|
70
|
+
export interface EncryptPermissions {
|
|
71
|
+
print?: boolean;
|
|
72
|
+
printHighQuality?: boolean;
|
|
73
|
+
modify?: boolean;
|
|
74
|
+
copy?: boolean;
|
|
75
|
+
annotate?: boolean;
|
|
76
|
+
fillForms?: boolean;
|
|
77
|
+
accessibility?: boolean;
|
|
78
|
+
assemble?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
4
83
|
/**
|
|
5
84
|
* Chroma subsampling format
|
|
6
85
|
*/
|
|
@@ -77,8 +156,16 @@ export class PdfDoc {
|
|
|
77
156
|
/**
|
|
78
157
|
* Apply a diagonal text watermark to every page.
|
|
79
158
|
* `opacity` in 0.0..=1.0. Default rotation 45 deg, default colour gray.
|
|
159
|
+
*
|
|
160
|
+
* Kept for compatibility; `addWatermark` takes the full set of options.
|
|
80
161
|
*/
|
|
81
162
|
addTextWatermark(text: string, opacity: number): Uint8Array;
|
|
163
|
+
/**
|
|
164
|
+
* Apply a text watermark with full control over text or preset, size,
|
|
165
|
+
* rotation, opacity, colour, position, layer, tiling and pages. Returns
|
|
166
|
+
* the new PDF bytes. Text only: there is no image watermark.
|
|
167
|
+
*/
|
|
168
|
+
addWatermark(options: WatermarkOptions): Uint8Array;
|
|
82
169
|
/**
|
|
83
170
|
* Re-encode all content streams with deflate compression. Removes
|
|
84
171
|
* no-op overhead. Returns the optimised PDF as a `Uint8Array`.
|
|
@@ -99,6 +186,58 @@ export class PdfDoc {
|
|
|
99
186
|
* DSS (Document Security Store) info as JSON, or null if absent.
|
|
100
187
|
*/
|
|
101
188
|
dssInfo(): string | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* The document's blocks as JSON, in reading order (#573).
|
|
191
|
+
*
|
|
192
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
193
|
+
*
|
|
194
|
+
* `{"blocks": [...]}`, one entry per paragraph, heading, list item, table
|
|
195
|
+
* cell and running head, each with its kind, page, box, text, spans and
|
|
196
|
+
* place in the reading order. `docs/STRUCTURED_EXTRACTION.md` is the key
|
|
197
|
+
* to every field.
|
|
198
|
+
*
|
|
199
|
+
* A JSON string and not a structured value, which is what every other
|
|
200
|
+
* structured reader in this binding hands back: one shape crosses the
|
|
201
|
+
* boundary, `JSON.parse` is what the caller already does for
|
|
202
|
+
* `getTextPositions` and the annotations, and a `serde` mirror of the
|
|
203
|
+
* block model would be a second definition of it to keep in step.
|
|
204
|
+
*
|
|
205
|
+
* An XFA form is read from its flattened form, for the reason
|
|
206
|
+
* `extractMarkdown` above gives.
|
|
207
|
+
*/
|
|
208
|
+
extractBlocks(first_page?: number | null, page_count?: number | null): string;
|
|
209
|
+
/**
|
|
210
|
+
* The document as a Docling `DoclingDocument`, as JSON (#629).
|
|
211
|
+
*
|
|
212
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
213
|
+
*
|
|
214
|
+
* The schema version the engine pins, which docling-core's
|
|
215
|
+
* `DoclingDocument.model_validate_json` loads as it is. `name` is
|
|
216
|
+
* `DoclingDocument.name`, which Docling fills with the file's stem;
|
|
217
|
+
* absent means `"document"`. An XFA form is read from its flattened form,
|
|
218
|
+
* for the reason `extractMarkdown` above gives.
|
|
219
|
+
*/
|
|
220
|
+
extractDocling(first_page?: number | null, page_count?: number | null, name?: string | null): string;
|
|
221
|
+
/**
|
|
222
|
+
* The document as markdown, in reading order (#573).
|
|
223
|
+
*
|
|
224
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
225
|
+
*
|
|
226
|
+
* Headings become `#` to `###`, list items `-` and `1.`, a table a pipe
|
|
227
|
+
* table or an HTML one where markdown cannot hold its shape, and a change
|
|
228
|
+
* of page an HTML comment. The running heads a document repeats are not in
|
|
229
|
+
* it; they are in `extractBlocks`.
|
|
230
|
+
*
|
|
231
|
+
* `firstPage` and `pageCount` choose a window of pages; leave both out for
|
|
232
|
+
* the whole document. The document is read whole whatever the window is,
|
|
233
|
+
* because what a block IS is decided against the rest of the document.
|
|
234
|
+
*
|
|
235
|
+
* AN XFA FORM IS READ FROM ITS FLATTENED FORM, the way `text` and
|
|
236
|
+
* `getTextPositions` read one: a dynamic XFA document draws its fields
|
|
237
|
+
* from a template rather than from page content, so the blocks of the
|
|
238
|
+
* unflattened file are the blocks of an empty page.
|
|
239
|
+
*/
|
|
240
|
+
extractMarkdown(first_page?: number | null, page_count?: number | null): string;
|
|
102
241
|
/**
|
|
103
242
|
* Extract the listed pages (0-based) into a new document.
|
|
104
243
|
* Used to implement "split" workflows in the browser.
|
|
@@ -661,6 +800,52 @@ export class XfaEngine {
|
|
|
661
800
|
static version(): string;
|
|
662
801
|
}
|
|
663
802
|
|
|
803
|
+
/**
|
|
804
|
+
* Remove the password from a PDF whose password you know, and return the
|
|
805
|
+
* unprotected bytes; open them with `PdfDoc.open`.
|
|
806
|
+
*
|
|
807
|
+
* The owner password always works. The user password works only when the
|
|
808
|
+
* file has no permission restrictions. Throws `PdfluentError` with
|
|
809
|
+
* `E-SECURITY-DECRYPTION-FAILED` for a password that does not entitle the
|
|
810
|
+
* caller, and `E-WASM-INVALID-ARGUMENT` for a PDF without a password.
|
|
811
|
+
*/
|
|
812
|
+
export function decryptPdf(bytes: Uint8Array, password: string): Uint8Array;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Encrypt a PDF with AES-256 and return the encrypted bytes.
|
|
816
|
+
*
|
|
817
|
+
* `userPassword` is needed to open the file (may be empty: then anyone can
|
|
818
|
+
* open it, and the permissions apply); `ownerPassword` lifts the permissions
|
|
819
|
+
* (empty: the user password serves as both). Refuses a PDF that is already
|
|
820
|
+
* encrypted. Throws `PdfluentError` with `E-WASM-INVALID-ARGUMENT` or
|
|
821
|
+
* `E-PARSE-INVALID-PDF`.
|
|
822
|
+
*/
|
|
823
|
+
export function encryptPdf(bytes: Uint8Array, user_password: string, owner_password: string, permissions?: EncryptPermissions | null): Uint8Array;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Extract the images of a PDF as PNG or JPEG files.
|
|
827
|
+
*
|
|
828
|
+
* Returns `{ images, skipped }`. An image that could not be exported exactly
|
|
829
|
+
* as it looks -- JPEG 2000, JBIG2 or fax compression, a transparency mask, a
|
|
830
|
+
* Decode array, CMYK, an ICC profile other than sRGB -- is listed in `skipped`
|
|
831
|
+
* with the reason, never emitted wrong. Each image is listed once, on the
|
|
832
|
+
* first page (0-based) that uses it.
|
|
833
|
+
*/
|
|
834
|
+
export function extractImages(bytes: Uint8Array): ImageExtraction;
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Sign a PDF with your own certificate (a .p12/.pfx file and its password)
|
|
838
|
+
* and return the signed bytes. The private key never leaves the page.
|
|
839
|
+
*
|
|
840
|
+
* This is a cryptographic PAdES signature (ETSI.CAdES.detached), appended as
|
|
841
|
+
* an incremental update so earlier signatures stay valid. Without a
|
|
842
|
+
* timestamp authority: no TSA or LTV in the browser. A self-signed
|
|
843
|
+
* certificate verifies, but readers such as Acrobat show its validity as
|
|
844
|
+
* unknown because they do not trust the issuer. Throws `PdfluentError` with
|
|
845
|
+
* `E-SECURITY-DECRYPTION-FAILED` for a wrong certificate password.
|
|
846
|
+
*/
|
|
847
|
+
export function signPdf(bytes: Uint8Array, pkcs12: Uint8Array, password: string, options?: SignPdfOptions | null): Uint8Array;
|
|
848
|
+
|
|
664
849
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
665
850
|
|
|
666
851
|
export interface InitOutput {
|
|
@@ -669,14 +854,21 @@ export interface InitOutput {
|
|
|
669
854
|
readonly __wbg_pdfdocmut_free: (a: number, b: number) => void;
|
|
670
855
|
readonly __wbg_texteditor_free: (a: number, b: number) => void;
|
|
671
856
|
readonly __wbg_xfaengine_free: (a: number, b: number) => void;
|
|
857
|
+
readonly decryptPdf: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
858
|
+
readonly encryptPdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
859
|
+
readonly extractImages: (a: number, b: number, c: number) => void;
|
|
672
860
|
readonly pdfdoc_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
673
861
|
readonly pdfdoc_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
674
862
|
readonly pdfdoc_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
675
863
|
readonly pdfdoc_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
864
|
+
readonly pdfdoc_addWatermark: (a: number, b: number, c: number) => void;
|
|
676
865
|
readonly pdfdoc_compress: (a: number, b: number) => void;
|
|
677
866
|
readonly pdfdoc_convertToPdfa: (a: number, b: number, c: number, d: number) => void;
|
|
678
867
|
readonly pdfdoc_deletePages: (a: number, b: number, c: number, d: number) => void;
|
|
679
868
|
readonly pdfdoc_dssInfo: (a: number, b: number) => void;
|
|
869
|
+
readonly pdfdoc_extractBlocks: (a: number, b: number, c: number, d: number) => void;
|
|
870
|
+
readonly pdfdoc_extractDocling: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
871
|
+
readonly pdfdoc_extractMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
680
872
|
readonly pdfdoc_extractPages: (a: number, b: number, c: number, d: number) => void;
|
|
681
873
|
readonly pdfdoc_flattenXfa: (a: number, b: number) => void;
|
|
682
874
|
readonly pdfdoc_getAnnotations: (a: number, b: number, c: number) => void;
|
|
@@ -728,6 +920,7 @@ export interface InitOutput {
|
|
|
728
920
|
readonly pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
729
921
|
readonly pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
730
922
|
readonly pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
923
|
+
readonly signPdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
731
924
|
readonly texteditor_findText: (a: number, b: number, c: number, d: number) => void;
|
|
732
925
|
readonly texteditor_open: (a: number, b: number, c: number) => void;
|
|
733
926
|
readonly texteditor_pageCount: (a: number) => number;
|
package/xfa_wasm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./xfa_wasm.d.ts" */
|
|
2
|
-
import { __pdfluent_error_ctor } from './snippets/xfa-wasm-
|
|
2
|
+
import { __pdfluent_error_ctor } from './snippets/xfa-wasm-d1985887593da269/inline0.js';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -168,6 +168,8 @@ export class PdfDoc {
|
|
|
168
168
|
/**
|
|
169
169
|
* Apply a diagonal text watermark to every page.
|
|
170
170
|
* `opacity` in 0.0..=1.0. Default rotation 45 deg, default colour gray.
|
|
171
|
+
*
|
|
172
|
+
* Kept for compatibility; `addWatermark` takes the full set of options.
|
|
171
173
|
* @param {string} text
|
|
172
174
|
* @param {number} opacity
|
|
173
175
|
* @returns {Uint8Array}
|
|
@@ -192,6 +194,31 @@ export class PdfDoc {
|
|
|
192
194
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
193
195
|
}
|
|
194
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Apply a text watermark with full control over text or preset, size,
|
|
199
|
+
* rotation, opacity, colour, position, layer, tiling and pages. Returns
|
|
200
|
+
* the new PDF bytes. Text only: there is no image watermark.
|
|
201
|
+
* @param {WatermarkOptions} options
|
|
202
|
+
* @returns {Uint8Array}
|
|
203
|
+
*/
|
|
204
|
+
addWatermark(options) {
|
|
205
|
+
try {
|
|
206
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
207
|
+
wasm.pdfdoc_addWatermark(retptr, this.__wbg_ptr, addHeapObject(options));
|
|
208
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
209
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
210
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
211
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
212
|
+
if (r3) {
|
|
213
|
+
throw takeObject(r2);
|
|
214
|
+
}
|
|
215
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
216
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
217
|
+
return v1;
|
|
218
|
+
} finally {
|
|
219
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
195
222
|
/**
|
|
196
223
|
* Re-encode all content streams with deflate compression. Removes
|
|
197
224
|
* no-op overhead. Returns the optimised PDF as a `Uint8Array`.
|
|
@@ -288,6 +315,139 @@ export class PdfDoc {
|
|
|
288
315
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
289
316
|
}
|
|
290
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* The document's blocks as JSON, in reading order (#573).
|
|
320
|
+
*
|
|
321
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
322
|
+
*
|
|
323
|
+
* `{"blocks": [...]}`, one entry per paragraph, heading, list item, table
|
|
324
|
+
* cell and running head, each with its kind, page, box, text, spans and
|
|
325
|
+
* place in the reading order. `docs/STRUCTURED_EXTRACTION.md` is the key
|
|
326
|
+
* to every field.
|
|
327
|
+
*
|
|
328
|
+
* A JSON string and not a structured value, which is what every other
|
|
329
|
+
* structured reader in this binding hands back: one shape crosses the
|
|
330
|
+
* boundary, `JSON.parse` is what the caller already does for
|
|
331
|
+
* `getTextPositions` and the annotations, and a `serde` mirror of the
|
|
332
|
+
* block model would be a second definition of it to keep in step.
|
|
333
|
+
*
|
|
334
|
+
* An XFA form is read from its flattened form, for the reason
|
|
335
|
+
* `extractMarkdown` above gives.
|
|
336
|
+
* @param {number | null} [first_page]
|
|
337
|
+
* @param {number | null} [page_count]
|
|
338
|
+
* @returns {string}
|
|
339
|
+
*/
|
|
340
|
+
extractBlocks(first_page, page_count) {
|
|
341
|
+
let deferred2_0;
|
|
342
|
+
let deferred2_1;
|
|
343
|
+
try {
|
|
344
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
345
|
+
wasm.pdfdoc_extractBlocks(retptr, this.__wbg_ptr, isLikeNone(first_page) ? Number.MAX_SAFE_INTEGER : (first_page) >>> 0, isLikeNone(page_count) ? Number.MAX_SAFE_INTEGER : (page_count) >>> 0);
|
|
346
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
347
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
348
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
349
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
350
|
+
var ptr1 = r0;
|
|
351
|
+
var len1 = r1;
|
|
352
|
+
if (r3) {
|
|
353
|
+
ptr1 = 0; len1 = 0;
|
|
354
|
+
throw takeObject(r2);
|
|
355
|
+
}
|
|
356
|
+
deferred2_0 = ptr1;
|
|
357
|
+
deferred2_1 = len1;
|
|
358
|
+
return getStringFromWasm0(ptr1, len1);
|
|
359
|
+
} finally {
|
|
360
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
361
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The document as a Docling `DoclingDocument`, as JSON (#629).
|
|
366
|
+
*
|
|
367
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
368
|
+
*
|
|
369
|
+
* The schema version the engine pins, which docling-core's
|
|
370
|
+
* `DoclingDocument.model_validate_json` loads as it is. `name` is
|
|
371
|
+
* `DoclingDocument.name`, which Docling fills with the file's stem;
|
|
372
|
+
* absent means `"document"`. An XFA form is read from its flattened form,
|
|
373
|
+
* for the reason `extractMarkdown` above gives.
|
|
374
|
+
* @param {number | null} [first_page]
|
|
375
|
+
* @param {number | null} [page_count]
|
|
376
|
+
* @param {string | null} [name]
|
|
377
|
+
* @returns {string}
|
|
378
|
+
*/
|
|
379
|
+
extractDocling(first_page, page_count, name) {
|
|
380
|
+
let deferred3_0;
|
|
381
|
+
let deferred3_1;
|
|
382
|
+
try {
|
|
383
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
384
|
+
var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
385
|
+
var len0 = WASM_VECTOR_LEN;
|
|
386
|
+
wasm.pdfdoc_extractDocling(retptr, this.__wbg_ptr, isLikeNone(first_page) ? Number.MAX_SAFE_INTEGER : (first_page) >>> 0, isLikeNone(page_count) ? Number.MAX_SAFE_INTEGER : (page_count) >>> 0, ptr0, len0);
|
|
387
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
388
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
389
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
390
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
391
|
+
var ptr2 = r0;
|
|
392
|
+
var len2 = r1;
|
|
393
|
+
if (r3) {
|
|
394
|
+
ptr2 = 0; len2 = 0;
|
|
395
|
+
throw takeObject(r2);
|
|
396
|
+
}
|
|
397
|
+
deferred3_0 = ptr2;
|
|
398
|
+
deferred3_1 = len2;
|
|
399
|
+
return getStringFromWasm0(ptr2, len2);
|
|
400
|
+
} finally {
|
|
401
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
402
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The document as markdown, in reading order (#573).
|
|
407
|
+
*
|
|
408
|
+
* Preview: output quality is still improving and the API may change in a minor release.
|
|
409
|
+
*
|
|
410
|
+
* Headings become `#` to `###`, list items `-` and `1.`, a table a pipe
|
|
411
|
+
* table or an HTML one where markdown cannot hold its shape, and a change
|
|
412
|
+
* of page an HTML comment. The running heads a document repeats are not in
|
|
413
|
+
* it; they are in `extractBlocks`.
|
|
414
|
+
*
|
|
415
|
+
* `firstPage` and `pageCount` choose a window of pages; leave both out for
|
|
416
|
+
* the whole document. The document is read whole whatever the window is,
|
|
417
|
+
* because what a block IS is decided against the rest of the document.
|
|
418
|
+
*
|
|
419
|
+
* AN XFA FORM IS READ FROM ITS FLATTENED FORM, the way `text` and
|
|
420
|
+
* `getTextPositions` read one: a dynamic XFA document draws its fields
|
|
421
|
+
* from a template rather than from page content, so the blocks of the
|
|
422
|
+
* unflattened file are the blocks of an empty page.
|
|
423
|
+
* @param {number | null} [first_page]
|
|
424
|
+
* @param {number | null} [page_count]
|
|
425
|
+
* @returns {string}
|
|
426
|
+
*/
|
|
427
|
+
extractMarkdown(first_page, page_count) {
|
|
428
|
+
let deferred2_0;
|
|
429
|
+
let deferred2_1;
|
|
430
|
+
try {
|
|
431
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
432
|
+
wasm.pdfdoc_extractMarkdown(retptr, this.__wbg_ptr, isLikeNone(first_page) ? Number.MAX_SAFE_INTEGER : (first_page) >>> 0, isLikeNone(page_count) ? Number.MAX_SAFE_INTEGER : (page_count) >>> 0);
|
|
433
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
434
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
435
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
436
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
437
|
+
var ptr1 = r0;
|
|
438
|
+
var len1 = r1;
|
|
439
|
+
if (r3) {
|
|
440
|
+
ptr1 = 0; len1 = 0;
|
|
441
|
+
throw takeObject(r2);
|
|
442
|
+
}
|
|
443
|
+
deferred2_0 = ptr1;
|
|
444
|
+
deferred2_1 = len1;
|
|
445
|
+
return getStringFromWasm0(ptr1, len1);
|
|
446
|
+
} finally {
|
|
447
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
448
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
291
451
|
/**
|
|
292
452
|
* Extract the listed pages (0-based) into a new document.
|
|
293
453
|
* Used to implement "split" workflows in the browser.
|
|
@@ -2109,10 +2269,154 @@ export class XfaEngine {
|
|
|
2109
2269
|
}
|
|
2110
2270
|
}
|
|
2111
2271
|
if (Symbol.dispose) XfaEngine.prototype[Symbol.dispose] = XfaEngine.prototype.free;
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Remove the password from a PDF whose password you know, and return the
|
|
2275
|
+
* unprotected bytes; open them with `PdfDoc.open`.
|
|
2276
|
+
*
|
|
2277
|
+
* The owner password always works. The user password works only when the
|
|
2278
|
+
* file has no permission restrictions. Throws `PdfluentError` with
|
|
2279
|
+
* `E-SECURITY-DECRYPTION-FAILED` for a password that does not entitle the
|
|
2280
|
+
* caller, and `E-WASM-INVALID-ARGUMENT` for a PDF without a password.
|
|
2281
|
+
* @param {Uint8Array} bytes
|
|
2282
|
+
* @param {string} password
|
|
2283
|
+
* @returns {Uint8Array}
|
|
2284
|
+
*/
|
|
2285
|
+
export function decryptPdf(bytes, password) {
|
|
2286
|
+
try {
|
|
2287
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2288
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
2289
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2290
|
+
const ptr1 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2291
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2292
|
+
wasm.decryptPdf(retptr, ptr0, len0, ptr1, len1);
|
|
2293
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2294
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2295
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2296
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2297
|
+
if (r3) {
|
|
2298
|
+
throw takeObject(r2);
|
|
2299
|
+
}
|
|
2300
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2301
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
2302
|
+
return v3;
|
|
2303
|
+
} finally {
|
|
2304
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
/**
|
|
2309
|
+
* Encrypt a PDF with AES-256 and return the encrypted bytes.
|
|
2310
|
+
*
|
|
2311
|
+
* `userPassword` is needed to open the file (may be empty: then anyone can
|
|
2312
|
+
* open it, and the permissions apply); `ownerPassword` lifts the permissions
|
|
2313
|
+
* (empty: the user password serves as both). Refuses a PDF that is already
|
|
2314
|
+
* encrypted. Throws `PdfluentError` with `E-WASM-INVALID-ARGUMENT` or
|
|
2315
|
+
* `E-PARSE-INVALID-PDF`.
|
|
2316
|
+
* @param {Uint8Array} bytes
|
|
2317
|
+
* @param {string} user_password
|
|
2318
|
+
* @param {string} owner_password
|
|
2319
|
+
* @param {EncryptPermissions | null} [permissions]
|
|
2320
|
+
* @returns {Uint8Array}
|
|
2321
|
+
*/
|
|
2322
|
+
export function encryptPdf(bytes, user_password, owner_password, permissions) {
|
|
2323
|
+
try {
|
|
2324
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2325
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
2326
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2327
|
+
const ptr1 = passStringToWasm0(user_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2328
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2329
|
+
const ptr2 = passStringToWasm0(owner_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2330
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2331
|
+
wasm.encryptPdf(retptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(permissions) ? 0 : addHeapObject(permissions));
|
|
2332
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2333
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2334
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2335
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2336
|
+
if (r3) {
|
|
2337
|
+
throw takeObject(r2);
|
|
2338
|
+
}
|
|
2339
|
+
var v4 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2340
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
2341
|
+
return v4;
|
|
2342
|
+
} finally {
|
|
2343
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* Extract the images of a PDF as PNG or JPEG files.
|
|
2349
|
+
*
|
|
2350
|
+
* Returns `{ images, skipped }`. An image that could not be exported exactly
|
|
2351
|
+
* as it looks -- JPEG 2000, JBIG2 or fax compression, a transparency mask, a
|
|
2352
|
+
* Decode array, CMYK, an ICC profile other than sRGB -- is listed in `skipped`
|
|
2353
|
+
* with the reason, never emitted wrong. Each image is listed once, on the
|
|
2354
|
+
* first page (0-based) that uses it.
|
|
2355
|
+
* @param {Uint8Array} bytes
|
|
2356
|
+
* @returns {ImageExtraction}
|
|
2357
|
+
*/
|
|
2358
|
+
export function extractImages(bytes) {
|
|
2359
|
+
try {
|
|
2360
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2361
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
2362
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2363
|
+
wasm.extractImages(retptr, ptr0, len0);
|
|
2364
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2365
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2366
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2367
|
+
if (r2) {
|
|
2368
|
+
throw takeObject(r1);
|
|
2369
|
+
}
|
|
2370
|
+
return takeObject(r0);
|
|
2371
|
+
} finally {
|
|
2372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
/**
|
|
2377
|
+
* Sign a PDF with your own certificate (a .p12/.pfx file and its password)
|
|
2378
|
+
* and return the signed bytes. The private key never leaves the page.
|
|
2379
|
+
*
|
|
2380
|
+
* This is a cryptographic PAdES signature (ETSI.CAdES.detached), appended as
|
|
2381
|
+
* an incremental update so earlier signatures stay valid. Without a
|
|
2382
|
+
* timestamp authority: no TSA or LTV in the browser. A self-signed
|
|
2383
|
+
* certificate verifies, but readers such as Acrobat show its validity as
|
|
2384
|
+
* unknown because they do not trust the issuer. Throws `PdfluentError` with
|
|
2385
|
+
* `E-SECURITY-DECRYPTION-FAILED` for a wrong certificate password.
|
|
2386
|
+
* @param {Uint8Array} bytes
|
|
2387
|
+
* @param {Uint8Array} pkcs12
|
|
2388
|
+
* @param {string} password
|
|
2389
|
+
* @param {SignPdfOptions | null} [options]
|
|
2390
|
+
* @returns {Uint8Array}
|
|
2391
|
+
*/
|
|
2392
|
+
export function signPdf(bytes, pkcs12, password, options) {
|
|
2393
|
+
try {
|
|
2394
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2395
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
2396
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2397
|
+
const ptr1 = passArray8ToWasm0(pkcs12, wasm.__wbindgen_export);
|
|
2398
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2399
|
+
const ptr2 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2400
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2401
|
+
wasm.signPdf(retptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(options) ? 0 : addHeapObject(options));
|
|
2402
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2403
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2404
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2405
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2406
|
+
if (r3) {
|
|
2407
|
+
throw takeObject(r2);
|
|
2408
|
+
}
|
|
2409
|
+
var v4 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2410
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
2411
|
+
return v4;
|
|
2412
|
+
} finally {
|
|
2413
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2112
2416
|
function __wbg_get_imports() {
|
|
2113
2417
|
const import0 = {
|
|
2114
2418
|
__proto__: null,
|
|
2115
|
-
|
|
2419
|
+
__wbg___pdfluent_error_ctor_17e86bb485874967: function() {
|
|
2116
2420
|
const ret = __pdfluent_error_ctor();
|
|
2117
2421
|
return addHeapObject(ret);
|
|
2118
2422
|
},
|
|
@@ -2127,6 +2431,14 @@ function __wbg_get_imports() {
|
|
|
2127
2431
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
2128
2432
|
return ret;
|
|
2129
2433
|
},
|
|
2434
|
+
__wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {
|
|
2435
|
+
const ret = getObject(arg0) === null;
|
|
2436
|
+
return ret;
|
|
2437
|
+
},
|
|
2438
|
+
__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
|
|
2439
|
+
const ret = getObject(arg0) === undefined;
|
|
2440
|
+
return ret;
|
|
2441
|
+
},
|
|
2130
2442
|
__wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
|
|
2131
2443
|
const obj = getObject(arg1);
|
|
2132
2444
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -2192,6 +2504,10 @@ function __wbg_get_imports() {
|
|
|
2192
2504
|
__wbg_moveTo_11bf5a977e6b8610: function(arg0, arg1, arg2) {
|
|
2193
2505
|
getObject(arg0).moveTo(arg1, arg2);
|
|
2194
2506
|
},
|
|
2507
|
+
__wbg_new_02d162bc6cf02f60: function() {
|
|
2508
|
+
const ret = new Object();
|
|
2509
|
+
return addHeapObject(ret);
|
|
2510
|
+
},
|
|
2195
2511
|
__wbg_new_1f236d63ba0c4784: function(arg0, arg1) {
|
|
2196
2512
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
2197
2513
|
return addHeapObject(ret);
|
|
@@ -2200,6 +2516,10 @@ function __wbg_get_imports() {
|
|
|
2200
2516
|
const ret = new Array();
|
|
2201
2517
|
return addHeapObject(ret);
|
|
2202
2518
|
},
|
|
2519
|
+
__wbg_new_from_slice_269e35316ed2d061: function(arg0, arg1) {
|
|
2520
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
2521
|
+
return addHeapObject(ret);
|
|
2522
|
+
},
|
|
2203
2523
|
__wbg_new_with_u8_clamped_array_and_sh_13504c3c5394c7c9: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
2204
2524
|
const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
|
|
2205
2525
|
return addHeapObject(ret);
|
|
@@ -2273,6 +2593,10 @@ function __wbg_get_imports() {
|
|
|
2273
2593
|
__wbg_set_width_25112eb6bf1148df: function(arg0, arg1) {
|
|
2274
2594
|
getObject(arg0).width = arg1 >>> 0;
|
|
2275
2595
|
},
|
|
2596
|
+
__wbg_stringify_ef0c105b1ccc3849: function() { return handleError(function (arg0) {
|
|
2597
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
2598
|
+
return addHeapObject(ret);
|
|
2599
|
+
}, arguments); },
|
|
2276
2600
|
__wbg_strokeRect_3430a0df4158ba67: function(arg0, arg1, arg2, arg3, arg4) {
|
|
2277
2601
|
getObject(arg0).strokeRect(arg1, arg2, arg3, arg4);
|
|
2278
2602
|
},
|
package/xfa_wasm_bg.wasm
CHANGED
|
Binary file
|
package/xfa_wasm_bg.wasm.d.ts
CHANGED
|
@@ -5,14 +5,21 @@ export const __wbg_pdfdoc_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_pdfdocmut_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_texteditor_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_xfaengine_free: (a: number, b: number) => void;
|
|
8
|
+
export const decryptPdf: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
9
|
+
export const encryptPdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
10
|
+
export const extractImages: (a: number, b: number, c: number) => void;
|
|
8
11
|
export const pdfdoc_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
9
12
|
export const pdfdoc_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
10
13
|
export const pdfdoc_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
11
14
|
export const pdfdoc_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
|
+
export const pdfdoc_addWatermark: (a: number, b: number, c: number) => void;
|
|
12
16
|
export const pdfdoc_compress: (a: number, b: number) => void;
|
|
13
17
|
export const pdfdoc_convertToPdfa: (a: number, b: number, c: number, d: number) => void;
|
|
14
18
|
export const pdfdoc_deletePages: (a: number, b: number, c: number, d: number) => void;
|
|
15
19
|
export const pdfdoc_dssInfo: (a: number, b: number) => void;
|
|
20
|
+
export const pdfdoc_extractBlocks: (a: number, b: number, c: number, d: number) => void;
|
|
21
|
+
export const pdfdoc_extractDocling: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
22
|
+
export const pdfdoc_extractMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
16
23
|
export const pdfdoc_extractPages: (a: number, b: number, c: number, d: number) => void;
|
|
17
24
|
export const pdfdoc_flattenXfa: (a: number, b: number) => void;
|
|
18
25
|
export const pdfdoc_getAnnotations: (a: number, b: number, c: number) => void;
|
|
@@ -64,6 +71,7 @@ export const pdfdocmut_setFormField: (a: number, b: number, c: number, d: number
|
|
|
64
71
|
export const pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
65
72
|
export const pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
66
73
|
export const pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
74
|
+
export const signPdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
67
75
|
export const texteditor_findText: (a: number, b: number, c: number, d: number) => void;
|
|
68
76
|
export const texteditor_open: (a: number, b: number, c: number) => void;
|
|
69
77
|
export const texteditor_pageCount: (a: number) => number;
|
|
File without changes
|