@pdfluent/sdk-wasm 1.0.0-beta.8 → 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 +661 -242
- package/LICENSE-COMMERCIAL +220 -0
- package/LICENSE-OFFER +45 -0
- package/NOTICE +150 -0
- package/README.md +32 -56
- package/THIRD_PARTY_LICENSES.txt +844 -0
- package/package.json +20 -5
- package/xfa_wasm.d.ts +324 -42
- package/xfa_wasm.js +691 -104
- package/xfa_wasm_bg.wasm +0 -0
- package/xfa_wasm_bg.wasm.d.ts +20 -6
- /package/snippets/{xfa-wasm-312742e1abcfad9e → xfa-wasm-d1985887593da269}/inline0.js +0 -0
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfluent/sdk-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"description": "PDFluent browser SDK —
|
|
5
|
-
"version": "1.
|
|
6
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
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.1.0",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE-OFFER",
|
|
7
7
|
"files": [
|
|
8
8
|
"xfa_wasm_bg.wasm",
|
|
9
9
|
"xfa_wasm.js",
|
|
10
10
|
"xfa_wasm.d.ts",
|
|
11
11
|
"snippets",
|
|
12
|
-
"xfa_wasm_bg.wasm.d.ts"
|
|
12
|
+
"xfa_wasm_bg.wasm.d.ts",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"LICENSE-COMMERCIAL",
|
|
15
|
+
"LICENSE-OFFER",
|
|
16
|
+
"NOTICE",
|
|
17
|
+
"THIRD_PARTY_LICENSES.txt"
|
|
13
18
|
],
|
|
14
19
|
"main": "xfa_wasm.js",
|
|
15
20
|
"types": "xfa_wasm.d.ts",
|
|
@@ -22,11 +27,21 @@
|
|
|
22
27
|
"pdfluent",
|
|
23
28
|
"browser",
|
|
24
29
|
"sdk",
|
|
30
|
+
"pdf-text-replace",
|
|
31
|
+
"find-and-replace",
|
|
32
|
+
"edit-pdf-text",
|
|
33
|
+
"pdf-editor",
|
|
25
34
|
"xfa",
|
|
35
|
+
"acroform",
|
|
36
|
+
"pades",
|
|
26
37
|
"forms",
|
|
27
38
|
"annotate",
|
|
28
39
|
"redact"
|
|
29
40
|
],
|
|
30
41
|
"homepage": "https://pdfluent.com",
|
|
31
|
-
"author": "Innovation Trigger BV <team@pdfluent.com>"
|
|
42
|
+
"author": "Innovation Trigger BV <team@pdfluent.com>",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/pdfluent/pdfluent-sdk"
|
|
46
|
+
}
|
|
32
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
|
*/
|
|
@@ -23,27 +102,6 @@ export enum ChromaSampling {
|
|
|
23
102
|
Cs400 = 3,
|
|
24
103
|
}
|
|
25
104
|
|
|
26
|
-
/**
|
|
27
|
-
* Status of the currently-active license.
|
|
28
|
-
*/
|
|
29
|
-
export class LicenseStatus {
|
|
30
|
-
private constructor();
|
|
31
|
-
free(): void;
|
|
32
|
-
[Symbol.dispose](): void;
|
|
33
|
-
/**
|
|
34
|
-
* Whether output is marked via `/Producer` metadata (Trial tier).
|
|
35
|
-
*/
|
|
36
|
-
readonly outputIsMarked: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Source: `"Default" | "EnvVar" | "Explicit"`.
|
|
39
|
-
*/
|
|
40
|
-
readonly source: string;
|
|
41
|
-
/**
|
|
42
|
-
* Tier name: `"Trial" | "Developer" | "Team" | "Business" | "Enterprise"`.
|
|
43
|
-
*/
|
|
44
|
-
readonly tier: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
105
|
/**
|
|
48
106
|
* PDF document handle for analysis and text extraction.
|
|
49
107
|
*
|
|
@@ -98,8 +156,16 @@ export class PdfDoc {
|
|
|
98
156
|
/**
|
|
99
157
|
* Apply a diagonal text watermark to every page.
|
|
100
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.
|
|
101
161
|
*/
|
|
102
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;
|
|
103
169
|
/**
|
|
104
170
|
* Re-encode all content streams with deflate compression. Removes
|
|
105
171
|
* no-op overhead. Returns the optimised PDF as a `Uint8Array`.
|
|
@@ -120,6 +186,58 @@ export class PdfDoc {
|
|
|
120
186
|
* DSS (Document Security Store) info as JSON, or null if absent.
|
|
121
187
|
*/
|
|
122
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;
|
|
123
241
|
/**
|
|
124
242
|
* Extract the listed pages (0-based) into a new document.
|
|
125
243
|
* Used to implement "split" workflows in the browser.
|
|
@@ -214,6 +332,22 @@ export class PdfDoc {
|
|
|
214
332
|
* is permanently removed from every page.
|
|
215
333
|
*/
|
|
216
334
|
redactSearch(query: string): Uint8Array;
|
|
335
|
+
/**
|
|
336
|
+
* Replace this document's content with new bytes in-place.
|
|
337
|
+
*
|
|
338
|
+
* Call this after [`PdfDocMut.save`] to update the render handle with
|
|
339
|
+
* the mutated PDF bytes so that subsequent [`renderPage`] calls reflect
|
|
340
|
+
* the changes, without needing to create a new `PdfDoc` object.
|
|
341
|
+
*
|
|
342
|
+
* ```js
|
|
343
|
+
* const handle = PdfDocMut.open(bytes);
|
|
344
|
+
* handle.replaceTextSpan(1, "old", "new");
|
|
345
|
+
* const newBytes = handle.save();
|
|
346
|
+
* doc.refresh(newBytes); // engine now renders the edited content
|
|
347
|
+
* doc.renderPage(0, 1.5); // ← shows "new" instead of "old"
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
refresh(data: Uint8Array): void;
|
|
217
351
|
/**
|
|
218
352
|
* Render a page to RGBA pixels.
|
|
219
353
|
*
|
|
@@ -266,11 +400,18 @@ export class PdfDoc {
|
|
|
266
400
|
*/
|
|
267
401
|
rotatePage(page_index: number, degrees: number): Uint8Array;
|
|
268
402
|
/**
|
|
269
|
-
* Set a single AcroForm text
|
|
403
|
+
* Set a single AcroForm **text** field value. Returns the new PDF bytes.
|
|
404
|
+
*
|
|
405
|
+
* Updates `/V` (ASCII literal or UTF-16BE+BOM), per-widget `/AS`, and
|
|
406
|
+
* regenerates the `/AP` appearance stream so the fill is visible without
|
|
407
|
+
* `/NeedAppearances` processing. Read-only fields throw.
|
|
408
|
+
*
|
|
409
|
+
* **Text fields only.** For checkbox, radio, and choice fields use
|
|
410
|
+
* `PdfDocMut.setFormField`, which runs the full type-aware dispatch.
|
|
270
411
|
*/
|
|
271
412
|
setFormField(path: string, value: string): Uint8Array;
|
|
272
413
|
/**
|
|
273
|
-
* Bulk-set multiple AcroForm text fields from a JSON object
|
|
414
|
+
* Bulk-set multiple AcroForm **text** fields from a JSON object
|
|
274
415
|
* `{"field.path": "value", ...}`. Returns the new PDF bytes.
|
|
275
416
|
*/
|
|
276
417
|
setFormFields(fields_json: string): Uint8Array;
|
|
@@ -285,6 +426,25 @@ export class PdfDoc {
|
|
|
285
426
|
* extraction fails.
|
|
286
427
|
*/
|
|
287
428
|
text(page_index: number): string;
|
|
429
|
+
/**
|
|
430
|
+
* Convert this PDF to a Word `.docx` package.
|
|
431
|
+
*
|
|
432
|
+
* Returns the package as a `Uint8Array`.
|
|
433
|
+
*
|
|
434
|
+
* The browser SDK could not do this until 23-08-2026: the conversion
|
|
435
|
+
* crates were excluded from wasm32 by a comment that applied to the
|
|
436
|
+
* renderer, not to them.
|
|
437
|
+
*/
|
|
438
|
+
toDocx(): Uint8Array;
|
|
439
|
+
/**
|
|
440
|
+
* Convert this PDF to a PowerPoint `.pptx` deck, one slide per page.
|
|
441
|
+
* See [`Self::to_docx`].
|
|
442
|
+
*/
|
|
443
|
+
toPptx(): Uint8Array;
|
|
444
|
+
/**
|
|
445
|
+
* Convert this PDF to an Excel `.xlsx` workbook. See [`Self::to_docx`].
|
|
446
|
+
*/
|
|
447
|
+
toXlsx(): Uint8Array;
|
|
288
448
|
/**
|
|
289
449
|
* Validate against a PDF/A level. Returns compliance report as JSON.
|
|
290
450
|
*/
|
|
@@ -449,26 +609,101 @@ export class PdfDocMut {
|
|
|
449
609
|
*/
|
|
450
610
|
save(): Uint8Array;
|
|
451
611
|
/**
|
|
452
|
-
* Set a single AcroForm
|
|
612
|
+
* Set a single AcroForm field value (text, checkbox, radio, or choice).
|
|
453
613
|
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* recursion) — same constraint as the Rust core.
|
|
614
|
+
* Delegates to [`pdf_forms::apply_field_value`] — the single SDK
|
|
615
|
+
* writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
|
|
616
|
+
* per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
|
|
617
|
+
* fully-qualified names through `/Kids`, and rejects read-only fields.
|
|
459
618
|
*/
|
|
460
619
|
setFormField(path: string, value: string): void;
|
|
461
620
|
/**
|
|
462
|
-
* Bulk-set multiple AcroForm
|
|
621
|
+
* Bulk-set multiple AcroForm fields from a JSON object
|
|
463
622
|
* `{"field.path": "value", ...}`.
|
|
464
623
|
*/
|
|
465
624
|
setFormFields(fields_json: string): void;
|
|
625
|
+
/**
|
|
626
|
+
* Select multiple options on a multi-select list box.
|
|
627
|
+
*
|
|
628
|
+
* Delegates to [`pdf_forms::apply_choice_multi`]: writes `/V` as an array
|
|
629
|
+
* of text strings and rebuilds `/I` (the sorted selected-index cache) to
|
|
630
|
+
* match what Adobe Acrobat produces. `values` is a JS array of strings;
|
|
631
|
+
* pass an empty array to clear the selection. The field must be a
|
|
632
|
+
* multi-select list box (`/Ff` MultiSelect flag); for non-editable list
|
|
633
|
+
* boxes every value must be one of the field's `/Opt` options.
|
|
634
|
+
*/
|
|
635
|
+
setMultiSelect(path: string, values: string[]): void;
|
|
466
636
|
/**
|
|
467
637
|
* Apply bold/italic style to a text run on `page_num` (1-based).
|
|
468
638
|
*/
|
|
469
639
|
setTextRunStyle(page_num: number, runs_json: string, run_index: number, bold?: boolean | null, italic?: boolean | null): string;
|
|
470
640
|
}
|
|
471
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Find-and-replace editor over a PDF document (SDK surface).
|
|
644
|
+
*/
|
|
645
|
+
export class TextEditor {
|
|
646
|
+
private constructor();
|
|
647
|
+
free(): void;
|
|
648
|
+
[Symbol.dispose](): void;
|
|
649
|
+
/**
|
|
650
|
+
* Find text occurrences. `query_json` is a JSON object:
|
|
651
|
+
*
|
|
652
|
+
* ```json
|
|
653
|
+
* {
|
|
654
|
+
* "text": "Acme B.V.", // required
|
|
655
|
+
* "caseInsensitive": false, // optional
|
|
656
|
+
* "pages": [1, 5], // optional inclusive 1-based range
|
|
657
|
+
* "region": { // optional
|
|
658
|
+
* "page": 1,
|
|
659
|
+
* "rect": [x0, y0, x1, y1],
|
|
660
|
+
* "relation": "intersects" // or "contained"
|
|
661
|
+
* },
|
|
662
|
+
* "limit": 100 // optional
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*
|
|
666
|
+
* Returns a JSON array of matches; each match carries an opaque `id`
|
|
667
|
+
* token valid until the next applied edit on this document.
|
|
668
|
+
*/
|
|
669
|
+
findText(query_json: string): string;
|
|
670
|
+
/**
|
|
671
|
+
* Open a PDF from raw bytes.
|
|
672
|
+
*/
|
|
673
|
+
static open(data: Uint8Array): TextEditor;
|
|
674
|
+
/**
|
|
675
|
+
* Number of pages.
|
|
676
|
+
*/
|
|
677
|
+
pageCount(): number;
|
|
678
|
+
/**
|
|
679
|
+
* Apply per-match replacements located earlier with `findText`.
|
|
680
|
+
*
|
|
681
|
+
* `edits_json` is a JSON array of `{"id": "<match token>", "text":
|
|
682
|
+
* "<replacement>"}`. All edits commit in one atomic transaction under
|
|
683
|
+
* `options_json` (see [`TextEditor::replace_text`]); the default is
|
|
684
|
+
* all-or-nothing. Returns the JSON replacement report.
|
|
685
|
+
*/
|
|
686
|
+
replaceMatches(edits_json: string, options_json: string): string;
|
|
687
|
+
/**
|
|
688
|
+
* Find and replace in one call. Returns the JSON replacement report.
|
|
689
|
+
*
|
|
690
|
+
* `options_json` may be empty/`"{}"` for defaults, or:
|
|
691
|
+
*
|
|
692
|
+
* ```json
|
|
693
|
+
* {
|
|
694
|
+
* "fontFallback": "deny" | "injectStandard" | {"explicit": "F1"},
|
|
695
|
+
* "signaturePolicy": "reject" | "allowPostSignatureChange",
|
|
696
|
+
* "commitPolicy": "allOrNothing" | "bestEffort"
|
|
697
|
+
* }
|
|
698
|
+
* ```
|
|
699
|
+
*/
|
|
700
|
+
replaceText(query_json: string, replacement: string, options_json: string): string;
|
|
701
|
+
/**
|
|
702
|
+
* Serialize the (possibly edited) document to PDF bytes.
|
|
703
|
+
*/
|
|
704
|
+
save(): Uint8Array;
|
|
705
|
+
}
|
|
706
|
+
|
|
472
707
|
/**
|
|
473
708
|
* The main XFA processing engine for WASM.
|
|
474
709
|
*
|
|
@@ -566,39 +801,74 @@ export class XfaEngine {
|
|
|
566
801
|
}
|
|
567
802
|
|
|
568
803
|
/**
|
|
569
|
-
*
|
|
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.
|
|
570
816
|
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
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`.
|
|
573
822
|
*/
|
|
574
|
-
export function
|
|
823
|
+
export function encryptPdf(bytes: Uint8Array, user_password: string, owner_password: string, permissions?: EncryptPermissions | null): Uint8Array;
|
|
575
824
|
|
|
576
825
|
/**
|
|
577
|
-
*
|
|
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.
|
|
578
846
|
*/
|
|
579
|
-
export function
|
|
847
|
+
export function signPdf(bytes: Uint8Array, pkcs12: Uint8Array, password: string, options?: SignPdfOptions | null): Uint8Array;
|
|
580
848
|
|
|
581
849
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
582
850
|
|
|
583
851
|
export interface InitOutput {
|
|
584
852
|
readonly memory: WebAssembly.Memory;
|
|
585
|
-
readonly __wbg_licensestatus_free: (a: number, b: number) => void;
|
|
586
853
|
readonly __wbg_pdfdoc_free: (a: number, b: number) => void;
|
|
587
854
|
readonly __wbg_pdfdocmut_free: (a: number, b: number) => void;
|
|
855
|
+
readonly __wbg_texteditor_free: (a: number, b: number) => void;
|
|
588
856
|
readonly __wbg_xfaengine_free: (a: number, b: number) => void;
|
|
589
|
-
readonly
|
|
590
|
-
readonly
|
|
591
|
-
readonly
|
|
592
|
-
readonly licensestatus_source: (a: number, b: number) => void;
|
|
593
|
-
readonly licensestatus_tier: (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;
|
|
594
860
|
readonly pdfdoc_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
595
861
|
readonly pdfdoc_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
596
862
|
readonly pdfdoc_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
597
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;
|
|
598
865
|
readonly pdfdoc_compress: (a: number, b: number) => void;
|
|
599
866
|
readonly pdfdoc_convertToPdfa: (a: number, b: number, c: number, d: number) => void;
|
|
600
867
|
readonly pdfdoc_deletePages: (a: number, b: number, c: number, d: number) => void;
|
|
601
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;
|
|
602
872
|
readonly pdfdoc_extractPages: (a: number, b: number, c: number, d: number) => void;
|
|
603
873
|
readonly pdfdoc_flattenXfa: (a: number, b: number) => void;
|
|
604
874
|
readonly pdfdoc_getAnnotations: (a: number, b: number, c: number) => void;
|
|
@@ -612,6 +882,7 @@ export interface InitOutput {
|
|
|
612
882
|
readonly pdfdoc_pageWidth: (a: number, b: number) => number;
|
|
613
883
|
readonly pdfdoc_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
614
884
|
readonly pdfdoc_redactSearch: (a: number, b: number, c: number, d: number) => void;
|
|
885
|
+
readonly pdfdoc_refresh: (a: number, b: number, c: number, d: number) => void;
|
|
615
886
|
readonly pdfdoc_renderPage: (a: number, b: number, c: number, d: number) => void;
|
|
616
887
|
readonly pdfdoc_renderPageToCanvas: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
617
888
|
readonly pdfdoc_renderPageToCanvasVector: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -622,6 +893,9 @@ export interface InitOutput {
|
|
|
622
893
|
readonly pdfdoc_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
623
894
|
readonly pdfdoc_signatures: (a: number, b: number) => void;
|
|
624
895
|
readonly pdfdoc_text: (a: number, b: number, c: number) => void;
|
|
896
|
+
readonly pdfdoc_toDocx: (a: number, b: number) => void;
|
|
897
|
+
readonly pdfdoc_toPptx: (a: number, b: number) => void;
|
|
898
|
+
readonly pdfdoc_toXlsx: (a: number, b: number) => void;
|
|
625
899
|
readonly pdfdoc_validatePdfA: (a: number, b: number, c: number, d: number) => void;
|
|
626
900
|
readonly pdfdoc_verifySignatures: (a: number, b: number) => void;
|
|
627
901
|
readonly pdfdocmut_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
@@ -644,7 +918,15 @@ export interface InitOutput {
|
|
|
644
918
|
readonly pdfdocmut_save: (a: number, b: number) => void;
|
|
645
919
|
readonly pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
646
920
|
readonly pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
921
|
+
readonly pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
647
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;
|
|
924
|
+
readonly texteditor_findText: (a: number, b: number, c: number, d: number) => void;
|
|
925
|
+
readonly texteditor_open: (a: number, b: number, c: number) => void;
|
|
926
|
+
readonly texteditor_pageCount: (a: number) => number;
|
|
927
|
+
readonly texteditor_replaceMatches: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
928
|
+
readonly texteditor_replaceText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
929
|
+
readonly texteditor_save: (a: number, b: number) => void;
|
|
648
930
|
readonly xfaengine_exportJson: (a: number, b: number) => void;
|
|
649
931
|
readonly xfaengine_exportSchema: (a: number, b: number) => void;
|
|
650
932
|
readonly xfaengine_fromFields: (a: number, b: number, c: number) => void;
|