@pdfluent/sdk-wasm 1.0.0-beta.8 → 1.0.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 +212 -0
- package/LICENSE-OFFER +45 -0
- package/NOTICE +143 -0
- package/README.md +32 -56
- package/THIRD_PARTY_LICENSES.txt +736 -0
- package/package.json +26 -5
- package/xfa_wasm.d.ts +138 -49
- package/xfa_wasm.js +385 -122
- package/xfa_wasm_bg.wasm +0 -0
- package/xfa_wasm_bg.wasm.d.ts +12 -6
- /package/snippets/{xfa-wasm-312742e1abcfad9e → xfa-wasm-df2db187f9a0e994}/inline0.js +0 -0
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfluent/sdk-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"description": "PDFluent browser SDK —
|
|
5
|
-
"version": "1.0.0
|
|
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.0.0",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE-OFFER",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/pdfluent/pdfluent-sdk"
|
|
10
|
+
},
|
|
7
11
|
"files": [
|
|
8
12
|
"xfa_wasm_bg.wasm",
|
|
9
13
|
"xfa_wasm.js",
|
|
10
14
|
"xfa_wasm.d.ts",
|
|
11
15
|
"snippets",
|
|
12
|
-
"xfa_wasm_bg.wasm.d.ts"
|
|
16
|
+
"xfa_wasm_bg.wasm.d.ts",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"LICENSE-COMMERCIAL",
|
|
19
|
+
"LICENSE-OFFER",
|
|
20
|
+
"NOTICE",
|
|
21
|
+
"THIRD_PARTY_LICENSES.txt"
|
|
13
22
|
],
|
|
14
23
|
"main": "xfa_wasm.js",
|
|
15
24
|
"types": "xfa_wasm.d.ts",
|
|
@@ -22,11 +31,23 @@
|
|
|
22
31
|
"pdfluent",
|
|
23
32
|
"browser",
|
|
24
33
|
"sdk",
|
|
34
|
+
"pdf-text-replace",
|
|
35
|
+
"find-and-replace",
|
|
36
|
+
"edit-pdf-text",
|
|
37
|
+
"pdf-editor",
|
|
25
38
|
"xfa",
|
|
39
|
+
"acroform",
|
|
40
|
+
"pades",
|
|
26
41
|
"forms",
|
|
27
42
|
"annotate",
|
|
28
43
|
"redact"
|
|
29
44
|
],
|
|
30
45
|
"homepage": "https://pdfluent.com",
|
|
31
|
-
"author": "Innovation Trigger BV <team@pdfluent.com>"
|
|
46
|
+
"author": "Innovation Trigger BV <team@pdfluent.com>",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/pdfluent/pdfluent-sdk/issues"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
32
53
|
}
|
package/xfa_wasm.d.ts
CHANGED
|
@@ -23,27 +23,6 @@ export enum ChromaSampling {
|
|
|
23
23
|
Cs400 = 3,
|
|
24
24
|
}
|
|
25
25
|
|
|
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
26
|
/**
|
|
48
27
|
* PDF document handle for analysis and text extraction.
|
|
49
28
|
*
|
|
@@ -214,6 +193,22 @@ export class PdfDoc {
|
|
|
214
193
|
* is permanently removed from every page.
|
|
215
194
|
*/
|
|
216
195
|
redactSearch(query: string): Uint8Array;
|
|
196
|
+
/**
|
|
197
|
+
* Replace this document's content with new bytes in-place.
|
|
198
|
+
*
|
|
199
|
+
* Call this after [`PdfDocMut.save`] to update the render handle with
|
|
200
|
+
* the mutated PDF bytes so that subsequent [`renderPage`] calls reflect
|
|
201
|
+
* the changes, without needing to create a new `PdfDoc` object.
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* const handle = PdfDocMut.open(bytes);
|
|
205
|
+
* handle.replaceTextSpan(1, "old", "new");
|
|
206
|
+
* const newBytes = handle.save();
|
|
207
|
+
* doc.refresh(newBytes); // engine now renders the edited content
|
|
208
|
+
* doc.renderPage(0, 1.5); // ← shows "new" instead of "old"
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
refresh(data: Uint8Array): void;
|
|
217
212
|
/**
|
|
218
213
|
* Render a page to RGBA pixels.
|
|
219
214
|
*
|
|
@@ -266,11 +261,18 @@ export class PdfDoc {
|
|
|
266
261
|
*/
|
|
267
262
|
rotatePage(page_index: number, degrees: number): Uint8Array;
|
|
268
263
|
/**
|
|
269
|
-
* Set a single AcroForm text
|
|
264
|
+
* Set a single AcroForm **text** field value. Returns the new PDF bytes.
|
|
265
|
+
*
|
|
266
|
+
* Updates `/V` (ASCII literal or UTF-16BE+BOM), per-widget `/AS`, and
|
|
267
|
+
* regenerates the `/AP` appearance stream so the fill is visible without
|
|
268
|
+
* `/NeedAppearances` processing. Read-only fields throw.
|
|
269
|
+
*
|
|
270
|
+
* **Text fields only.** For checkbox, radio, and choice fields use
|
|
271
|
+
* `PdfDocMut.setFormField`, which runs the full type-aware dispatch.
|
|
270
272
|
*/
|
|
271
273
|
setFormField(path: string, value: string): Uint8Array;
|
|
272
274
|
/**
|
|
273
|
-
* Bulk-set multiple AcroForm text fields from a JSON object
|
|
275
|
+
* Bulk-set multiple AcroForm **text** fields from a JSON object
|
|
274
276
|
* `{"field.path": "value", ...}`. Returns the new PDF bytes.
|
|
275
277
|
*/
|
|
276
278
|
setFormFields(fields_json: string): Uint8Array;
|
|
@@ -285,6 +287,25 @@ export class PdfDoc {
|
|
|
285
287
|
* extraction fails.
|
|
286
288
|
*/
|
|
287
289
|
text(page_index: number): string;
|
|
290
|
+
/**
|
|
291
|
+
* Convert this PDF to a Word `.docx` package.
|
|
292
|
+
*
|
|
293
|
+
* Returns the package as a `Uint8Array`.
|
|
294
|
+
*
|
|
295
|
+
* The browser SDK could not do this until 23-08-2026: the conversion
|
|
296
|
+
* crates were excluded from wasm32 by a comment that applied to the
|
|
297
|
+
* renderer, not to them.
|
|
298
|
+
*/
|
|
299
|
+
toDocx(): Uint8Array;
|
|
300
|
+
/**
|
|
301
|
+
* Convert this PDF to a PowerPoint `.pptx` deck, one slide per page.
|
|
302
|
+
* See [`Self::to_docx`].
|
|
303
|
+
*/
|
|
304
|
+
toPptx(): Uint8Array;
|
|
305
|
+
/**
|
|
306
|
+
* Convert this PDF to an Excel `.xlsx` workbook. See [`Self::to_docx`].
|
|
307
|
+
*/
|
|
308
|
+
toXlsx(): Uint8Array;
|
|
288
309
|
/**
|
|
289
310
|
* Validate against a PDF/A level. Returns compliance report as JSON.
|
|
290
311
|
*/
|
|
@@ -449,26 +470,101 @@ export class PdfDocMut {
|
|
|
449
470
|
*/
|
|
450
471
|
save(): Uint8Array;
|
|
451
472
|
/**
|
|
452
|
-
* Set a single AcroForm
|
|
473
|
+
* Set a single AcroForm field value (text, checkbox, radio, or choice).
|
|
453
474
|
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* recursion) — same constraint as the Rust core.
|
|
475
|
+
* Delegates to [`pdf_forms::apply_field_value`] — the single SDK
|
|
476
|
+
* writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
|
|
477
|
+
* per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
|
|
478
|
+
* fully-qualified names through `/Kids`, and rejects read-only fields.
|
|
459
479
|
*/
|
|
460
480
|
setFormField(path: string, value: string): void;
|
|
461
481
|
/**
|
|
462
|
-
* Bulk-set multiple AcroForm
|
|
482
|
+
* Bulk-set multiple AcroForm fields from a JSON object
|
|
463
483
|
* `{"field.path": "value", ...}`.
|
|
464
484
|
*/
|
|
465
485
|
setFormFields(fields_json: string): void;
|
|
486
|
+
/**
|
|
487
|
+
* Select multiple options on a multi-select list box.
|
|
488
|
+
*
|
|
489
|
+
* Delegates to [`pdf_forms::apply_choice_multi`]: writes `/V` as an array
|
|
490
|
+
* of text strings and rebuilds `/I` (the sorted selected-index cache) to
|
|
491
|
+
* match what Adobe Acrobat produces. `values` is a JS array of strings;
|
|
492
|
+
* pass an empty array to clear the selection. The field must be a
|
|
493
|
+
* multi-select list box (`/Ff` MultiSelect flag); for non-editable list
|
|
494
|
+
* boxes every value must be one of the field's `/Opt` options.
|
|
495
|
+
*/
|
|
496
|
+
setMultiSelect(path: string, values: string[]): void;
|
|
466
497
|
/**
|
|
467
498
|
* Apply bold/italic style to a text run on `page_num` (1-based).
|
|
468
499
|
*/
|
|
469
500
|
setTextRunStyle(page_num: number, runs_json: string, run_index: number, bold?: boolean | null, italic?: boolean | null): string;
|
|
470
501
|
}
|
|
471
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Find-and-replace editor over a PDF document (SDK surface).
|
|
505
|
+
*/
|
|
506
|
+
export class TextEditor {
|
|
507
|
+
private constructor();
|
|
508
|
+
free(): void;
|
|
509
|
+
[Symbol.dispose](): void;
|
|
510
|
+
/**
|
|
511
|
+
* Find text occurrences. `query_json` is a JSON object:
|
|
512
|
+
*
|
|
513
|
+
* ```json
|
|
514
|
+
* {
|
|
515
|
+
* "text": "Acme B.V.", // required
|
|
516
|
+
* "caseInsensitive": false, // optional
|
|
517
|
+
* "pages": [1, 5], // optional inclusive 1-based range
|
|
518
|
+
* "region": { // optional
|
|
519
|
+
* "page": 1,
|
|
520
|
+
* "rect": [x0, y0, x1, y1],
|
|
521
|
+
* "relation": "intersects" // or "contained"
|
|
522
|
+
* },
|
|
523
|
+
* "limit": 100 // optional
|
|
524
|
+
* }
|
|
525
|
+
* ```
|
|
526
|
+
*
|
|
527
|
+
* Returns a JSON array of matches; each match carries an opaque `id`
|
|
528
|
+
* token valid until the next applied edit on this document.
|
|
529
|
+
*/
|
|
530
|
+
findText(query_json: string): string;
|
|
531
|
+
/**
|
|
532
|
+
* Open a PDF from raw bytes.
|
|
533
|
+
*/
|
|
534
|
+
static open(data: Uint8Array): TextEditor;
|
|
535
|
+
/**
|
|
536
|
+
* Number of pages.
|
|
537
|
+
*/
|
|
538
|
+
pageCount(): number;
|
|
539
|
+
/**
|
|
540
|
+
* Apply per-match replacements located earlier with `findText`.
|
|
541
|
+
*
|
|
542
|
+
* `edits_json` is a JSON array of `{"id": "<match token>", "text":
|
|
543
|
+
* "<replacement>"}`. All edits commit in one atomic transaction under
|
|
544
|
+
* `options_json` (see [`TextEditor::replace_text`]); the default is
|
|
545
|
+
* all-or-nothing. Returns the JSON replacement report.
|
|
546
|
+
*/
|
|
547
|
+
replaceMatches(edits_json: string, options_json: string): string;
|
|
548
|
+
/**
|
|
549
|
+
* Find and replace in one call. Returns the JSON replacement report.
|
|
550
|
+
*
|
|
551
|
+
* `options_json` may be empty/`"{}"` for defaults, or:
|
|
552
|
+
*
|
|
553
|
+
* ```json
|
|
554
|
+
* {
|
|
555
|
+
* "fontFallback": "deny" | "injectStandard" | {"explicit": "F1"},
|
|
556
|
+
* "signaturePolicy": "reject" | "allowPostSignatureChange",
|
|
557
|
+
* "commitPolicy": "allOrNothing" | "bestEffort"
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
replaceText(query_json: string, replacement: string, options_json: string): string;
|
|
562
|
+
/**
|
|
563
|
+
* Serialize the (possibly edited) document to PDF bytes.
|
|
564
|
+
*/
|
|
565
|
+
save(): Uint8Array;
|
|
566
|
+
}
|
|
567
|
+
|
|
472
568
|
/**
|
|
473
569
|
* The main XFA processing engine for WASM.
|
|
474
570
|
*
|
|
@@ -565,32 +661,14 @@ export class XfaEngine {
|
|
|
565
661
|
static version(): string;
|
|
566
662
|
}
|
|
567
663
|
|
|
568
|
-
/**
|
|
569
|
-
* Activate the process-global license from a key string.
|
|
570
|
-
*
|
|
571
|
-
* Throws on invalid key or if the process has already been activated to a
|
|
572
|
-
* different tier this session.
|
|
573
|
-
*/
|
|
574
|
-
export function activateLicenseKey(key: string): void;
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Return the current license status. Always succeeds; defaults to Trial.
|
|
578
|
-
*/
|
|
579
|
-
export function licenseStatus(): LicenseStatus;
|
|
580
|
-
|
|
581
664
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
582
665
|
|
|
583
666
|
export interface InitOutput {
|
|
584
667
|
readonly memory: WebAssembly.Memory;
|
|
585
|
-
readonly __wbg_licensestatus_free: (a: number, b: number) => void;
|
|
586
668
|
readonly __wbg_pdfdoc_free: (a: number, b: number) => void;
|
|
587
669
|
readonly __wbg_pdfdocmut_free: (a: number, b: number) => void;
|
|
670
|
+
readonly __wbg_texteditor_free: (a: number, b: number) => void;
|
|
588
671
|
readonly __wbg_xfaengine_free: (a: number, b: number) => void;
|
|
589
|
-
readonly activateLicenseKey: (a: number, b: number, c: number) => void;
|
|
590
|
-
readonly licenseStatus: () => number;
|
|
591
|
-
readonly licensestatus_outputIsMarked: (a: number) => number;
|
|
592
|
-
readonly licensestatus_source: (a: number, b: number) => void;
|
|
593
|
-
readonly licensestatus_tier: (a: number, b: number) => void;
|
|
594
672
|
readonly pdfdoc_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
595
673
|
readonly pdfdoc_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
596
674
|
readonly pdfdoc_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
@@ -612,6 +690,7 @@ export interface InitOutput {
|
|
|
612
690
|
readonly pdfdoc_pageWidth: (a: number, b: number) => number;
|
|
613
691
|
readonly pdfdoc_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
614
692
|
readonly pdfdoc_redactSearch: (a: number, b: number, c: number, d: number) => void;
|
|
693
|
+
readonly pdfdoc_refresh: (a: number, b: number, c: number, d: number) => void;
|
|
615
694
|
readonly pdfdoc_renderPage: (a: number, b: number, c: number, d: number) => void;
|
|
616
695
|
readonly pdfdoc_renderPageToCanvas: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
617
696
|
readonly pdfdoc_renderPageToCanvasVector: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -622,6 +701,9 @@ export interface InitOutput {
|
|
|
622
701
|
readonly pdfdoc_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
623
702
|
readonly pdfdoc_signatures: (a: number, b: number) => void;
|
|
624
703
|
readonly pdfdoc_text: (a: number, b: number, c: number) => void;
|
|
704
|
+
readonly pdfdoc_toDocx: (a: number, b: number) => void;
|
|
705
|
+
readonly pdfdoc_toPptx: (a: number, b: number) => void;
|
|
706
|
+
readonly pdfdoc_toXlsx: (a: number, b: number) => void;
|
|
625
707
|
readonly pdfdoc_validatePdfA: (a: number, b: number, c: number, d: number) => void;
|
|
626
708
|
readonly pdfdoc_verifySignatures: (a: number, b: number) => void;
|
|
627
709
|
readonly pdfdocmut_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
@@ -644,7 +726,14 @@ export interface InitOutput {
|
|
|
644
726
|
readonly pdfdocmut_save: (a: number, b: number) => void;
|
|
645
727
|
readonly pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
646
728
|
readonly pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
|
|
729
|
+
readonly pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
647
730
|
readonly pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
731
|
+
readonly texteditor_findText: (a: number, b: number, c: number, d: number) => void;
|
|
732
|
+
readonly texteditor_open: (a: number, b: number, c: number) => void;
|
|
733
|
+
readonly texteditor_pageCount: (a: number) => number;
|
|
734
|
+
readonly texteditor_replaceMatches: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
735
|
+
readonly texteditor_replaceText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
736
|
+
readonly texteditor_save: (a: number, b: number) => void;
|
|
648
737
|
readonly xfaengine_exportJson: (a: number, b: number) => void;
|
|
649
738
|
readonly xfaengine_exportSchema: (a: number, b: number) => void;
|
|
650
739
|
readonly xfaengine_fromFields: (a: number, b: number, c: number) => void;
|