@pdfluent/sdk-wasm 1.0.0-beta.11 → 1.0.0-beta.8

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
@@ -4,9 +4,10 @@ WebAssembly distribution of the PDFluent PDF engine. Read, edit, annotate,
4
4
  redact, sign, and validate PDFs (including XFA) entirely in the browser —
5
5
  zero bytes go to a server.
6
6
 
7
- Published as `@pdfluent/xfa-wasm` on npm. (Crate name reflects historical
8
- XFA roots; the package now covers the full SDK surface needed for an
9
- in-browser PDF editor.)
7
+ Published as `@pdfluent/sdk-wasm` on npm. (The crate directory is named
8
+ `xfa-wasm` for historical XFA roots — the published npm package covers the
9
+ full SDK surface needed for an in-browser PDF editor. Previously known as
10
+ `@pdfluent/xfa-wasm`; renamed to `@pdfluent/sdk-wasm`.)
10
11
 
11
12
  ## Features
12
13
 
@@ -31,10 +32,10 @@ in-browser PDF editor.)
31
32
  cargo install wasm-pack
32
33
 
33
34
  # Build the WASM package
34
- wasm-pack build crates/@pdfluent/wasm --target web
35
+ wasm-pack build crates/xfa-wasm --target web
35
36
 
36
37
  # Without rendering (smaller bundle)
37
- wasm-pack build crates/@pdfluent/wasm --target web -- --no-default-features
38
+ wasm-pack build crates/xfa-wasm --target web -- --no-default-features
38
39
  ```
39
40
 
40
41
  ## Quick Start
@@ -148,7 +149,7 @@ const data = forms.exportJson();
148
149
  Build without optional features for a smaller WASM binary:
149
150
 
150
151
  ```bash
151
- wasm-pack build crates/@pdfluent/wasm --target web -- --no-default-features
152
+ wasm-pack build crates/xfa-wasm --target web -- --no-default-features
152
153
  ```
153
154
 
154
155
  ## API Reference
@@ -175,7 +176,7 @@ is marked via `/Producer` metadata in Trial. Activate a license to remove
175
176
  the mark and unlock paid capabilities.
176
177
 
177
178
  ```js
178
- import init, { activateLicenseKey, licenseStatus } from '@pdfluent/xfa-wasm';
179
+ import init, { activateLicenseKey, licenseStatus } from '@pdfluent/sdk-wasm';
179
180
 
180
181
  await init();
181
182
  activateLicenseKey('tier:enterprise');
@@ -278,7 +279,7 @@ operations to the same document, **`PdfDocMut` is dramatically faster**:
278
279
  #### Editor flow with PdfDocMut
279
280
 
280
281
  ```js
281
- import init, { PdfDocMut } from '@pdfluent/xfa-wasm';
282
+ import init, { PdfDocMut } from '@pdfluent/sdk-wasm';
282
283
 
283
284
  await init();
284
285
  const bytes = new Uint8Array(await (await fetch('/document.pdf')).arrayBuffer());
@@ -304,7 +305,7 @@ are equally fine. They are kept for backward compatibility but the
304
305
  recommended path for any multi-step edit is `PdfDocMut`.
305
306
 
306
307
  ```js
307
- import init, { PdfDoc } from '@pdfluent/xfa-wasm';
308
+ import init, { PdfDoc } from '@pdfluent/sdk-wasm';
308
309
  await init();
309
310
  const doc = PdfDoc.open(bytes);
310
311
  const merged = doc.merge(otherBytes); // single op, one-shot
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.11",
5
+ "version": "1.0.0-beta.8",
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
@@ -49,6 +49,33 @@ export class LicenseStatus {
49
49
  *
50
50
  * Uses `pdf-syntax` for metadata/geometry/signatures/compliance and
51
51
  * `pdf-engine` for text extraction so the WASM path matches native decoding.
52
+ *
53
+ * # Memory lifecycle
54
+ *
55
+ * `PdfDoc` holds native WASM memory. Call [`PdfDoc.free()`] when done,
56
+ * or use the `using` keyword (TypeScript 5.2+):
57
+ *
58
+ * ```js
59
+ * using doc = PdfDoc.open(bytes);
60
+ * // doc.free() is called automatically at end of block
61
+ * ```
62
+ *
63
+ * After `free()`, all method calls throw. Do not hold references across `free()`.
64
+ *
65
+ * # Errors
66
+ *
67
+ * All fallible methods throw a `PdfluentError` — a standard `Error` subclass with
68
+ * these properties:
69
+ * - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
70
+ * (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
71
+ * - `message`: human-readable description (stable for backwards compatibility).
72
+ * - `operation`: short identifier of the API call that failed.
73
+ * - `help`: optional actionable hint (may be empty string).
74
+ * - `docsUrl`: deep-link into `https://pdfluent.com/errors/<code>`.
75
+ * - `legacyCode`: the original SCREAMING_SNAKE_CASE identifier from the
76
+ * pre-1.0 WASM binding, preserved so older user code keeps working.
77
+ *
78
+ * JavaScript callers can use `error instanceof PdfluentError` to discriminate.
52
79
  */
53
80
  export class PdfDoc {
54
81
  private constructor();
@@ -121,8 +148,30 @@ export class PdfDoc {
121
148
  *
122
149
  * ```js
123
150
  * const runs = JSON.parse(doc.getTextPositions(0));
124
- * // runs[i] = { text: "Hello world", x: 72.0, y: 100.0, width: 96.0, height: 12.0, fontSize: 12.0 }
151
+ * // runs[i] = {
152
+ * // text: "Hello world",
153
+ * // x: 72.0, y: 100.0, width: 96.0, height: 12.0, fontSize: 12.0,
154
+ * // fontName: "Helvetica-Bold", // G1: stable presence; null when unknown
155
+ * // isBold: true, isItalic: false,
156
+ * // color: [0, 0, 0, 255], // G1: omitted when unknown
157
+ * // widthSource: "Metric", // G2: "Metric" | "Estimate"
158
+ * // charBounds: [[72,100,80,112], …] // G2: per-glyph bounds (omitted when empty)
159
+ * // }
125
160
  * ```
161
+ *
162
+ * `fontName` is always present in the JSON: a known PostScript
163
+ * name (embedded font, or resolved standard-14 fallback for
164
+ * non-embedded Type1) emits a string; an unknown name (Type3
165
+ * glyphs, embedded Type1 without a standard-font fallback)
166
+ * emits `null`. This stable presence matches the editor
167
+ * contract; the editor can call `run.fontName ?? "Unknown"`
168
+ * or do `'fontName' in run` tests without conditional logic.
169
+ *
170
+ * `color` is still omitted from the JSON when the source paint
171
+ * is a pattern/shading or the color space could not be
172
+ * resolved. `isBold`/`isItalic` are always present so editor
173
+ * toolbars can render unconditionally. `widthSource` is always
174
+ * present; `charBounds` is omitted only when the span is empty.
126
175
  */
127
176
  getTextPositions(page_index: number): string;
128
177
  /**
@@ -277,6 +326,16 @@ export class PdfDocMut {
277
326
  * Apply a diagonal text watermark to every page.
278
327
  */
279
328
  addTextWatermark(text: string, opacity: number): void;
329
+ /**
330
+ * Convenience: open bytes, format a single run, return new bytes.
331
+ *
332
+ * One-shot equivalent of `open → formatTextSpan → save`.
333
+ */
334
+ static applyTextFormat(data: Uint8Array, page_num: number, run_index: number, font_size?: number | null, color?: string | null): Uint8Array;
335
+ /**
336
+ * Convenience: open bytes, apply style, return new bytes.
337
+ */
338
+ static applyTextRunStyle(data: Uint8Array, page_num: number, run_index: number, bold?: boolean | null, italic?: boolean | null): Uint8Array;
280
339
  /**
281
340
  * Re-encode content streams with deflate compression.
282
341
  */
@@ -293,6 +352,26 @@ export class PdfDocMut {
293
352
  * set of pages and a subset is exported.
294
353
  */
295
354
  extractPages(pages: Uint32Array): Uint8Array;
355
+ /**
356
+ * Format a single text run on `page_num` (1-based) by changing its font
357
+ * size and/or fill color. The mutation is scoped so other runs on the
358
+ * page are unaffected (q…Q isolation injected as needed).
359
+ *
360
+ * Parameters:
361
+ * - `page_num`: 1-based page index.
362
+ * - `run_index`: 0-based index into `extract_page_text_runs(page_num)`.
363
+ * - `font_size`: optional new font size (points). Pass `None` to keep.
364
+ * - `color`: optional hex color string (e.g. `"#FF0000"`); pass `None`
365
+ * to keep the existing fill color.
366
+ *
367
+ * Returns a JSON string with the canonical `FormatResult` shape:
368
+ * `{ "formatted": bool, "bytesChanged": usize, "isolationStrategy": str,
369
+ * "originalSize": f32?, "originalColor": [f32; 3]?, "code": str? }`.
370
+ *
371
+ * Passing both `font_size = None` and `color = None` is a no-op:
372
+ * `formatted = false`, `bytesChanged = 0`, no error.
373
+ */
374
+ formatTextSpan(page_num: number, run_index: number, font_size?: number | null, color?: string | null): string;
296
375
  /**
297
376
  * Open a PDF for editing.
298
377
  */
@@ -314,6 +393,50 @@ export class PdfDocMut {
314
393
  * Re-order pages. `new_order` is a permutation of `0..page_count`.
315
394
  */
316
395
  reorderPages(new_order: Uint32Array): void;
396
+ /**
397
+ * G3 — Replace a text span on a page.
398
+ *
399
+ * The editor passes the **exact** text it extracted from
400
+ * `getTextPositions()` as `original_text`, and the desired
401
+ * replacement as `replacement_text`. The replacement is
402
+ * re-encoded into the same font used by the matched span
403
+ * (subset-font fallback applies when the original font cannot
404
+ * encode the replacement — see
405
+ * `pdf-manip::text_replace::replace_text`).
406
+ *
407
+ * `page_num` is **1-based** to match the rest of the
408
+ * `pdf-manip` surface (and the existing `formatTextSpan` /
409
+ * `setTextRunStyle` methods on this handle).
410
+ *
411
+ * Returns a JSON string with the following shape:
412
+ *
413
+ * ```jsonc
414
+ * {
415
+ * "replaced": false,
416
+ * "code": "NO_MATCH", // only when replaced=false
417
+ * "reason": "originalText …", // only when replaced=false
418
+ * "byteLengthBefore": 12345, // only when replaced=true
419
+ * "byteLengthAfter": 12378 // only when replaced=true
420
+ * }
421
+ * ```
422
+ *
423
+ * Typed unsupported codes (all set `replaced=false`):
424
+ *
425
+ * - `"NO_MATCH"` — `original_text` not found on the page.
426
+ * - `"ENCODING_UNSUPPORTED"` — replacement contains characters
427
+ * the matched font cannot encode and no fallback font is
428
+ * available.
429
+ * - `"REPLACE_FAILED"` — anything else (lopdf I/O,
430
+ * serialisation, FontMap construction, …). `reason` carries
431
+ * the lower-level error message.
432
+ *
433
+ * Layout is preserved within the existing run: same font,
434
+ * same baseline, same `Tj`/`TJ` operator boundaries. Cross-run
435
+ * matches (where the search text is split across multiple
436
+ * content-stream operators) are handled by the underlying
437
+ * `replace_text` cross-run path.
438
+ */
439
+ replaceTextSpan(page_num: number, original_text: string, replacement_text: string): string;
317
440
  /**
318
441
  * Rotate a single page by 90/180/270 (or negative). Multiples of 90 only.
319
442
  */
@@ -340,12 +463,43 @@ export class PdfDocMut {
340
463
  * `{"field.path": "value", ...}`.
341
464
  */
342
465
  setFormFields(fields_json: string): void;
466
+ /**
467
+ * Apply bold/italic style to a text run on `page_num` (1-based).
468
+ */
469
+ setTextRunStyle(page_num: number, runs_json: string, run_index: number, bold?: boolean | null, italic?: boolean | null): string;
343
470
  }
344
471
 
345
472
  /**
346
473
  * The main XFA processing engine for WASM.
347
474
  *
348
475
  * Holds a parsed FormTree and provides methods to extract/import data.
476
+ *
477
+ * # Memory lifecycle
478
+ *
479
+ * `XfaEngine` holds native WASM memory. Call [`XfaEngine.free()`] when done,
480
+ * or use the `using` keyword (TypeScript 5.2+, TC39 Explicit Resource Management):
481
+ *
482
+ * ```js
483
+ * using engine = XfaEngine.fromFields(fields);
484
+ * // engine.free() is called automatically at end of block
485
+ * ```
486
+ *
487
+ * After `free()`, all method calls throw. Do not keep references across blocks.
488
+ *
489
+ * # Errors
490
+ *
491
+ * All fallible methods throw a `PdfluentError` — a standard `Error` subclass with
492
+ * these properties:
493
+ * - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
494
+ * (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
495
+ * - `message`: human-readable description (stable for backwards compatibility).
496
+ * - `operation`: short identifier of the API call that failed.
497
+ * - `help`: optional actionable hint (may be empty string).
498
+ * - `docsUrl`: deep-link into `https://pdfluent.com/errors/<code>`.
499
+ * - `legacyCode`: the original SCREAMING_SNAKE_CASE identifier from the
500
+ * pre-1.0 WASM binding, preserved so older user code keeps working.
501
+ *
502
+ * JavaScript callers can use `error instanceof PdfluentError` to discriminate.
349
503
  */
350
504
  export class XfaEngine {
351
505
  private constructor();
@@ -474,18 +628,23 @@ export interface InitOutput {
474
628
  readonly pdfdocmut_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
475
629
  readonly pdfdocmut_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
476
630
  readonly pdfdocmut_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
631
+ readonly pdfdocmut_applyTextFormat: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
632
+ readonly pdfdocmut_applyTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
477
633
  readonly pdfdocmut_compress: (a: number, b: number) => void;
478
634
  readonly pdfdocmut_deletePages: (a: number, b: number, c: number, d: number) => void;
479
635
  readonly pdfdocmut_extractPages: (a: number, b: number, c: number, d: number) => void;
636
+ readonly pdfdocmut_formatTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
480
637
  readonly pdfdocmut_open: (a: number, b: number, c: number) => void;
481
638
  readonly pdfdocmut_pageCount: (a: number) => number;
482
639
  readonly pdfdocmut_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
483
640
  readonly pdfdocmut_redactSearch: (a: number, b: number, c: number, d: number) => void;
484
641
  readonly pdfdocmut_reorderPages: (a: number, b: number, c: number, d: number) => void;
642
+ readonly pdfdocmut_replaceTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
485
643
  readonly pdfdocmut_rotatePage: (a: number, b: number, c: number, d: number) => void;
486
644
  readonly pdfdocmut_save: (a: number, b: number) => void;
487
645
  readonly pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
488
646
  readonly pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
647
+ readonly pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
489
648
  readonly xfaengine_exportJson: (a: number, b: number) => void;
490
649
  readonly xfaengine_exportSchema: (a: number, b: number) => void;
491
650
  readonly xfaengine_fromFields: (a: number, b: number, c: number) => void;
package/xfa_wasm.js CHANGED
@@ -1,4 +1,6 @@
1
1
  /* @ts-self-types="./xfa_wasm.d.ts" */
2
+ import { __pdfluent_error_ctor } from './snippets/xfa-wasm-312742e1abcfad9e/inline0.js';
3
+
2
4
 
3
5
  /**
4
6
  * Chroma subsampling format
@@ -28,7 +30,6 @@ export const ChromaSampling = Object.freeze({
28
30
  */
29
31
  export class LicenseStatus {
30
32
  static __wrap(ptr) {
31
- ptr = ptr >>> 0;
32
33
  const obj = Object.create(LicenseStatus.prototype);
33
34
  obj.__wbg_ptr = ptr;
34
35
  LicenseStatusFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -100,10 +101,36 @@ if (Symbol.dispose) LicenseStatus.prototype[Symbol.dispose] = LicenseStatus.prot
100
101
  *
101
102
  * Uses `pdf-syntax` for metadata/geometry/signatures/compliance and
102
103
  * `pdf-engine` for text extraction so the WASM path matches native decoding.
104
+ *
105
+ * # Memory lifecycle
106
+ *
107
+ * `PdfDoc` holds native WASM memory. Call [`PdfDoc.free()`] when done,
108
+ * or use the `using` keyword (TypeScript 5.2+):
109
+ *
110
+ * ```js
111
+ * using doc = PdfDoc.open(bytes);
112
+ * // doc.free() is called automatically at end of block
113
+ * ```
114
+ *
115
+ * After `free()`, all method calls throw. Do not hold references across `free()`.
116
+ *
117
+ * # Errors
118
+ *
119
+ * All fallible methods throw a `PdfluentError` — a standard `Error` subclass with
120
+ * these properties:
121
+ * - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
122
+ * (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
123
+ * - `message`: human-readable description (stable for backwards compatibility).
124
+ * - `operation`: short identifier of the API call that failed.
125
+ * - `help`: optional actionable hint (may be empty string).
126
+ * - `docsUrl`: deep-link into `https://pdfluent.com/errors/<code>`.
127
+ * - `legacyCode`: the original SCREAMING_SNAKE_CASE identifier from the
128
+ * pre-1.0 WASM binding, preserved so older user code keeps working.
129
+ *
130
+ * JavaScript callers can use `error instanceof PdfluentError` to discriminate.
103
131
  */
104
132
  export class PdfDoc {
105
133
  static __wrap(ptr) {
106
- ptr = ptr >>> 0;
107
134
  const obj = Object.create(PdfDoc.prototype);
108
135
  obj.__wbg_ptr = ptr;
109
136
  PdfDocFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -424,8 +451,30 @@ export class PdfDoc {
424
451
  *
425
452
  * ```js
426
453
  * const runs = JSON.parse(doc.getTextPositions(0));
427
- * // runs[i] = { text: "Hello world", x: 72.0, y: 100.0, width: 96.0, height: 12.0, fontSize: 12.0 }
454
+ * // runs[i] = {
455
+ * // text: "Hello world",
456
+ * // x: 72.0, y: 100.0, width: 96.0, height: 12.0, fontSize: 12.0,
457
+ * // fontName: "Helvetica-Bold", // G1: stable presence; null when unknown
458
+ * // isBold: true, isItalic: false,
459
+ * // color: [0, 0, 0, 255], // G1: omitted when unknown
460
+ * // widthSource: "Metric", // G2: "Metric" | "Estimate"
461
+ * // charBounds: [[72,100,80,112], …] // G2: per-glyph bounds (omitted when empty)
462
+ * // }
428
463
  * ```
464
+ *
465
+ * `fontName` is always present in the JSON: a known PostScript
466
+ * name (embedded font, or resolved standard-14 fallback for
467
+ * non-embedded Type1) emits a string; an unknown name (Type3
468
+ * glyphs, embedded Type1 without a standard-font fallback)
469
+ * emits `null`. This stable presence matches the editor
470
+ * contract; the editor can call `run.fontName ?? "Unknown"`
471
+ * or do `'fontName' in run` tests without conditional logic.
472
+ *
473
+ * `color` is still omitted from the JSON when the source paint
474
+ * is a pattern/shading or the color space could not be
475
+ * resolved. `isBold`/`isItalic` are always present so editor
476
+ * toolbars can render unconditionally. `widthSource` is always
477
+ * present; `charBounds` is omitted only when the span is empty.
429
478
  * @param {number} page_index
430
479
  * @returns {string}
431
480
  */
@@ -938,7 +987,6 @@ if (Symbol.dispose) PdfDoc.prototype[Symbol.dispose] = PdfDoc.prototype.free;
938
987
  */
939
988
  export class PdfDocMut {
940
989
  static __wrap(ptr) {
941
- ptr = ptr >>> 0;
942
990
  const obj = Object.create(PdfDocMut.prototype);
943
991
  obj.__wbg_ptr = ptr;
944
992
  PdfDocMutFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -1045,6 +1093,68 @@ export class PdfDocMut {
1045
1093
  wasm.__wbindgen_add_to_stack_pointer(16);
1046
1094
  }
1047
1095
  }
1096
+ /**
1097
+ * Convenience: open bytes, format a single run, return new bytes.
1098
+ *
1099
+ * One-shot equivalent of `open → formatTextSpan → save`.
1100
+ * @param {Uint8Array} data
1101
+ * @param {number} page_num
1102
+ * @param {number} run_index
1103
+ * @param {number | null} [font_size]
1104
+ * @param {string | null} [color]
1105
+ * @returns {Uint8Array}
1106
+ */
1107
+ static applyTextFormat(data, page_num, run_index, font_size, color) {
1108
+ try {
1109
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1110
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1111
+ const len0 = WASM_VECTOR_LEN;
1112
+ var ptr1 = isLikeNone(color) ? 0 : passStringToWasm0(color, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1113
+ var len1 = WASM_VECTOR_LEN;
1114
+ wasm.pdfdocmut_applyTextFormat(retptr, ptr0, len0, page_num, run_index, isLikeNone(font_size) ? Number.MAX_SAFE_INTEGER : Math.fround(font_size), ptr1, len1);
1115
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1116
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1117
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1118
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1119
+ if (r3) {
1120
+ throw takeObject(r2);
1121
+ }
1122
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
1123
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1124
+ return v3;
1125
+ } finally {
1126
+ wasm.__wbindgen_add_to_stack_pointer(16);
1127
+ }
1128
+ }
1129
+ /**
1130
+ * Convenience: open bytes, apply style, return new bytes.
1131
+ * @param {Uint8Array} data
1132
+ * @param {number} page_num
1133
+ * @param {number} run_index
1134
+ * @param {boolean | null} [bold]
1135
+ * @param {boolean | null} [italic]
1136
+ * @returns {Uint8Array}
1137
+ */
1138
+ static applyTextRunStyle(data, page_num, run_index, bold, italic) {
1139
+ try {
1140
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1141
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1142
+ const len0 = WASM_VECTOR_LEN;
1143
+ wasm.pdfdocmut_applyTextRunStyle(retptr, ptr0, len0, page_num, run_index, isLikeNone(bold) ? 0xFFFFFF : bold ? 1 : 0, isLikeNone(italic) ? 0xFFFFFF : italic ? 1 : 0);
1144
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1145
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1146
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1147
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1148
+ if (r3) {
1149
+ throw takeObject(r2);
1150
+ }
1151
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1152
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1153
+ return v2;
1154
+ } finally {
1155
+ wasm.__wbindgen_add_to_stack_pointer(16);
1156
+ }
1157
+ }
1048
1158
  /**
1049
1159
  * Re-encode content streams with deflate compression.
1050
1160
  */
@@ -1109,6 +1219,56 @@ export class PdfDocMut {
1109
1219
  wasm.__wbindgen_add_to_stack_pointer(16);
1110
1220
  }
1111
1221
  }
1222
+ /**
1223
+ * Format a single text run on `page_num` (1-based) by changing its font
1224
+ * size and/or fill color. The mutation is scoped so other runs on the
1225
+ * page are unaffected (q…Q isolation injected as needed).
1226
+ *
1227
+ * Parameters:
1228
+ * - `page_num`: 1-based page index.
1229
+ * - `run_index`: 0-based index into `extract_page_text_runs(page_num)`.
1230
+ * - `font_size`: optional new font size (points). Pass `None` to keep.
1231
+ * - `color`: optional hex color string (e.g. `"#FF0000"`); pass `None`
1232
+ * to keep the existing fill color.
1233
+ *
1234
+ * Returns a JSON string with the canonical `FormatResult` shape:
1235
+ * `{ "formatted": bool, "bytesChanged": usize, "isolationStrategy": str,
1236
+ * "originalSize": f32?, "originalColor": [f32; 3]?, "code": str? }`.
1237
+ *
1238
+ * Passing both `font_size = None` and `color = None` is a no-op:
1239
+ * `formatted = false`, `bytesChanged = 0`, no error.
1240
+ * @param {number} page_num
1241
+ * @param {number} run_index
1242
+ * @param {number | null} [font_size]
1243
+ * @param {string | null} [color]
1244
+ * @returns {string}
1245
+ */
1246
+ formatTextSpan(page_num, run_index, font_size, color) {
1247
+ let deferred3_0;
1248
+ let deferred3_1;
1249
+ try {
1250
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1251
+ var ptr0 = isLikeNone(color) ? 0 : passStringToWasm0(color, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1252
+ var len0 = WASM_VECTOR_LEN;
1253
+ wasm.pdfdocmut_formatTextSpan(retptr, this.__wbg_ptr, page_num, run_index, isLikeNone(font_size) ? Number.MAX_SAFE_INTEGER : Math.fround(font_size), ptr0, len0);
1254
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1255
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1256
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1257
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1258
+ var ptr2 = r0;
1259
+ var len2 = r1;
1260
+ if (r3) {
1261
+ ptr2 = 0; len2 = 0;
1262
+ throw takeObject(r2);
1263
+ }
1264
+ deferred3_0 = ptr2;
1265
+ deferred3_1 = len2;
1266
+ return getStringFromWasm0(ptr2, len2);
1267
+ } finally {
1268
+ wasm.__wbindgen_add_to_stack_pointer(16);
1269
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1270
+ }
1271
+ }
1112
1272
  /**
1113
1273
  * Open a PDF for editing.
1114
1274
  * @param {Uint8Array} bytes
@@ -1199,6 +1359,81 @@ export class PdfDocMut {
1199
1359
  wasm.__wbindgen_add_to_stack_pointer(16);
1200
1360
  }
1201
1361
  }
1362
+ /**
1363
+ * G3 — Replace a text span on a page.
1364
+ *
1365
+ * The editor passes the **exact** text it extracted from
1366
+ * `getTextPositions()` as `original_text`, and the desired
1367
+ * replacement as `replacement_text`. The replacement is
1368
+ * re-encoded into the same font used by the matched span
1369
+ * (subset-font fallback applies when the original font cannot
1370
+ * encode the replacement — see
1371
+ * `pdf-manip::text_replace::replace_text`).
1372
+ *
1373
+ * `page_num` is **1-based** to match the rest of the
1374
+ * `pdf-manip` surface (and the existing `formatTextSpan` /
1375
+ * `setTextRunStyle` methods on this handle).
1376
+ *
1377
+ * Returns a JSON string with the following shape:
1378
+ *
1379
+ * ```jsonc
1380
+ * {
1381
+ * "replaced": false,
1382
+ * "code": "NO_MATCH", // only when replaced=false
1383
+ * "reason": "originalText …", // only when replaced=false
1384
+ * "byteLengthBefore": 12345, // only when replaced=true
1385
+ * "byteLengthAfter": 12378 // only when replaced=true
1386
+ * }
1387
+ * ```
1388
+ *
1389
+ * Typed unsupported codes (all set `replaced=false`):
1390
+ *
1391
+ * - `"NO_MATCH"` — `original_text` not found on the page.
1392
+ * - `"ENCODING_UNSUPPORTED"` — replacement contains characters
1393
+ * the matched font cannot encode and no fallback font is
1394
+ * available.
1395
+ * - `"REPLACE_FAILED"` — anything else (lopdf I/O,
1396
+ * serialisation, FontMap construction, …). `reason` carries
1397
+ * the lower-level error message.
1398
+ *
1399
+ * Layout is preserved within the existing run: same font,
1400
+ * same baseline, same `Tj`/`TJ` operator boundaries. Cross-run
1401
+ * matches (where the search text is split across multiple
1402
+ * content-stream operators) are handled by the underlying
1403
+ * `replace_text` cross-run path.
1404
+ * @param {number} page_num
1405
+ * @param {string} original_text
1406
+ * @param {string} replacement_text
1407
+ * @returns {string}
1408
+ */
1409
+ replaceTextSpan(page_num, original_text, replacement_text) {
1410
+ let deferred4_0;
1411
+ let deferred4_1;
1412
+ try {
1413
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1414
+ const ptr0 = passStringToWasm0(original_text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1415
+ const len0 = WASM_VECTOR_LEN;
1416
+ const ptr1 = passStringToWasm0(replacement_text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1417
+ const len1 = WASM_VECTOR_LEN;
1418
+ wasm.pdfdocmut_replaceTextSpan(retptr, this.__wbg_ptr, page_num, ptr0, len0, ptr1, len1);
1419
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1420
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1421
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1422
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1423
+ var ptr3 = r0;
1424
+ var len3 = r1;
1425
+ if (r3) {
1426
+ ptr3 = 0; len3 = 0;
1427
+ throw takeObject(r2);
1428
+ }
1429
+ deferred4_0 = ptr3;
1430
+ deferred4_1 = len3;
1431
+ return getStringFromWasm0(ptr3, len3);
1432
+ } finally {
1433
+ wasm.__wbindgen_add_to_stack_pointer(16);
1434
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
1435
+ }
1436
+ }
1202
1437
  /**
1203
1438
  * Rotate a single page by 90/180/270 (or negative). Multiples of 90 only.
1204
1439
  * @param {number} page_index
@@ -1290,6 +1525,41 @@ export class PdfDocMut {
1290
1525
  wasm.__wbindgen_add_to_stack_pointer(16);
1291
1526
  }
1292
1527
  }
1528
+ /**
1529
+ * Apply bold/italic style to a text run on `page_num` (1-based).
1530
+ * @param {number} page_num
1531
+ * @param {string} runs_json
1532
+ * @param {number} run_index
1533
+ * @param {boolean | null} [bold]
1534
+ * @param {boolean | null} [italic]
1535
+ * @returns {string}
1536
+ */
1537
+ setTextRunStyle(page_num, runs_json, run_index, bold, italic) {
1538
+ let deferred3_0;
1539
+ let deferred3_1;
1540
+ try {
1541
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1542
+ const ptr0 = passStringToWasm0(runs_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1543
+ const len0 = WASM_VECTOR_LEN;
1544
+ wasm.pdfdocmut_setTextRunStyle(retptr, this.__wbg_ptr, page_num, ptr0, len0, run_index, isLikeNone(bold) ? 0xFFFFFF : bold ? 1 : 0, isLikeNone(italic) ? 0xFFFFFF : italic ? 1 : 0);
1545
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1546
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1547
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1548
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1549
+ var ptr2 = r0;
1550
+ var len2 = r1;
1551
+ if (r3) {
1552
+ ptr2 = 0; len2 = 0;
1553
+ throw takeObject(r2);
1554
+ }
1555
+ deferred3_0 = ptr2;
1556
+ deferred3_1 = len2;
1557
+ return getStringFromWasm0(ptr2, len2);
1558
+ } finally {
1559
+ wasm.__wbindgen_add_to_stack_pointer(16);
1560
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1561
+ }
1562
+ }
1293
1563
  }
1294
1564
  if (Symbol.dispose) PdfDocMut.prototype[Symbol.dispose] = PdfDocMut.prototype.free;
1295
1565
 
@@ -1297,10 +1567,36 @@ if (Symbol.dispose) PdfDocMut.prototype[Symbol.dispose] = PdfDocMut.prototype.fr
1297
1567
  * The main XFA processing engine for WASM.
1298
1568
  *
1299
1569
  * Holds a parsed FormTree and provides methods to extract/import data.
1570
+ *
1571
+ * # Memory lifecycle
1572
+ *
1573
+ * `XfaEngine` holds native WASM memory. Call [`XfaEngine.free()`] when done,
1574
+ * or use the `using` keyword (TypeScript 5.2+, TC39 Explicit Resource Management):
1575
+ *
1576
+ * ```js
1577
+ * using engine = XfaEngine.fromFields(fields);
1578
+ * // engine.free() is called automatically at end of block
1579
+ * ```
1580
+ *
1581
+ * After `free()`, all method calls throw. Do not keep references across blocks.
1582
+ *
1583
+ * # Errors
1584
+ *
1585
+ * All fallible methods throw a `PdfluentError` — a standard `Error` subclass with
1586
+ * these properties:
1587
+ * - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
1588
+ * (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
1589
+ * - `message`: human-readable description (stable for backwards compatibility).
1590
+ * - `operation`: short identifier of the API call that failed.
1591
+ * - `help`: optional actionable hint (may be empty string).
1592
+ * - `docsUrl`: deep-link into `https://pdfluent.com/errors/<code>`.
1593
+ * - `legacyCode`: the original SCREAMING_SNAKE_CASE identifier from the
1594
+ * pre-1.0 WASM binding, preserved so older user code keeps working.
1595
+ *
1596
+ * JavaScript callers can use `error instanceof PdfluentError` to discriminate.
1300
1597
  */
1301
1598
  export class XfaEngine {
1302
1599
  static __wrap(ptr) {
1303
- ptr = ptr >>> 0;
1304
1600
  const obj = Object.create(XfaEngine.prototype);
1305
1601
  obj.__wbg_ptr = ptr;
1306
1602
  XfaEngineFinalization.register(obj, obj.__wbg_ptr, obj);
@@ -1568,56 +1864,67 @@ export function licenseStatus() {
1568
1864
  const ret = wasm.licenseStatus();
1569
1865
  return LicenseStatus.__wrap(ret);
1570
1866
  }
1571
-
1572
1867
  function __wbg_get_imports() {
1573
1868
  const import0 = {
1574
1869
  __proto__: null,
1575
- __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
1870
+ __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
1576
1871
  const ret = Error(getStringFromWasm0(arg0, arg1));
1577
1872
  return addHeapObject(ret);
1578
1873
  },
1579
- __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
1874
+ __wbg___pdfluent_error_ctor_eea54aa1c0fd64d9: function() {
1875
+ const ret = __pdfluent_error_ctor();
1876
+ return addHeapObject(ret);
1877
+ },
1878
+ __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
1580
1879
  const ret = debugString(getObject(arg1));
1581
1880
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1582
1881
  const len1 = WASM_VECTOR_LEN;
1583
1882
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1584
1883
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1585
1884
  },
1586
- __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
1885
+ __wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {
1886
+ const ret = typeof(getObject(arg0)) === 'function';
1887
+ return ret;
1888
+ },
1889
+ __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
1587
1890
  throw new Error(getStringFromWasm0(arg0, arg1));
1588
1891
  },
1589
- __wbg_beginPath_596efed55075dbc3: function(arg0) {
1892
+ __wbg_beginPath_0362b3134ed67152: function(arg0) {
1590
1893
  getObject(arg0).beginPath();
1591
1894
  },
1592
- __wbg_bezierCurveTo_ee956cad5cea25b2: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1895
+ __wbg_bezierCurveTo_2d7f81b72815a6e9: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1593
1896
  getObject(arg0).bezierCurveTo(arg1, arg2, arg3, arg4, arg5, arg6);
1594
1897
  },
1595
- __wbg_clearRect_ea4f3d34d76f4bc5: function(arg0, arg1, arg2, arg3, arg4) {
1898
+ __wbg_clearRect_1ea64f387215d3b8: function(arg0, arg1, arg2, arg3, arg4) {
1596
1899
  getObject(arg0).clearRect(arg1, arg2, arg3, arg4);
1597
1900
  },
1598
- __wbg_clip_307b93ada960ec4d: function(arg0, arg1) {
1901
+ __wbg_clip_e9791a9cb5940a47: function(arg0, arg1) {
1599
1902
  getObject(arg0).clip(__wbindgen_enum_CanvasWindingRule[arg1]);
1600
1903
  },
1601
- __wbg_closePath_f96bcae0fc7087a9: function(arg0) {
1904
+ __wbg_closePath_ab8775c8f9ce941f: function(arg0) {
1602
1905
  getObject(arg0).closePath();
1603
1906
  },
1604
- __wbg_fillRect_4e5596ca954226e7: function(arg0, arg1, arg2, arg3, arg4) {
1907
+ __wbg_construct_391d7e1e0b4dda3a: function() { return handleError(function (arg0, arg1) {
1908
+ const ret = Reflect.construct(getObject(arg0), getObject(arg1));
1909
+ return addHeapObject(ret);
1910
+ }, arguments); },
1911
+ __wbg_fillRect_4f7134801b257e68: function(arg0, arg1, arg2, arg3, arg4) {
1605
1912
  getObject(arg0).fillRect(arg1, arg2, arg3, arg4);
1606
1913
  },
1607
- __wbg_fillText_b1722b6179692b85: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1914
+ __wbg_fillText_b32475d6cb52486d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1608
1915
  getObject(arg0).fillText(getStringFromWasm0(arg1, arg2), arg3, arg4);
1609
1916
  }, arguments); },
1610
- __wbg_fill_e228aca002a2bbf7: function(arg0, arg1) {
1917
+ __wbg_fill_b52c5e04a3f6413e: function(arg0, arg1) {
1611
1918
  getObject(arg0).fill(__wbindgen_enum_CanvasWindingRule[arg1]);
1612
1919
  },
1613
- __wbg_getContext_f04bf8f22dcb2d53: function() { return handleError(function (arg0, arg1, arg2) {
1920
+ __wbg_getContext_e1463ff7aa682d57: function() { return handleError(function (arg0, arg1, arg2) {
1614
1921
  const ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));
1615
1922
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1616
1923
  }, arguments); },
1617
1924
  __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
1618
1925
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1619
1926
  }, arguments); },
1620
- __wbg_instanceof_CanvasRenderingContext2d_08b9d193c22fa886: function(arg0) {
1927
+ __wbg_instanceof_CanvasRenderingContext2d_d4be74cff7165c1e: function(arg0) {
1621
1928
  let result;
1622
1929
  try {
1623
1930
  result = getObject(arg0) instanceof CanvasRenderingContext2D;
@@ -1627,94 +1934,105 @@ function __wbg_get_imports() {
1627
1934
  const ret = result;
1628
1935
  return ret;
1629
1936
  },
1630
- __wbg_lineTo_8ea7db5b5d763030: function(arg0, arg1, arg2) {
1937
+ __wbg_lineTo_72d6b123d28ab168: function(arg0, arg1, arg2) {
1631
1938
  getObject(arg0).lineTo(arg1, arg2);
1632
1939
  },
1633
- __wbg_log_524eedafa26daa59: function(arg0) {
1940
+ __wbg_log_eb752234eec406d1: function(arg0) {
1634
1941
  console.log(getObject(arg0));
1635
1942
  },
1636
- __wbg_moveTo_6d04ca2f71946754: function(arg0, arg1, arg2) {
1943
+ __wbg_moveTo_11bf5a977e6b8610: function(arg0, arg1, arg2) {
1637
1944
  getObject(arg0).moveTo(arg1, arg2);
1638
1945
  },
1639
- __wbg_new_a70fbab9066b301f: function() {
1946
+ __wbg_new_1f236d63ba0c4784: function(arg0, arg1) {
1947
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1948
+ return addHeapObject(ret);
1949
+ },
1950
+ __wbg_new_310879b66b6e95e1: function() {
1640
1951
  const ret = new Array();
1641
1952
  return addHeapObject(ret);
1642
1953
  },
1643
- __wbg_new_with_u8_clamped_array_and_sh_5d9be5b17e50951c: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1954
+ __wbg_new_with_u8_clamped_array_and_sh_13504c3c5394c7c9: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1644
1955
  const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
1645
1956
  return addHeapObject(ret);
1646
1957
  }, arguments); },
1647
- __wbg_push_e87b0e732085a946: function(arg0, arg1) {
1958
+ __wbg_push_b77c476b01548d0a: function(arg0, arg1) {
1648
1959
  const ret = getObject(arg0).push(getObject(arg1));
1649
1960
  return ret;
1650
1961
  },
1651
- __wbg_putImageData_1750176f4dd07174: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1962
+ __wbg_putImageData_947c369295a5768a: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1652
1963
  getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
1653
1964
  }, arguments); },
1654
- __wbg_quadraticCurveTo_79b47836efb75da7: function(arg0, arg1, arg2, arg3, arg4) {
1965
+ __wbg_quadraticCurveTo_5f5e011124b8f464: function(arg0, arg1, arg2, arg3, arg4) {
1655
1966
  getObject(arg0).quadraticCurveTo(arg1, arg2, arg3, arg4);
1656
1967
  },
1657
- __wbg_resetTransform_3e32a3e235bd6a64: function() { return handleError(function (arg0) {
1968
+ __wbg_resetTransform_6f10bc77e166b888: function() { return handleError(function (arg0) {
1658
1969
  getObject(arg0).resetTransform();
1659
1970
  }, arguments); },
1660
- __wbg_restore_ec1ece47cce5dc64: function(arg0) {
1971
+ __wbg_restore_6a7dd2b862e161a3: function(arg0) {
1661
1972
  getObject(arg0).restore();
1662
1973
  },
1663
- __wbg_save_c4e64a4ec29f000f: function(arg0) {
1974
+ __wbg_save_14924e966ab6b8b7: function(arg0) {
1664
1975
  getObject(arg0).save();
1665
1976
  },
1666
- __wbg_setLineDash_b22b8de6051bb23a: function() { return handleError(function (arg0, arg1) {
1977
+ __wbg_setLineDash_52c39bb093201720: function() { return handleError(function (arg0, arg1) {
1667
1978
  getObject(arg0).setLineDash(getObject(arg1));
1668
1979
  }, arguments); },
1669
- __wbg_set_fillStyle_58417b6b548ae475: function(arg0, arg1, arg2) {
1980
+ __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {
1981
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1982
+ return ret;
1983
+ }, arguments); },
1984
+ __wbg_set_fillStyle_ac68c79af375566e: function(arg0, arg1, arg2) {
1670
1985
  getObject(arg0).fillStyle = getStringFromWasm0(arg1, arg2);
1671
1986
  },
1672
- __wbg_set_font_b038797b3573ae5e: function(arg0, arg1, arg2) {
1987
+ __wbg_set_font_7d34a66f4488295e: function(arg0, arg1, arg2) {
1673
1988
  getObject(arg0).font = getStringFromWasm0(arg1, arg2);
1674
1989
  },
1675
- __wbg_set_globalAlpha_d51aa11e10f40cfc: function(arg0, arg1) {
1990
+ __wbg_set_globalAlpha_b733b0d48d14b1c0: function(arg0, arg1) {
1676
1991
  getObject(arg0).globalAlpha = arg1;
1677
1992
  },
1678
- __wbg_set_globalCompositeOperation_ba0da38482e6aa11: function() { return handleError(function (arg0, arg1, arg2) {
1993
+ __wbg_set_globalCompositeOperation_884b1f7507e6f565: function() { return handleError(function (arg0, arg1, arg2) {
1679
1994
  getObject(arg0).globalCompositeOperation = getStringFromWasm0(arg1, arg2);
1680
1995
  }, arguments); },
1681
- __wbg_set_height_b6548a01bdcb689a: function(arg0, arg1) {
1996
+ __wbg_set_height_bdd58e6b04e88cca: function(arg0, arg1) {
1682
1997
  getObject(arg0).height = arg1 >>> 0;
1683
1998
  },
1684
- __wbg_set_lineCap_1ecf6c7ca9319eb2: function(arg0, arg1, arg2) {
1999
+ __wbg_set_lineCap_59e3edc93d8a32b9: function(arg0, arg1, arg2) {
1685
2000
  getObject(arg0).lineCap = getStringFromWasm0(arg1, arg2);
1686
2001
  },
1687
- __wbg_set_lineDashOffset_3dc747fbfd1e7a15: function(arg0, arg1) {
2002
+ __wbg_set_lineDashOffset_6ac8e5b15c55d7f9: function(arg0, arg1) {
1688
2003
  getObject(arg0).lineDashOffset = arg1;
1689
2004
  },
1690
- __wbg_set_lineJoin_2c56d0d6bec26d27: function(arg0, arg1, arg2) {
2005
+ __wbg_set_lineJoin_a3878786eac23080: function(arg0, arg1, arg2) {
1691
2006
  getObject(arg0).lineJoin = getStringFromWasm0(arg1, arg2);
1692
2007
  },
1693
- __wbg_set_lineWidth_e38550ed429ec417: function(arg0, arg1) {
2008
+ __wbg_set_lineWidth_e101692cb4fcf2b8: function(arg0, arg1) {
1694
2009
  getObject(arg0).lineWidth = arg1;
1695
2010
  },
1696
- __wbg_set_miterLimit_59600cb9df94059b: function(arg0, arg1) {
2011
+ __wbg_set_miterLimit_75d5333780d1658c: function(arg0, arg1) {
1697
2012
  getObject(arg0).miterLimit = arg1;
1698
2013
  },
1699
- __wbg_set_strokeStyle_a5baa9565d8b6485: function(arg0, arg1, arg2) {
2014
+ __wbg_set_name_e500733c75ec36b0: function(arg0, arg1, arg2) {
2015
+ getObject(arg0).name = getStringFromWasm0(arg1, arg2);
2016
+ },
2017
+ __wbg_set_strokeStyle_c6ed1f71bc678b73: function(arg0, arg1, arg2) {
1700
2018
  getObject(arg0).strokeStyle = getStringFromWasm0(arg1, arg2);
1701
2019
  },
1702
- __wbg_set_width_c0fcaa2da53cd540: function(arg0, arg1) {
2020
+ __wbg_set_width_25112eb6bf1148df: function(arg0, arg1) {
1703
2021
  getObject(arg0).width = arg1 >>> 0;
1704
2022
  },
1705
- __wbg_strokeRect_2e20ce9870736fad: function(arg0, arg1, arg2, arg3, arg4) {
2023
+ __wbg_strokeRect_3430a0df4158ba67: function(arg0, arg1, arg2, arg3, arg4) {
1706
2024
  getObject(arg0).strokeRect(arg1, arg2, arg3, arg4);
1707
2025
  },
1708
- __wbg_strokeText_9f0af270c9810166: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2026
+ __wbg_strokeText_2ada42e0f9d6c857: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1709
2027
  getObject(arg0).strokeText(getStringFromWasm0(arg1, arg2), arg3, arg4);
1710
2028
  }, arguments); },
1711
- __wbg_stroke_affa71c0888c6f31: function(arg0) {
2029
+ __wbg_stroke_82139a335b371e81: function(arg0) {
1712
2030
  getObject(arg0).stroke();
1713
2031
  },
1714
- __wbg_transform_d9d216c58f699bf9: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
2032
+ __wbg_transform_9f749facb9d7d892: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1715
2033
  getObject(arg0).transform(arg1, arg2, arg3, arg4, arg5, arg6);
1716
2034
  }, arguments); },
1717
- __wbg_warn_69424c2d92a2fa73: function(arg0) {
2035
+ __wbg_warn_c4e0780980765a86: function(arg0) {
1718
2036
  console.warn(getObject(arg0));
1719
2037
  },
1720
2038
  __wbindgen_cast_0000000000000001: function(arg0) {
@@ -1740,16 +2058,16 @@ function __wbg_get_imports() {
1740
2058
  const __wbindgen_enum_CanvasWindingRule = ["nonzero", "evenodd"];
1741
2059
  const LicenseStatusFinalization = (typeof FinalizationRegistry === 'undefined')
1742
2060
  ? { register: () => {}, unregister: () => {} }
1743
- : new FinalizationRegistry(ptr => wasm.__wbg_licensestatus_free(ptr >>> 0, 1));
2061
+ : new FinalizationRegistry(ptr => wasm.__wbg_licensestatus_free(ptr, 1));
1744
2062
  const PdfDocFinalization = (typeof FinalizationRegistry === 'undefined')
1745
2063
  ? { register: () => {}, unregister: () => {} }
1746
- : new FinalizationRegistry(ptr => wasm.__wbg_pdfdoc_free(ptr >>> 0, 1));
2064
+ : new FinalizationRegistry(ptr => wasm.__wbg_pdfdoc_free(ptr, 1));
1747
2065
  const PdfDocMutFinalization = (typeof FinalizationRegistry === 'undefined')
1748
2066
  ? { register: () => {}, unregister: () => {} }
1749
- : new FinalizationRegistry(ptr => wasm.__wbg_pdfdocmut_free(ptr >>> 0, 1));
2067
+ : new FinalizationRegistry(ptr => wasm.__wbg_pdfdocmut_free(ptr, 1));
1750
2068
  const XfaEngineFinalization = (typeof FinalizationRegistry === 'undefined')
1751
2069
  ? { register: () => {}, unregister: () => {} }
1752
- : new FinalizationRegistry(ptr => wasm.__wbg_xfaengine_free(ptr >>> 0, 1));
2070
+ : new FinalizationRegistry(ptr => wasm.__wbg_xfaengine_free(ptr, 1));
1753
2071
 
1754
2072
  function addHeapObject(obj) {
1755
2073
  if (heap_next === heap.length) heap.push(heap.length + 1);
@@ -1856,8 +2174,7 @@ function getDataViewMemory0() {
1856
2174
  }
1857
2175
 
1858
2176
  function getStringFromWasm0(ptr, len) {
1859
- ptr = ptr >>> 0;
1860
- return decodeText(ptr, len);
2177
+ return decodeText(ptr >>> 0, len);
1861
2178
  }
1862
2179
 
1863
2180
  let cachedUint32ArrayMemory0 = null;
@@ -1991,8 +2308,9 @@ if (!('encodeInto' in cachedTextEncoder)) {
1991
2308
 
1992
2309
  let WASM_VECTOR_LEN = 0;
1993
2310
 
1994
- let wasmModule, wasm;
2311
+ let wasmModule, wasmInstance, wasm;
1995
2312
  function __wbg_finalize_init(instance, module) {
2313
+ wasmInstance = instance;
1996
2314
  wasm = instance.exports;
1997
2315
  wasmModule = module;
1998
2316
  cachedDataViewMemory0 = null;
package/xfa_wasm_bg.wasm CHANGED
Binary file
@@ -0,0 +1,81 @@
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_renderPage: (a: number, b: number, c: number, d: number) => void;
35
+ export const pdfdoc_renderPageToCanvas: (a: number, b: number, c: number, d: number, e: number) => void;
36
+ export const pdfdoc_renderPageToCanvasVector: (a: number, b: number, c: number, d: number, e: number) => void;
37
+ export const pdfdoc_renderThumbnail: (a: number, b: number, c: number, d: number) => void;
38
+ export const pdfdoc_reorderPages: (a: number, b: number, c: number, d: number) => void;
39
+ export const pdfdoc_rotatePage: (a: number, b: number, c: number, d: number) => void;
40
+ export const pdfdoc_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
41
+ export const pdfdoc_setFormFields: (a: number, b: number, c: number, d: number) => void;
42
+ export const pdfdoc_signatures: (a: number, b: number) => void;
43
+ export const pdfdoc_text: (a: number, b: number, c: number) => void;
44
+ export const pdfdoc_validatePdfA: (a: number, b: number, c: number, d: number) => void;
45
+ export const pdfdoc_verifySignatures: (a: number, b: number) => void;
46
+ export const pdfdocmut_addFreeText: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
47
+ export const pdfdocmut_addHighlight: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
48
+ export const pdfdocmut_addStickyNote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
49
+ export const pdfdocmut_addTextWatermark: (a: number, b: number, c: number, d: number, e: number) => void;
50
+ export const pdfdocmut_applyTextFormat: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
51
+ export const pdfdocmut_applyTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
52
+ export const pdfdocmut_compress: (a: number, b: number) => void;
53
+ export const pdfdocmut_deletePages: (a: number, b: number, c: number, d: number) => void;
54
+ export const pdfdocmut_extractPages: (a: number, b: number, c: number, d: number) => void;
55
+ export const pdfdocmut_formatTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
56
+ export const pdfdocmut_open: (a: number, b: number, c: number) => void;
57
+ export const pdfdocmut_pageCount: (a: number) => number;
58
+ export const pdfdocmut_redactRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
59
+ export const pdfdocmut_redactSearch: (a: number, b: number, c: number, d: number) => void;
60
+ export const pdfdocmut_reorderPages: (a: number, b: number, c: number, d: number) => void;
61
+ export const pdfdocmut_replaceTextSpan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
62
+ export const pdfdocmut_rotatePage: (a: number, b: number, c: number, d: number) => void;
63
+ export const pdfdocmut_save: (a: number, b: number) => void;
64
+ export const pdfdocmut_setFormField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
65
+ export const pdfdocmut_setFormFields: (a: number, b: number, c: number, d: number) => void;
66
+ export const pdfdocmut_setTextRunStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
67
+ export const xfaengine_exportJson: (a: number, b: number) => void;
68
+ export const xfaengine_exportSchema: (a: number, b: number) => void;
69
+ export const xfaengine_fromFields: (a: number, b: number, c: number) => void;
70
+ export const xfaengine_fromJson: (a: number, b: number, c: number) => void;
71
+ export const xfaengine_getFieldValue: (a: number, b: number, c: number, d: number) => void;
72
+ export const xfaengine_importJson: (a: number, b: number, c: number, d: number) => void;
73
+ export const xfaengine_nodeCount: (a: number) => number;
74
+ export const xfaengine_runCalculations: (a: number, b: number) => void;
75
+ export const xfaengine_setFieldValue: (a: number, b: number, c: number, d: number, e: number) => number;
76
+ export const xfaengine_version: (a: number) => void;
77
+ export const __wbindgen_export: (a: number, b: number) => number;
78
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
79
+ export const __wbindgen_export3: (a: number) => void;
80
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
81
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;