@pdfluent/sdk-wasm 1.0.0-beta.12 → 1.0.0-beta.17

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/README.md CHANGED
@@ -237,8 +237,8 @@ Invalid keys throw `Error`. The key string is never logged.
237
237
 
238
238
  | Method | Description |
239
239
  |--------|-------------|
240
- | `setFormField(path, value)` | Set a single AcroForm text field; returns new bytes |
241
- | `setFormFields(jsonObject)` | Bulk-set form fields from a JSON `{path: value}` map |
240
+ | `setFormField(path, value)` | Fill a single AcroForm **text** field; updates `/V`, `/AS`, and `/AP`; returns new bytes. For checkbox/radio/choice use `PdfDocMut`. |
241
+ | `setFormFields(jsonObject)` | Bulk-fill **text** fields from a JSON `{path: value}` map; returns new bytes |
242
242
  | `addHighlight(pageIndex, x, y, w, h, colorHex?)` | Highlight annotation (feature: annotate) |
243
243
  | `addStickyNote(pageIndex, x, y, contents)` | Sticky note annotation (feature: annotate) |
244
244
  | `addFreeText(pageIndex, x, y, w, h, contents)` | Free-text annotation (feature: annotate) |
@@ -266,8 +266,8 @@ operations to the same document, **`PdfDocMut` is dramatically faster**:
266
266
  | `rotatePage(pageIndex, degrees)` | In place |
267
267
  | `reorderPages(newOrder)` | In place |
268
268
  | `extractPages(pages)` | Returns bytes for a NEW subdocument; current editor unchanged |
269
- | `setFormField(path, value)` | In place |
270
- | `setFormFields(jsonObject)` | In place, bulk |
269
+ | `setFormField(path, value)` | In place — text, checkbox, radio, and choice; updates `/V`, `/AS`, and `/AP` |
270
+ | `setFormFields(jsonObject)` | In place, bulk — same full chain for each entry |
271
271
  | `addHighlight(pageIndex, x, y, w, h, colorHex?)` | In place (feature: annotate) |
272
272
  | `addStickyNote(pageIndex, x, y, contents)` | In place (feature: annotate) |
273
273
  | `addFreeText(pageIndex, x, y, w, h, contents)` | In place (feature: annotate) |
package/package.json CHANGED
@@ -2,12 +2,14 @@
2
2
  "name": "@pdfluent/sdk-wasm",
3
3
  "type": "module",
4
4
  "description": "PDFluent browser SDK — read, edit, annotate, redact, sign, and validate PDFs (including XFA) entirely client-side via WASM.",
5
- "version": "1.0.0-beta.12",
5
+ "version": "1.0.0-beta.17",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "files": [
8
8
  "xfa_wasm_bg.wasm",
9
9
  "xfa_wasm.js",
10
- "xfa_wasm.d.ts"
10
+ "xfa_wasm.d.ts",
11
+ "snippets",
12
+ "xfa_wasm_bg.wasm.d.ts"
11
13
  ],
12
14
  "main": "xfa_wasm.js",
13
15
  "types": "xfa_wasm.d.ts",
@@ -0,0 +1,19 @@
1
+
2
+ export function __pdfluent_error_ctor() {
3
+ if (globalThis.__PdfluentError) {
4
+ return globalThis.__PdfluentError;
5
+ }
6
+ class PdfluentError extends Error {
7
+ constructor(message, code, operation, help, docsUrl, legacyCode) {
8
+ super(message);
9
+ this.name = "PdfluentError";
10
+ this.code = code;
11
+ this.operation = operation;
12
+ this.help = help;
13
+ this.docsUrl = docsUrl;
14
+ this.legacyCode = legacyCode;
15
+ }
16
+ }
17
+ globalThis.__PdfluentError = PdfluentError;
18
+ return PdfluentError;
19
+ }
package/xfa_wasm.d.ts CHANGED
@@ -214,6 +214,22 @@ export class PdfDoc {
214
214
  * is permanently removed from every page.
215
215
  */
216
216
  redactSearch(query: string): Uint8Array;
217
+ /**
218
+ * Replace this document's content with new bytes in-place.
219
+ *
220
+ * Call this after [`PdfDocMut.save`] to update the render handle with
221
+ * the mutated PDF bytes so that subsequent [`renderPage`] calls reflect
222
+ * the changes, without needing to create a new `PdfDoc` object.
223
+ *
224
+ * ```js
225
+ * const handle = PdfDocMut.open(bytes);
226
+ * handle.replaceTextSpan(1, "old", "new");
227
+ * const newBytes = handle.save();
228
+ * doc.refresh(newBytes); // engine now renders the edited content
229
+ * doc.renderPage(0, 1.5); // ← shows "new" instead of "old"
230
+ * ```
231
+ */
232
+ refresh(data: Uint8Array): void;
217
233
  /**
218
234
  * Render a page to RGBA pixels.
219
235
  *
@@ -266,11 +282,18 @@ export class PdfDoc {
266
282
  */
267
283
  rotatePage(page_index: number, degrees: number): Uint8Array;
268
284
  /**
269
- * Set a single AcroForm text-field value. Returns the new PDF bytes.
285
+ * Set a single AcroForm **text** field value. Returns the new PDF bytes.
286
+ *
287
+ * Updates `/V` (ASCII literal or UTF-16BE+BOM), per-widget `/AS`, and
288
+ * regenerates the `/AP` appearance stream so the fill is visible without
289
+ * `/NeedAppearances` processing. Read-only fields throw.
290
+ *
291
+ * **Text fields only.** For checkbox, radio, and choice fields use
292
+ * `PdfDocMut.setFormField`, which runs the full type-aware dispatch.
270
293
  */
271
294
  setFormField(path: string, value: string): Uint8Array;
272
295
  /**
273
- * Bulk-set multiple AcroForm text fields from a JSON object
296
+ * Bulk-set multiple AcroForm **text** fields from a JSON object
274
297
  * `{"field.path": "value", ...}`. Returns the new PDF bytes.
275
298
  */
276
299
  setFormFields(fields_json: string): Uint8Array;
@@ -449,20 +472,30 @@ export class PdfDocMut {
449
472
  */
450
473
  save(): Uint8Array;
451
474
  /**
452
- * Set a single AcroForm text-field value.
475
+ * Set a single AcroForm field value (text, checkbox, radio, or choice).
453
476
  *
454
- * Note: pdfluent's high-level `PdfFormMut` requires a
455
- * `pdfluent::PdfDocument`. To stay in-place on this handle, we use
456
- * the lower-level lopdf walk via the `pdf-forms` engine. For 1.0,
457
- * this supports flat top-level field hierarchies (no `/Kids`
458
- * recursion) — same constraint as the Rust core.
477
+ * Delegates to [`pdf_forms::apply_field_value`] — the single SDK
478
+ * writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
479
+ * per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
480
+ * fully-qualified names through `/Kids`, and rejects read-only fields.
459
481
  */
460
482
  setFormField(path: string, value: string): void;
461
483
  /**
462
- * Bulk-set multiple AcroForm text fields from a JSON object
484
+ * Bulk-set multiple AcroForm fields from a JSON object
463
485
  * `{"field.path": "value", ...}`.
464
486
  */
465
487
  setFormFields(fields_json: string): void;
488
+ /**
489
+ * Select multiple options on a multi-select list box.
490
+ *
491
+ * Delegates to [`pdf_forms::apply_choice_multi`]: writes `/V` as an array
492
+ * of text strings and rebuilds `/I` (the sorted selected-index cache) to
493
+ * match what Adobe Acrobat produces. `values` is a JS array of strings;
494
+ * pass an empty array to clear the selection. The field must be a
495
+ * multi-select list box (`/Ff` MultiSelect flag); for non-editable list
496
+ * boxes every value must be one of the field's `/Opt` options.
497
+ */
498
+ setMultiSelect(path: string, values: string[]): void;
466
499
  /**
467
500
  * Apply bold/italic style to a text run on `page_num` (1-based).
468
501
  */
@@ -574,30 +607,38 @@ export class XfaEngine {
574
607
  export function activateLicenseKey(key: string): void;
575
608
 
576
609
  /**
577
- * Flatten an XFA (XML Forms Architecture) PDF into a static, viewer-agnostic
578
- * PDF, entirely in the browser.
610
+ * Return the current license status. Always succeeds; defaults to Trial.
611
+ */
612
+ export function licenseStatus(): LicenseStatus;
613
+
614
+ /**
615
+ * Activate a signed license payload (Ed25519-verified JSON).
579
616
  *
580
- * `data` is the raw PDF bytes (a dynamic or static XFA form). `password` is an
581
- * optional user password for XFA PDFs protected with PDF user-password
582
- * encryption; it is ignored for unencrypted input. A wrong or missing password
583
- * on an encrypted document throws an error whose message starts
584
- * `E-XFA-ENCRYPTED` and never returns plaintext; a password on an unencrypted
585
- * PDF is ignored. This does not crack, remove, or bypass owner-password
586
- * permissions.
617
+ * Mirrors the Node binding `setLicensePayload` and the Rust core
618
+ * [`pdfluent::set_license_payload`]. Verifies the signature against the key
619
+ * set via [`set_license_public_key`], checks `expires_at > now`, and stores
620
+ * the resolved tier process-wide so [`license_status`] surfaces it.
587
621
  *
588
- * ```js
589
- * import init, { flattenXfa } from "@pdfluent/sdk-wasm";
590
- * await init();
591
- * const flat = flattenXfa(new Uint8Array(buf)); // unencrypted
592
- * const flatEnc = flattenXfa(new Uint8Array(buf), "secret"); // encrypted
593
- * ```
622
+ * Throws `E-LICENSE-INVALID` (no public key configured, malformed JSON,
623
+ * unrecognised tier, or already set to a different tier),
624
+ * `E-LICENSE-INVALID-SIGNATURE` (signature does not verify), or
625
+ * `E-LICENSE-EXPIRED` (payload expired). On any error the process-global
626
+ * tier is **not** modified.
594
627
  */
595
- export function flattenXfa(data: Uint8Array, password?: string | null): Uint8Array;
628
+ export function setLicensePayload(payload_json: string): void;
596
629
 
597
630
  /**
598
- * Return the current license status. Always succeeds; defaults to Trial.
631
+ * Inject the Ed25519 public verification key for signed license payloads.
632
+ *
633
+ * Mirrors the Node binding `setLicensePublicKey` and the Rust core
634
+ * [`pdfluent::set_license_public_key`]. Must be called **before**
635
+ * [`set_license_payload`]. `public_key` must be exactly 32 bytes.
636
+ *
637
+ * Calling twice with the same key bytes is idempotent; calling with a
638
+ * different key throws (`E-LICENSE-INVALID`) — restart the worker/page to
639
+ * swap keys.
599
640
  */
600
- export function licenseStatus(): LicenseStatus;
641
+ export function setLicensePublicKey(public_key: Uint8Array): void;
601
642
 
602
643
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
603
644
 
@@ -608,7 +649,6 @@ export interface InitOutput {
608
649
  readonly __wbg_pdfdocmut_free: (a: number, b: number) => void;
609
650
  readonly __wbg_xfaengine_free: (a: number, b: number) => void;
610
651
  readonly activateLicenseKey: (a: number, b: number, c: number) => void;
611
- readonly flattenXfa: (a: number, b: number, c: number, d: number, e: number) => void;
612
652
  readonly licenseStatus: () => number;
613
653
  readonly licensestatus_outputIsMarked: (a: number) => number;
614
654
  readonly licensestatus_source: (a: number, b: number) => void;
@@ -634,6 +674,7 @@ export interface InitOutput {
634
674
  readonly pdfdoc_pageWidth: (a: number, b: number) => number;
635
675
  readonly pdfdoc_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
636
676
  readonly pdfdoc_redactSearch: (a: number, b: number, c: number, d: number) => void;
677
+ readonly pdfdoc_refresh: (a: number, b: number, c: number, d: number) => void;
637
678
  readonly pdfdoc_renderPage: (a: number, b: number, c: number, d: number) => void;
638
679
  readonly pdfdoc_renderPageToCanvas: (a: number, b: number, c: number, d: number, e: number) => void;
639
680
  readonly pdfdoc_renderPageToCanvasVector: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -666,7 +707,10 @@ export interface InitOutput {
666
707
  readonly pdfdocmut_save: (a: number, b: number) => void;
667
708
  readonly pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
668
709
  readonly pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
710
+ readonly pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
669
711
  readonly pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
712
+ readonly setLicensePayload: (a: number, b: number, c: number) => void;
713
+ readonly setLicensePublicKey: (a: number, b: number, c: number) => void;
670
714
  readonly xfaengine_exportJson: (a: number, b: number) => void;
671
715
  readonly xfaengine_exportSchema: (a: number, b: number) => void;
672
716
  readonly xfaengine_fromFields: (a: number, b: number, c: number) => void;
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-312742e1abcfad9e/inline0.js';
2
+ import { __pdfluent_error_ctor } from './snippets/xfa-wasm-24036f6340bfe813/inline0.js';
3
3
 
4
4
 
5
5
  /**
@@ -659,6 +659,37 @@ export class PdfDoc {
659
659
  wasm.__wbindgen_add_to_stack_pointer(16);
660
660
  }
661
661
  }
662
+ /**
663
+ * Replace this document's content with new bytes in-place.
664
+ *
665
+ * Call this after [`PdfDocMut.save`] to update the render handle with
666
+ * the mutated PDF bytes so that subsequent [`renderPage`] calls reflect
667
+ * the changes, without needing to create a new `PdfDoc` object.
668
+ *
669
+ * ```js
670
+ * const handle = PdfDocMut.open(bytes);
671
+ * handle.replaceTextSpan(1, "old", "new");
672
+ * const newBytes = handle.save();
673
+ * doc.refresh(newBytes); // engine now renders the edited content
674
+ * doc.renderPage(0, 1.5); // ← shows "new" instead of "old"
675
+ * ```
676
+ * @param {Uint8Array} data
677
+ */
678
+ refresh(data) {
679
+ try {
680
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
681
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
682
+ const len0 = WASM_VECTOR_LEN;
683
+ wasm.pdfdoc_refresh(retptr, this.__wbg_ptr, ptr0, len0);
684
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
685
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
686
+ if (r1) {
687
+ throw takeObject(r0);
688
+ }
689
+ } finally {
690
+ wasm.__wbindgen_add_to_stack_pointer(16);
691
+ }
692
+ }
662
693
  /**
663
694
  * Render a page to RGBA pixels.
664
695
  *
@@ -824,7 +855,14 @@ export class PdfDoc {
824
855
  }
825
856
  }
826
857
  /**
827
- * Set a single AcroForm text-field value. Returns the new PDF bytes.
858
+ * Set a single AcroForm **text** field value. Returns the new PDF bytes.
859
+ *
860
+ * Updates `/V` (ASCII literal or UTF-16BE+BOM), per-widget `/AS`, and
861
+ * regenerates the `/AP` appearance stream so the fill is visible without
862
+ * `/NeedAppearances` processing. Read-only fields throw.
863
+ *
864
+ * **Text fields only.** For checkbox, radio, and choice fields use
865
+ * `PdfDocMut.setFormField`, which runs the full type-aware dispatch.
828
866
  * @param {string} path
829
867
  * @param {string} value
830
868
  * @returns {Uint8Array}
@@ -852,7 +890,7 @@ export class PdfDoc {
852
890
  }
853
891
  }
854
892
  /**
855
- * Bulk-set multiple AcroForm text fields from a JSON object
893
+ * Bulk-set multiple AcroForm **text** fields from a JSON object
856
894
  * `{"field.path": "value", ...}`. Returns the new PDF bytes.
857
895
  * @param {string} fields_json
858
896
  * @returns {Uint8Array}
@@ -1478,13 +1516,12 @@ export class PdfDocMut {
1478
1516
  }
1479
1517
  }
1480
1518
  /**
1481
- * Set a single AcroForm text-field value.
1519
+ * Set a single AcroForm field value (text, checkbox, radio, or choice).
1482
1520
  *
1483
- * Note: pdfluent's high-level `PdfFormMut` requires a
1484
- * `pdfluent::PdfDocument`. To stay in-place on this handle, we use
1485
- * the lower-level lopdf walk via the `pdf-forms` engine. For 1.0,
1486
- * this supports flat top-level field hierarchies (no `/Kids`
1487
- * recursion) — same constraint as the Rust core.
1521
+ * Delegates to [`pdf_forms::apply_field_value`] — the single SDK
1522
+ * writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
1523
+ * per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
1524
+ * fully-qualified names through `/Kids`, and rejects read-only fields.
1488
1525
  * @param {string} path
1489
1526
  * @param {string} value
1490
1527
  */
@@ -1506,7 +1543,7 @@ export class PdfDocMut {
1506
1543
  }
1507
1544
  }
1508
1545
  /**
1509
- * Bulk-set multiple AcroForm text fields from a JSON object
1546
+ * Bulk-set multiple AcroForm fields from a JSON object
1510
1547
  * `{"field.path": "value", ...}`.
1511
1548
  * @param {string} fields_json
1512
1549
  */
@@ -1525,6 +1562,35 @@ export class PdfDocMut {
1525
1562
  wasm.__wbindgen_add_to_stack_pointer(16);
1526
1563
  }
1527
1564
  }
1565
+ /**
1566
+ * Select multiple options on a multi-select list box.
1567
+ *
1568
+ * Delegates to [`pdf_forms::apply_choice_multi`]: writes `/V` as an array
1569
+ * of text strings and rebuilds `/I` (the sorted selected-index cache) to
1570
+ * match what Adobe Acrobat produces. `values` is a JS array of strings;
1571
+ * pass an empty array to clear the selection. The field must be a
1572
+ * multi-select list box (`/Ff` MultiSelect flag); for non-editable list
1573
+ * boxes every value must be one of the field's `/Opt` options.
1574
+ * @param {string} path
1575
+ * @param {string[]} values
1576
+ */
1577
+ setMultiSelect(path, values) {
1578
+ try {
1579
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1580
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1581
+ const len0 = WASM_VECTOR_LEN;
1582
+ const ptr1 = passArrayJsValueToWasm0(values, wasm.__wbindgen_export);
1583
+ const len1 = WASM_VECTOR_LEN;
1584
+ wasm.pdfdocmut_setMultiSelect(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1585
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1586
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1587
+ if (r1) {
1588
+ throw takeObject(r0);
1589
+ }
1590
+ } finally {
1591
+ wasm.__wbindgen_add_to_stack_pointer(16);
1592
+ }
1593
+ }
1528
1594
  /**
1529
1595
  * Apply bold/italic style to a text run on `page_num` (1-based).
1530
1596
  * @param {number} page_num
@@ -1857,66 +1923,76 @@ export function activateLicenseKey(key) {
1857
1923
  }
1858
1924
 
1859
1925
  /**
1860
- * Flatten an XFA (XML Forms Architecture) PDF into a static, viewer-agnostic
1861
- * PDF, entirely in the browser.
1926
+ * Return the current license status. Always succeeds; defaults to Trial.
1927
+ * @returns {LicenseStatus}
1928
+ */
1929
+ export function licenseStatus() {
1930
+ const ret = wasm.licenseStatus();
1931
+ return LicenseStatus.__wrap(ret);
1932
+ }
1933
+
1934
+ /**
1935
+ * Activate a signed license payload (Ed25519-verified JSON).
1862
1936
  *
1863
- * `data` is the raw PDF bytes (a dynamic or static XFA form). `password` is an
1864
- * optional user password for XFA PDFs protected with PDF user-password
1865
- * encryption; it is ignored for unencrypted input. A wrong or missing password
1866
- * on an encrypted document throws an error whose message starts
1867
- * `E-XFA-ENCRYPTED` and never returns plaintext; a password on an unencrypted
1868
- * PDF is ignored. This does not crack, remove, or bypass owner-password
1869
- * permissions.
1937
+ * Mirrors the Node binding `setLicensePayload` and the Rust core
1938
+ * [`pdfluent::set_license_payload`]. Verifies the signature against the key
1939
+ * set via [`set_license_public_key`], checks `expires_at > now`, and stores
1940
+ * the resolved tier process-wide so [`license_status`] surfaces it.
1870
1941
  *
1871
- * ```js
1872
- * import init, { flattenXfa } from "@pdfluent/sdk-wasm";
1873
- * await init();
1874
- * const flat = flattenXfa(new Uint8Array(buf)); // unencrypted
1875
- * const flatEnc = flattenXfa(new Uint8Array(buf), "secret"); // encrypted
1876
- * ```
1877
- * @param {Uint8Array} data
1878
- * @param {string | null} [password]
1879
- * @returns {Uint8Array}
1942
+ * Throws `E-LICENSE-INVALID` (no public key configured, malformed JSON,
1943
+ * unrecognised tier, or already set to a different tier),
1944
+ * `E-LICENSE-INVALID-SIGNATURE` (signature does not verify), or
1945
+ * `E-LICENSE-EXPIRED` (payload expired). On any error the process-global
1946
+ * tier is **not** modified.
1947
+ * @param {string} payload_json
1880
1948
  */
1881
- export function flattenXfa(data, password) {
1949
+ export function setLicensePayload(payload_json) {
1882
1950
  try {
1883
1951
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1884
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1952
+ const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1885
1953
  const len0 = WASM_VECTOR_LEN;
1886
- var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1887
- var len1 = WASM_VECTOR_LEN;
1888
- wasm.flattenXfa(retptr, ptr0, len0, ptr1, len1);
1954
+ wasm.setLicensePayload(retptr, ptr0, len0);
1889
1955
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1890
1956
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1891
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1892
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1893
- if (r3) {
1894
- throw takeObject(r2);
1895
- }
1896
- var v3 = getArrayU8FromWasm0(r0, r1).slice();
1897
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1898
- return v3;
1957
+ if (r1) {
1958
+ throw takeObject(r0);
1959
+ }
1899
1960
  } finally {
1900
1961
  wasm.__wbindgen_add_to_stack_pointer(16);
1901
1962
  }
1902
1963
  }
1903
1964
 
1904
1965
  /**
1905
- * Return the current license status. Always succeeds; defaults to Trial.
1906
- * @returns {LicenseStatus}
1966
+ * Inject the Ed25519 public verification key for signed license payloads.
1967
+ *
1968
+ * Mirrors the Node binding `setLicensePublicKey` and the Rust core
1969
+ * [`pdfluent::set_license_public_key`]. Must be called **before**
1970
+ * [`set_license_payload`]. `public_key` must be exactly 32 bytes.
1971
+ *
1972
+ * Calling twice with the same key bytes is idempotent; calling with a
1973
+ * different key throws (`E-LICENSE-INVALID`) — restart the worker/page to
1974
+ * swap keys.
1975
+ * @param {Uint8Array} public_key
1907
1976
  */
1908
- export function licenseStatus() {
1909
- const ret = wasm.licenseStatus();
1910
- return LicenseStatus.__wrap(ret);
1977
+ export function setLicensePublicKey(public_key) {
1978
+ try {
1979
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1980
+ const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_export);
1981
+ const len0 = WASM_VECTOR_LEN;
1982
+ wasm.setLicensePublicKey(retptr, ptr0, len0);
1983
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1984
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1985
+ if (r1) {
1986
+ throw takeObject(r0);
1987
+ }
1988
+ } finally {
1989
+ wasm.__wbindgen_add_to_stack_pointer(16);
1990
+ }
1911
1991
  }
1912
1992
  function __wbg_get_imports() {
1913
1993
  const import0 = {
1914
1994
  __proto__: null,
1915
- __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
1916
- const ret = Error(getStringFromWasm0(arg0, arg1));
1917
- return addHeapObject(ret);
1918
- },
1919
- __wbg___pdfluent_error_ctor_eea54aa1c0fd64d9: function() {
1995
+ __wbg___pdfluent_error_ctor_d5ec563386e2f105: function() {
1920
1996
  const ret = __pdfluent_error_ctor();
1921
1997
  return addHeapObject(ret);
1922
1998
  },
@@ -1931,6 +2007,14 @@ function __wbg_get_imports() {
1931
2007
  const ret = typeof(getObject(arg0)) === 'function';
1932
2008
  return ret;
1933
2009
  },
2010
+ __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
2011
+ const obj = getObject(arg1);
2012
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2013
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2014
+ var len1 = WASM_VECTOR_LEN;
2015
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2016
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2017
+ },
1934
2018
  __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
1935
2019
  throw new Error(getStringFromWasm0(arg0, arg1));
1936
2020
  },
@@ -2279,6 +2363,16 @@ function passArray8ToWasm0(arg, malloc) {
2279
2363
  return ptr;
2280
2364
  }
2281
2365
 
2366
+ function passArrayJsValueToWasm0(array, malloc) {
2367
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2368
+ const mem = getDataViewMemory0();
2369
+ for (let i = 0; i < array.length; i++) {
2370
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
2371
+ }
2372
+ WASM_VECTOR_LEN = array.length;
2373
+ return ptr;
2374
+ }
2375
+
2282
2376
  function passStringToWasm0(arg, malloc, realloc) {
2283
2377
  if (realloc === undefined) {
2284
2378
  const buf = cachedTextEncoder.encode(arg);
package/xfa_wasm_bg.wasm CHANGED
Binary file
@@ -0,0 +1,85 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_licensestatus_free: (a: number, b: number) => void;
5
+ export const __wbg_pdfdoc_free: (a: number, b: number) => void;
6
+ export const __wbg_pdfdocmut_free: (a: number, b: number) => void;
7
+ export const __wbg_xfaengine_free: (a: number, b: number) => void;
8
+ export const activateLicenseKey: (a: number, b: number, c: number) => void;
9
+ export const licenseStatus: () => number;
10
+ export const licensestatus_outputIsMarked: (a: number) => number;
11
+ export const licensestatus_source: (a: number, b: number) => void;
12
+ export const licensestatus_tier: (a: number, b: number) => void;
13
+ export const pdfdoc_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
14
+ export const pdfdoc_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
15
+ export const pdfdoc_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
16
+ export const pdfdoc_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
17
+ export const pdfdoc_compress: (a: number, b: number) => void;
18
+ export const pdfdoc_convertToPdfa: (a: number, b: number, c: number, d: number) => void;
19
+ export const pdfdoc_deletePages: (a: number, b: number, c: number, d: number) => void;
20
+ export const pdfdoc_dssInfo: (a: number, b: number) => void;
21
+ export const pdfdoc_extractPages: (a: number, b: number, c: number, d: number) => void;
22
+ export const pdfdoc_flattenXfa: (a: number, b: number) => void;
23
+ export const pdfdoc_getAnnotations: (a: number, b: number, c: number) => void;
24
+ export const pdfdoc_getTextPositions: (a: number, b: number, c: number) => void;
25
+ export const pdfdoc_hasSignatures: (a: number) => number;
26
+ export const pdfdoc_merge: (a: number, b: number, c: number, d: number) => void;
27
+ export const pdfdoc_metadata: (a: number, b: number) => void;
28
+ export const pdfdoc_open: (a: number, b: number, c: number) => void;
29
+ export const pdfdoc_pageCount: (a: number) => number;
30
+ export const pdfdoc_pageHeight: (a: number, b: number) => number;
31
+ export const pdfdoc_pageWidth: (a: number, b: number) => number;
32
+ export const pdfdoc_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
33
+ export const pdfdoc_redactSearch: (a: number, b: number, c: number, d: number) => void;
34
+ export const pdfdoc_refresh: (a: number, b: number, c: number, d: number) => void;
35
+ export const pdfdoc_renderPage: (a: number, b: number, c: number, d: number) => void;
36
+ export const pdfdoc_renderPageToCanvas: (a: number, b: number, c: number, d: number, e: number) => void;
37
+ export const pdfdoc_renderPageToCanvasVector: (a: number, b: number, c: number, d: number, e: number) => void;
38
+ export const pdfdoc_renderThumbnail: (a: number, b: number, c: number, d: number) => void;
39
+ export const pdfdoc_reorderPages: (a: number, b: number, c: number, d: number) => void;
40
+ export const pdfdoc_rotatePage: (a: number, b: number, c: number, d: number) => void;
41
+ export const pdfdoc_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
42
+ export const pdfdoc_setFormFields: (a: number, b: number, c: number, d: number) => void;
43
+ export const pdfdoc_signatures: (a: number, b: number) => void;
44
+ export const pdfdoc_text: (a: number, b: number, c: number) => void;
45
+ export const pdfdoc_validatePdfA: (a: number, b: number, c: number, d: number) => void;
46
+ export const pdfdoc_verifySignatures: (a: number, b: number) => void;
47
+ export const pdfdocmut_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
48
+ export const pdfdocmut_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
49
+ export const pdfdocmut_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
50
+ export const pdfdocmut_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
51
+ export const pdfdocmut_applyTextFormat: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
52
+ export const pdfdocmut_applyTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
53
+ export const pdfdocmut_compress: (a: number, b: number) => void;
54
+ export const pdfdocmut_deletePages: (a: number, b: number, c: number, d: number) => void;
55
+ export const pdfdocmut_extractPages: (a: number, b: number, c: number, d: number) => void;
56
+ export const pdfdocmut_formatTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
57
+ export const pdfdocmut_open: (a: number, b: number, c: number) => void;
58
+ export const pdfdocmut_pageCount: (a: number) => number;
59
+ export const pdfdocmut_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
60
+ export const pdfdocmut_redactSearch: (a: number, b: number, c: number, d: number) => void;
61
+ export const pdfdocmut_reorderPages: (a: number, b: number, c: number, d: number) => void;
62
+ export const pdfdocmut_replaceTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
63
+ export const pdfdocmut_rotatePage: (a: number, b: number, c: number, d: number) => void;
64
+ export const pdfdocmut_save: (a: number, b: number) => void;
65
+ export const pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
66
+ export const pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
67
+ export const pdfdocmut_setMultiSelect: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
68
+ export const pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
69
+ export const setLicensePayload: (a: number, b: number, c: number) => void;
70
+ export const setLicensePublicKey: (a: number, b: number, c: number) => void;
71
+ export const xfaengine_exportJson: (a: number, b: number) => void;
72
+ export const xfaengine_exportSchema: (a: number, b: number) => void;
73
+ export const xfaengine_fromFields: (a: number, b: number, c: number) => void;
74
+ export const xfaengine_fromJson: (a: number, b: number, c: number) => void;
75
+ export const xfaengine_getFieldValue: (a: number, b: number, c: number, d: number) => void;
76
+ export const xfaengine_importJson: (a: number, b: number, c: number, d: number) => void;
77
+ export const xfaengine_nodeCount: (a: number) => number;
78
+ export const xfaengine_runCalculations: (a: number, b: number) => void;
79
+ export const xfaengine_setFieldValue: (a: number, b: number, c: number, d: number, e: number) => number;
80
+ export const xfaengine_version: (a: number) => void;
81
+ export const __wbindgen_export: (a: number, b: number) => number;
82
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
83
+ export const __wbindgen_export3: (a: number) => void;
84
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
85
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;