pdf-oxide-wasm 0.3.18 → 0.3.20

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/pdf_oxide.js CHANGED
@@ -1,297 +1,4 @@
1
-
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
-
5
- function addHeapObject(obj) {
6
- if (heap_next === heap.length) heap.push(heap.length + 1);
7
- const idx = heap_next;
8
- heap_next = heap[idx];
9
-
10
- heap[idx] = obj;
11
- return idx;
12
- }
13
-
14
- function _assertClass(instance, klass) {
15
- if (!(instance instanceof klass)) {
16
- throw new Error(`expected instance of ${klass.name}`);
17
- }
18
- }
19
-
20
- function debugString(val) {
21
- // primitive types
22
- const type = typeof val;
23
- if (type == 'number' || type == 'boolean' || val == null) {
24
- return `${val}`;
25
- }
26
- if (type == 'string') {
27
- return `"${val}"`;
28
- }
29
- if (type == 'symbol') {
30
- const description = val.description;
31
- if (description == null) {
32
- return 'Symbol';
33
- } else {
34
- return `Symbol(${description})`;
35
- }
36
- }
37
- if (type == 'function') {
38
- const name = val.name;
39
- if (typeof name == 'string' && name.length > 0) {
40
- return `Function(${name})`;
41
- } else {
42
- return 'Function';
43
- }
44
- }
45
- // objects
46
- if (Array.isArray(val)) {
47
- const length = val.length;
48
- let debug = '[';
49
- if (length > 0) {
50
- debug += debugString(val[0]);
51
- }
52
- for(let i = 1; i < length; i++) {
53
- debug += ', ' + debugString(val[i]);
54
- }
55
- debug += ']';
56
- return debug;
57
- }
58
- // Test for built-in
59
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
60
- let className;
61
- if (builtInMatches && builtInMatches.length > 1) {
62
- className = builtInMatches[1];
63
- } else {
64
- // Failed to match the standard '[object ClassName]'
65
- return toString.call(val);
66
- }
67
- if (className == 'Object') {
68
- // we're a user defined class or Object
69
- // JSON.stringify avoids problems with cycles, and is generally much
70
- // easier than looping through ownProperties of `val`.
71
- try {
72
- return 'Object(' + JSON.stringify(val) + ')';
73
- } catch (_) {
74
- return 'Object';
75
- }
76
- }
77
- // errors
78
- if (val instanceof Error) {
79
- return `${val.name}: ${val.message}\n${val.stack}`;
80
- }
81
- // TODO we could test for more things here, like `Set`s and `Map`s.
82
- return className;
83
- }
84
-
85
- function dropObject(idx) {
86
- if (idx < 132) return;
87
- heap[idx] = heap_next;
88
- heap_next = idx;
89
- }
90
-
91
- function getArrayF32FromWasm0(ptr, len) {
92
- ptr = ptr >>> 0;
93
- return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
94
- }
95
-
96
- function getArrayU8FromWasm0(ptr, len) {
97
- ptr = ptr >>> 0;
98
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
99
- }
100
-
101
- let cachedDataViewMemory0 = null;
102
- function getDataViewMemory0() {
103
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
104
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
105
- }
106
- return cachedDataViewMemory0;
107
- }
108
-
109
- let cachedFloat32ArrayMemory0 = null;
110
- function getFloat32ArrayMemory0() {
111
- if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
112
- cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
113
- }
114
- return cachedFloat32ArrayMemory0;
115
- }
116
-
117
- function getStringFromWasm0(ptr, len) {
118
- ptr = ptr >>> 0;
119
- return decodeText(ptr, len);
120
- }
121
-
122
- let cachedUint32ArrayMemory0 = null;
123
- function getUint32ArrayMemory0() {
124
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
125
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
126
- }
127
- return cachedUint32ArrayMemory0;
128
- }
129
-
130
- let cachedUint8ArrayMemory0 = null;
131
- function getUint8ArrayMemory0() {
132
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
133
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
134
- }
135
- return cachedUint8ArrayMemory0;
136
- }
137
-
138
- function getObject(idx) { return heap[idx]; }
139
-
140
- function handleError(f, args) {
141
- try {
142
- return f.apply(this, args);
143
- } catch (e) {
144
- wasm.__wbindgen_export3(addHeapObject(e));
145
- }
146
- }
147
-
148
- let heap = new Array(128).fill(undefined);
149
- heap.push(undefined, null, true, false);
150
-
151
- let heap_next = heap.length;
152
-
153
- function isLikeNone(x) {
154
- return x === undefined || x === null;
155
- }
156
-
157
- function passArray32ToWasm0(arg, malloc) {
158
- const ptr = malloc(arg.length * 4, 4) >>> 0;
159
- getUint32ArrayMemory0().set(arg, ptr / 4);
160
- WASM_VECTOR_LEN = arg.length;
161
- return ptr;
162
- }
163
-
164
- function passArray8ToWasm0(arg, malloc) {
165
- const ptr = malloc(arg.length * 1, 1) >>> 0;
166
- getUint8ArrayMemory0().set(arg, ptr / 1);
167
- WASM_VECTOR_LEN = arg.length;
168
- return ptr;
169
- }
170
-
171
- function passArrayF32ToWasm0(arg, malloc) {
172
- const ptr = malloc(arg.length * 4, 4) >>> 0;
173
- getFloat32ArrayMemory0().set(arg, ptr / 4);
174
- WASM_VECTOR_LEN = arg.length;
175
- return ptr;
176
- }
177
-
178
- function passArrayJsValueToWasm0(array, malloc) {
179
- const ptr = malloc(array.length * 4, 4) >>> 0;
180
- const mem = getDataViewMemory0();
181
- for (let i = 0; i < array.length; i++) {
182
- mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
183
- }
184
- WASM_VECTOR_LEN = array.length;
185
- return ptr;
186
- }
187
-
188
- function passStringToWasm0(arg, malloc, realloc) {
189
- if (realloc === undefined) {
190
- const buf = cachedTextEncoder.encode(arg);
191
- const ptr = malloc(buf.length, 1) >>> 0;
192
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
193
- WASM_VECTOR_LEN = buf.length;
194
- return ptr;
195
- }
196
-
197
- let len = arg.length;
198
- let ptr = malloc(len, 1) >>> 0;
199
-
200
- const mem = getUint8ArrayMemory0();
201
-
202
- let offset = 0;
203
-
204
- for (; offset < len; offset++) {
205
- const code = arg.charCodeAt(offset);
206
- if (code > 0x7F) break;
207
- mem[ptr + offset] = code;
208
- }
209
- if (offset !== len) {
210
- if (offset !== 0) {
211
- arg = arg.slice(offset);
212
- }
213
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
214
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
215
- const ret = cachedTextEncoder.encodeInto(arg, view);
216
-
217
- offset += ret.written;
218
- ptr = realloc(ptr, len, offset, 1) >>> 0;
219
- }
220
-
221
- WASM_VECTOR_LEN = offset;
222
- return ptr;
223
- }
224
-
225
- function takeObject(idx) {
226
- const ret = getObject(idx);
227
- dropObject(idx);
228
- return ret;
229
- }
230
-
231
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
232
- cachedTextDecoder.decode();
233
- function decodeText(ptr, len) {
234
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
235
- }
236
-
237
- const cachedTextEncoder = new TextEncoder();
238
-
239
- if (!('encodeInto' in cachedTextEncoder)) {
240
- cachedTextEncoder.encodeInto = function (arg, view) {
241
- const buf = cachedTextEncoder.encode(arg);
242
- view.set(buf);
243
- return {
244
- read: arg.length,
245
- written: buf.length
246
- };
247
- }
248
- }
249
-
250
- let WASM_VECTOR_LEN = 0;
251
-
252
- const ArtifactStyleFinalization = (typeof FinalizationRegistry === 'undefined')
253
- ? { register: () => {}, unregister: () => {} }
254
- : new FinalizationRegistry(ptr => wasm.__wbg_artifactstyle_free(ptr >>> 0, 1));
255
-
256
- const WasmArtifactFinalization = (typeof FinalizationRegistry === 'undefined')
257
- ? { register: () => {}, unregister: () => {} }
258
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmartifact_free(ptr >>> 0, 1));
259
-
260
- const WasmArtifactStyleFinalization = (typeof FinalizationRegistry === 'undefined')
261
- ? { register: () => {}, unregister: () => {} }
262
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmartifactstyle_free(ptr >>> 0, 1));
263
-
264
- const WasmFooterFinalization = (typeof FinalizationRegistry === 'undefined')
265
- ? { register: () => {}, unregister: () => {} }
266
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmfooter_free(ptr >>> 0, 1));
267
-
268
- const WasmHeaderFinalization = (typeof FinalizationRegistry === 'undefined')
269
- ? { register: () => {}, unregister: () => {} }
270
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmheader_free(ptr >>> 0, 1));
271
-
272
- const WasmOcrConfigFinalization = (typeof FinalizationRegistry === 'undefined')
273
- ? { register: () => {}, unregister: () => {} }
274
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmocrconfig_free(ptr >>> 0, 1));
275
-
276
- const WasmOcrEngineFinalization = (typeof FinalizationRegistry === 'undefined')
277
- ? { register: () => {}, unregister: () => {} }
278
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmocrengine_free(ptr >>> 0, 1));
279
-
280
- const WasmPageTemplateFinalization = (typeof FinalizationRegistry === 'undefined')
281
- ? { register: () => {}, unregister: () => {} }
282
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmpagetemplate_free(ptr >>> 0, 1));
283
-
284
- const WasmPdfFinalization = (typeof FinalizationRegistry === 'undefined')
285
- ? { register: () => {}, unregister: () => {} }
286
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdf_free(ptr >>> 0, 1));
287
-
288
- const WasmPdfDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
289
- ? { register: () => {}, unregister: () => {} }
290
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfdocument_free(ptr >>> 0, 1));
291
-
292
- const WasmPdfPageRegionFinalization = (typeof FinalizationRegistry === 'undefined')
293
- ? { register: () => {}, unregister: () => {} }
294
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfpageregion_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./pdf_oxide.d.ts" */
295
2
 
296
3
  /**
297
4
  * Style configuration for header/footer text.
@@ -314,10 +21,77 @@ class ArtifactStyle {
314
21
  const ptr = this.__destroy_into_raw();
315
22
  wasm.__wbg_artifactstyle_free(ptr, 0);
316
23
  }
24
+ /**
25
+ * Set bold font for the artifact.
26
+ * @returns {ArtifactStyle}
27
+ */
28
+ bold() {
29
+ const ptr = this.__destroy_into_raw();
30
+ const ret = wasm.wasmartifactstyle_bold(ptr);
31
+ return ArtifactStyle.__wrap(ret);
32
+ }
33
+ /**
34
+ * Set color for the artifact.
35
+ * @param {number} r
36
+ * @param {number} g
37
+ * @param {number} b
38
+ * @returns {ArtifactStyle}
39
+ */
40
+ color(r, g, b) {
41
+ const ptr = this.__destroy_into_raw();
42
+ const ret = wasm.wasmartifactstyle_color(ptr, r, g, b);
43
+ return ArtifactStyle.__wrap(ret);
44
+ }
45
+ /**
46
+ * Set font for the artifact.
47
+ * @param {string} name
48
+ * @param {number} size
49
+ * @returns {ArtifactStyle}
50
+ */
51
+ font(name, size) {
52
+ const ptr = this.__destroy_into_raw();
53
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ const ret = wasm.wasmartifactstyle_font(ptr, ptr0, len0, size);
56
+ return ArtifactStyle.__wrap(ret);
57
+ }
58
+ /**
59
+ * Create a new artifact style.
60
+ */
61
+ constructor() {
62
+ const ret = wasm.wasmartifactstyle_new();
63
+ this.__wbg_ptr = ret >>> 0;
64
+ ArtifactStyleFinalization.register(this, this.__wbg_ptr, this);
65
+ return this;
66
+ }
317
67
  }
318
68
  if (Symbol.dispose) ArtifactStyle.prototype[Symbol.dispose] = ArtifactStyle.prototype.free;
319
69
  exports.ArtifactStyle = ArtifactStyle;
320
70
 
71
+ /**
72
+ * Chroma subsampling format
73
+ * @enum {0 | 1 | 2 | 3}
74
+ */
75
+ const ChromaSampling = Object.freeze({
76
+ /**
77
+ * Both vertically and horizontally subsampled.
78
+ */
79
+ Cs420: 0, "0": "Cs420",
80
+ /**
81
+ * Horizontally subsampled.
82
+ */
83
+ Cs422: 1, "1": "Cs422",
84
+ /**
85
+ * Not subsampled.
86
+ */
87
+ Cs444: 2, "2": "Cs444",
88
+ /**
89
+ * Monochrome.
90
+ */
91
+ Cs400: 3, "3": "Cs400",
92
+ });
93
+ exports.ChromaSampling = ChromaSampling;
94
+
321
95
  /**
322
96
  * A header or footer artifact definition.
323
97
  */
@@ -340,24 +114,25 @@ class WasmArtifact {
340
114
  wasm.__wbg_wasmartifact_free(ptr, 0);
341
115
  }
342
116
  /**
343
- * Set style for the artifact.
344
- * @param {ArtifactStyle} style
117
+ * Create a center-aligned artifact.
118
+ * @param {string} text
345
119
  * @returns {WasmArtifact}
346
120
  */
347
- withStyle(style) {
348
- const ptr = this.__destroy_into_raw();
349
- _assertClass(style, ArtifactStyle);
350
- const ret = wasm.wasmartifact_withStyle(ptr, style.__wbg_ptr);
121
+ static center(text) {
122
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ret = wasm.wasmartifact_center(ptr0, len0);
351
125
  return WasmArtifact.__wrap(ret);
352
126
  }
353
127
  /**
354
- * Set vertical offset for the artifact.
355
- * @param {number} offset
128
+ * Create a left-aligned artifact.
129
+ * @param {string} text
356
130
  * @returns {WasmArtifact}
357
131
  */
358
- withOffset(offset) {
359
- const ptr = this.__destroy_into_raw();
360
- const ret = wasm.wasmartifact_withOffset(ptr, offset);
132
+ static left(text) {
133
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ const ret = wasm.wasmartifact_left(ptr0, len0);
361
136
  return WasmArtifact.__wrap(ret);
362
137
  }
363
138
  /**
@@ -369,17 +144,6 @@ class WasmArtifact {
369
144
  WasmArtifactFinalization.register(this, this.__wbg_ptr, this);
370
145
  return this;
371
146
  }
372
- /**
373
- * Create a left-aligned artifact.
374
- * @param {string} text
375
- * @returns {WasmArtifact}
376
- */
377
- static left(text) {
378
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
379
- const len0 = WASM_VECTOR_LEN;
380
- const ret = wasm.wasmartifact_left(ptr0, len0);
381
- return WasmArtifact.__wrap(ret);
382
- }
383
147
  /**
384
148
  * Create a right-aligned artifact.
385
149
  * @param {string} text
@@ -392,75 +156,29 @@ class WasmArtifact {
392
156
  return WasmArtifact.__wrap(ret);
393
157
  }
394
158
  /**
395
- * Create a center-aligned artifact.
396
- * @param {string} text
159
+ * Set vertical offset for the artifact.
160
+ * @param {number} offset
397
161
  * @returns {WasmArtifact}
398
162
  */
399
- static center(text) {
400
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
401
- const len0 = WASM_VECTOR_LEN;
402
- const ret = wasm.wasmartifact_center(ptr0, len0);
403
- return WasmArtifact.__wrap(ret);
404
- }
405
- }
406
- if (Symbol.dispose) WasmArtifact.prototype[Symbol.dispose] = WasmArtifact.prototype.free;
407
- exports.WasmArtifact = WasmArtifact;
408
-
409
- class WasmArtifactStyle {
410
- __destroy_into_raw() {
411
- const ptr = this.__wbg_ptr;
412
- this.__wbg_ptr = 0;
413
- WasmArtifactStyleFinalization.unregister(this);
414
- return ptr;
415
- }
416
- free() {
417
- const ptr = this.__destroy_into_raw();
418
- wasm.__wbg_wasmartifactstyle_free(ptr, 0);
419
- }
420
- /**
421
- * Create a new artifact style.
422
- */
423
- constructor() {
424
- const ret = wasm.wasmartifactstyle_new();
425
- return ArtifactStyle.__wrap(ret);
426
- }
427
- /**
428
- * Set bold font for the artifact.
429
- * @returns {ArtifactStyle}
430
- */
431
- bold() {
432
- const ptr = this.__destroy_into_raw();
433
- const ret = wasm.wasmartifactstyle_bold(ptr);
434
- return ArtifactStyle.__wrap(ret);
435
- }
436
- /**
437
- * Set font for the artifact.
438
- * @param {string} name
439
- * @param {number} size
440
- * @returns {ArtifactStyle}
441
- */
442
- font(name, size) {
163
+ withOffset(offset) {
443
164
  const ptr = this.__destroy_into_raw();
444
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
445
- const len0 = WASM_VECTOR_LEN;
446
- const ret = wasm.wasmartifactstyle_font(ptr, ptr0, len0, size);
447
- return ArtifactStyle.__wrap(ret);
165
+ const ret = wasm.wasmartifact_withOffset(ptr, offset);
166
+ return WasmArtifact.__wrap(ret);
448
167
  }
449
168
  /**
450
- * Set color for the artifact.
451
- * @param {number} r
452
- * @param {number} g
453
- * @param {number} b
454
- * @returns {ArtifactStyle}
169
+ * Set style for the artifact.
170
+ * @param {ArtifactStyle} style
171
+ * @returns {WasmArtifact}
455
172
  */
456
- color(r, g, b) {
173
+ withStyle(style) {
457
174
  const ptr = this.__destroy_into_raw();
458
- const ret = wasm.wasmartifactstyle_color(ptr, r, g, b);
459
- return ArtifactStyle.__wrap(ret);
175
+ _assertClass(style, ArtifactStyle);
176
+ const ret = wasm.wasmartifact_withStyle(ptr, style.__wbg_ptr);
177
+ return WasmArtifact.__wrap(ret);
460
178
  }
461
179
  }
462
- if (Symbol.dispose) WasmArtifactStyle.prototype[Symbol.dispose] = WasmArtifactStyle.prototype.free;
463
- exports.WasmArtifactStyle = WasmArtifactStyle;
180
+ if (Symbol.dispose) WasmArtifact.prototype[Symbol.dispose] = WasmArtifact.prototype.free;
181
+ exports.WasmArtifact = WasmArtifact;
464
182
 
465
183
  /**
466
184
  * A footer definition.
@@ -484,45 +202,45 @@ class WasmFooter {
484
202
  wasm.__wbg_wasmfooter_free(ptr, 0);
485
203
  }
486
204
  /**
487
- * Create a new empty footer.
488
- */
489
- constructor() {
490
- const ret = wasm.wasmartifact_new();
491
- this.__wbg_ptr = ret >>> 0;
492
- WasmFooterFinalization.register(this, this.__wbg_ptr, this);
493
- return this;
494
- }
495
- /**
496
- * Create a left-aligned footer.
205
+ * Create a center-aligned footer.
497
206
  * @param {string} text
498
207
  * @returns {WasmFooter}
499
208
  */
500
- static left(text) {
209
+ static center(text) {
501
210
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
502
211
  const len0 = WASM_VECTOR_LEN;
503
- const ret = wasm.wasmartifact_left(ptr0, len0);
212
+ const ret = wasm.wasmfooter_center(ptr0, len0);
504
213
  return WasmFooter.__wrap(ret);
505
214
  }
506
215
  /**
507
- * Create a right-aligned footer.
216
+ * Create a left-aligned footer.
508
217
  * @param {string} text
509
218
  * @returns {WasmFooter}
510
219
  */
511
- static right(text) {
220
+ static left(text) {
512
221
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
513
222
  const len0 = WASM_VECTOR_LEN;
514
- const ret = wasm.wasmartifact_right(ptr0, len0);
223
+ const ret = wasm.wasmfooter_left(ptr0, len0);
515
224
  return WasmFooter.__wrap(ret);
516
225
  }
517
226
  /**
518
- * Create a center-aligned footer.
227
+ * Create a new empty footer.
228
+ */
229
+ constructor() {
230
+ const ret = wasm.wasmfooter_new();
231
+ this.__wbg_ptr = ret >>> 0;
232
+ WasmFooterFinalization.register(this, this.__wbg_ptr, this);
233
+ return this;
234
+ }
235
+ /**
236
+ * Create a right-aligned footer.
519
237
  * @param {string} text
520
238
  * @returns {WasmFooter}
521
239
  */
522
- static center(text) {
240
+ static right(text) {
523
241
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
524
242
  const len0 = WASM_VECTOR_LEN;
525
- const ret = wasm.wasmartifact_center(ptr0, len0);
243
+ const ret = wasm.wasmfooter_right(ptr0, len0);
526
244
  return WasmFooter.__wrap(ret);
527
245
  }
528
246
  }
@@ -546,50 +264,50 @@ class WasmHeader {
546
264
  WasmHeaderFinalization.unregister(this);
547
265
  return ptr;
548
266
  }
549
- free() {
550
- const ptr = this.__destroy_into_raw();
551
- wasm.__wbg_wasmheader_free(ptr, 0);
552
- }
553
- /**
554
- * Create a new empty header.
555
- */
556
- constructor() {
557
- const ret = wasm.wasmartifact_new();
558
- this.__wbg_ptr = ret >>> 0;
559
- WasmHeaderFinalization.register(this, this.__wbg_ptr, this);
560
- return this;
267
+ free() {
268
+ const ptr = this.__destroy_into_raw();
269
+ wasm.__wbg_wasmheader_free(ptr, 0);
561
270
  }
562
271
  /**
563
- * Create a left-aligned header.
272
+ * Create a center-aligned header.
564
273
  * @param {string} text
565
274
  * @returns {WasmHeader}
566
275
  */
567
- static left(text) {
276
+ static center(text) {
568
277
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
569
278
  const len0 = WASM_VECTOR_LEN;
570
- const ret = wasm.wasmartifact_left(ptr0, len0);
279
+ const ret = wasm.wasmheader_center(ptr0, len0);
571
280
  return WasmHeader.__wrap(ret);
572
281
  }
573
282
  /**
574
- * Create a right-aligned header.
283
+ * Create a left-aligned header.
575
284
  * @param {string} text
576
285
  * @returns {WasmHeader}
577
286
  */
578
- static right(text) {
287
+ static left(text) {
579
288
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
580
289
  const len0 = WASM_VECTOR_LEN;
581
- const ret = wasm.wasmartifact_right(ptr0, len0);
290
+ const ret = wasm.wasmheader_left(ptr0, len0);
582
291
  return WasmHeader.__wrap(ret);
583
292
  }
584
293
  /**
585
- * Create a center-aligned header.
294
+ * Create a new empty header.
295
+ */
296
+ constructor() {
297
+ const ret = wasm.wasmheader_new();
298
+ this.__wbg_ptr = ret >>> 0;
299
+ WasmHeaderFinalization.register(this, this.__wbg_ptr, this);
300
+ return this;
301
+ }
302
+ /**
303
+ * Create a right-aligned header.
586
304
  * @param {string} text
587
305
  * @returns {WasmHeader}
588
306
  */
589
- static center(text) {
307
+ static right(text) {
590
308
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
591
309
  const len0 = WASM_VECTOR_LEN;
592
- const ret = wasm.wasmartifact_center(ptr0, len0);
310
+ const ret = wasm.wasmheader_right(ptr0, len0);
593
311
  return WasmHeader.__wrap(ret);
594
312
  }
595
313
  }
@@ -697,24 +415,6 @@ class WasmPageTemplate {
697
415
  const ptr = this.__destroy_into_raw();
698
416
  wasm.__wbg_wasmpagetemplate_free(ptr, 0);
699
417
  }
700
- /**
701
- * Skip rendering template on the first page.
702
- * @returns {WasmPageTemplate}
703
- */
704
- skipFirstPage() {
705
- const ptr = this.__destroy_into_raw();
706
- const ret = wasm.wasmpagetemplate_skipFirstPage(ptr);
707
- return WasmPageTemplate.__wrap(ret);
708
- }
709
- /**
710
- * Create a new page template.
711
- */
712
- constructor() {
713
- const ret = wasm.wasmpagetemplate_new();
714
- this.__wbg_ptr = ret >>> 0;
715
- WasmPageTemplateFinalization.register(this, this.__wbg_ptr, this);
716
- return this;
717
- }
718
418
  /**
719
419
  * Set footer artifact.
720
420
  * @param {WasmArtifact} footer
@@ -737,6 +437,24 @@ class WasmPageTemplate {
737
437
  const ret = wasm.wasmpagetemplate_header(ptr, header.__wbg_ptr);
738
438
  return WasmPageTemplate.__wrap(ret);
739
439
  }
440
+ /**
441
+ * Create a new page template.
442
+ */
443
+ constructor() {
444
+ const ret = wasm.wasmpagetemplate_new();
445
+ this.__wbg_ptr = ret >>> 0;
446
+ WasmPageTemplateFinalization.register(this, this.__wbg_ptr, this);
447
+ return this;
448
+ }
449
+ /**
450
+ * Skip rendering template on the first page.
451
+ * @returns {WasmPageTemplate}
452
+ */
453
+ skipFirstPage() {
454
+ const ptr = this.__destroy_into_raw();
455
+ const ret = wasm.wasmpagetemplate_skipFirstPage(ptr);
456
+ return WasmPageTemplate.__wrap(ret);
457
+ }
740
458
  }
741
459
  if (Symbol.dispose) WasmPageTemplate.prototype[Symbol.dispose] = WasmPageTemplate.prototype.free;
742
460
  exports.WasmPageTemplate = WasmPageTemplate;
@@ -769,107 +487,19 @@ class WasmPdf {
769
487
  wasm.__wbg_wasmpdf_free(ptr, 0);
770
488
  }
771
489
  /**
772
- * Create a PDF from Markdown content.
773
- *
774
- * @param content - Markdown string
775
- * @param title - Optional document title
776
- * @param author - Optional document author
777
- * @param {string} content
778
- * @param {string | null} [title]
779
- * @param {string | null} [author]
780
- * @returns {WasmPdf}
781
- */
782
- static fromMarkdown(content, title, author) {
783
- try {
784
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
785
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
786
- const len0 = WASM_VECTOR_LEN;
787
- var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
788
- var len1 = WASM_VECTOR_LEN;
789
- var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
790
- var len2 = WASM_VECTOR_LEN;
791
- wasm.wasmpdf_fromMarkdown(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
792
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
793
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
794
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
795
- if (r2) {
796
- throw takeObject(r1);
797
- }
798
- return WasmPdf.__wrap(r0);
799
- } finally {
800
- wasm.__wbindgen_add_to_stack_pointer(16);
801
- }
802
- }
803
- /**
804
- * Create a PDF from image bytes (PNG, JPEG, etc.).
490
+ * Open an existing PDF from bytes for editing.
805
491
  *
806
- * @param data - Image file contents as a Uint8Array
492
+ * @param data - PDF file contents as Uint8Array
493
+ * @returns WasmPdf for editing
807
494
  * @param {Uint8Array} data
808
495
  * @returns {WasmPdf}
809
496
  */
810
- static fromImageBytes(data) {
497
+ static fromBytes(data) {
811
498
  try {
812
499
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
813
500
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
814
501
  const len0 = WASM_VECTOR_LEN;
815
- wasm.wasmpdf_fromImageBytes(retptr, ptr0, len0);
816
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
817
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
818
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
819
- if (r2) {
820
- throw takeObject(r1);
821
- }
822
- return WasmPdf.__wrap(r0);
823
- } finally {
824
- wasm.__wbindgen_add_to_stack_pointer(16);
825
- }
826
- }
827
- /**
828
- * Create a PDF from multiple image byte arrays.
829
- *
830
- * Each image becomes a separate page. Pass an array of Uint8Arrays.
831
- *
832
- * @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
833
- * @param {any} images_array
834
- * @returns {WasmPdf}
835
- */
836
- static fromMultipleImageBytes(images_array) {
837
- try {
838
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
839
- wasm.wasmpdf_fromMultipleImageBytes(retptr, addHeapObject(images_array));
840
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
841
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
842
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
843
- if (r2) {
844
- throw takeObject(r1);
845
- }
846
- return WasmPdf.__wrap(r0);
847
- } finally {
848
- wasm.__wbindgen_add_to_stack_pointer(16);
849
- }
850
- }
851
- /**
852
- * Get the size of the PDF in bytes.
853
- * @returns {number}
854
- */
855
- get size() {
856
- const ret = wasm.wasmpdf_size(this.__wbg_ptr);
857
- return ret >>> 0;
858
- }
859
- /**
860
- * Merge multiple PDF byte arrays into a single PDF.
861
- *
862
- * @param pdfs - Array of Uint8Array, each containing a PDF
863
- * @returns WasmPdf containing all pages
864
- * @param {Uint8Array[]} pdfs
865
- * @returns {WasmPdf}
866
- */
867
- static merge(pdfs) {
868
- try {
869
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
870
- const ptr0 = passArrayJsValueToWasm0(pdfs, wasm.__wbindgen_export);
871
- const len0 = WASM_VECTOR_LEN;
872
- wasm.wasmpdf_merge(retptr, ptr0, len0);
502
+ wasm.wasmpdf_fromBytes(retptr, ptr0, len0);
873
503
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
874
504
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
875
505
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -881,23 +511,6 @@ class WasmPdf {
881
511
  wasm.__wbindgen_add_to_stack_pointer(16);
882
512
  }
883
513
  }
884
- /**
885
- * Get the PDF as a Uint8Array.
886
- * @returns {Uint8Array}
887
- */
888
- toBytes() {
889
- try {
890
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
891
- wasm.wasmpdf_toBytes(retptr, this.__wbg_ptr);
892
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
893
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
894
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
895
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
896
- return v1;
897
- } finally {
898
- wasm.__wbindgen_add_to_stack_pointer(16);
899
- }
900
- }
901
514
  /**
902
515
  * Create a PDF from HTML content.
903
516
  *
@@ -931,271 +544,254 @@ class WasmPdf {
931
544
  }
932
545
  }
933
546
  /**
934
- * Create a PDF from plain text.
935
- *
936
- * @param content - Plain text string
937
- * @param title - Optional document title
938
- * @param author - Optional document author
939
- * @param {string} content
940
- * @param {string | null} [title]
941
- * @param {string | null} [author]
942
- * @returns {WasmPdf}
943
- */
944
- static fromText(content, title, author) {
945
- try {
946
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
947
- const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
948
- const len0 = WASM_VECTOR_LEN;
949
- var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
950
- var len1 = WASM_VECTOR_LEN;
951
- var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
952
- var len2 = WASM_VECTOR_LEN;
953
- wasm.wasmpdf_fromText(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
954
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
955
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
956
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
957
- if (r2) {
958
- throw takeObject(r1);
959
- }
960
- return WasmPdf.__wrap(r0);
961
- } finally {
962
- wasm.__wbindgen_add_to_stack_pointer(16);
963
- }
964
- }
965
- }
966
- if (Symbol.dispose) WasmPdf.prototype[Symbol.dispose] = WasmPdf.prototype.free;
967
- exports.WasmPdf = WasmPdf;
968
-
969
- /**
970
- * A PDF document loaded from bytes for use in WebAssembly.
971
- *
972
- * Create an instance by passing PDF file bytes to the constructor.
973
- * Call `.free()` when done to release memory.
974
- */
975
- class WasmPdfDocument {
976
- __destroy_into_raw() {
977
- const ptr = this.__wbg_ptr;
978
- this.__wbg_ptr = 0;
979
- WasmPdfDocumentFinalization.unregister(this);
980
- return ptr;
981
- }
982
- free() {
983
- const ptr = this.__destroy_into_raw();
984
- wasm.__wbg_wasmpdfdocument_free(ptr, 0);
985
- }
986
- /**
987
- * Embed a file into the PDF document.
988
- *
989
- * @param name - Display name for the embedded file
990
- * @param data - File contents as a Uint8Array
991
- * @param {string} name
992
- * @param {Uint8Array} data
993
- */
994
- embedFile(name, data) {
995
- try {
996
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
997
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
998
- const len0 = WASM_VECTOR_LEN;
999
- const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1000
- const len1 = WASM_VECTOR_LEN;
1001
- wasm.wasmpdfdocument_embedFile(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1002
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1003
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1004
- if (r1) {
1005
- throw takeObject(r0);
1006
- }
1007
- } finally {
1008
- wasm.__wbindgen_add_to_stack_pointer(16);
1009
- }
1010
- }
1011
- /**
1012
- * Merge another PDF (provided as bytes) into this document.
547
+ * Create a PDF from image bytes (PNG, JPEG, etc.).
1013
548
  *
1014
- * @param data - The PDF file contents to merge as a Uint8Array
1015
- * @returns Number of pages merged
549
+ * @param data - Image file contents as a Uint8Array
1016
550
  * @param {Uint8Array} data
1017
- * @returns {number}
551
+ * @returns {WasmPdf}
1018
552
  */
1019
- mergeFrom(data) {
553
+ static fromImageBytes(data) {
1020
554
  try {
1021
555
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1022
556
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1023
557
  const len0 = WASM_VECTOR_LEN;
1024
- wasm.wasmpdfdocument_mergeFrom(retptr, this.__wbg_ptr, ptr0, len0);
558
+ wasm.wasmpdf_fromImageBytes(retptr, ptr0, len0);
1025
559
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1026
560
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1027
561
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1028
562
  if (r2) {
1029
563
  throw takeObject(r1);
1030
564
  }
1031
- return r0 >>> 0;
565
+ return WasmPdf.__wrap(r0);
1032
566
  } finally {
1033
567
  wasm.__wbindgen_add_to_stack_pointer(16);
1034
568
  }
1035
569
  }
1036
570
  /**
1037
- * Get the number of pages in the document.
1038
- * @returns {number}
571
+ * Create a PDF from Markdown content.
572
+ *
573
+ * @param content - Markdown string
574
+ * @param title - Optional document title
575
+ * @param author - Optional document author
576
+ * @param {string} content
577
+ * @param {string | null} [title]
578
+ * @param {string | null} [author]
579
+ * @returns {WasmPdf}
1039
580
  */
1040
- pageCount() {
581
+ static fromMarkdown(content, title, author) {
1041
582
  try {
1042
583
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1043
- wasm.wasmpdfdocument_pageCount(retptr, this.__wbg_ptr);
584
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
585
+ const len0 = WASM_VECTOR_LEN;
586
+ var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
587
+ var len1 = WASM_VECTOR_LEN;
588
+ var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
589
+ var len2 = WASM_VECTOR_LEN;
590
+ wasm.wasmpdf_fromMarkdown(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1044
591
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1045
592
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1046
593
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1047
594
  if (r2) {
1048
595
  throw takeObject(r1);
1049
596
  }
1050
- return r0 >>> 0;
597
+ return WasmPdf.__wrap(r0);
1051
598
  } finally {
1052
599
  wasm.__wbindgen_add_to_stack_pointer(16);
1053
600
  }
1054
601
  }
1055
602
  /**
1056
- * Set the document author.
1057
- * @param {string} author
603
+ * Create a PDF from multiple image byte arrays.
604
+ *
605
+ * Each image becomes a separate page. Pass an array of Uint8Arrays.
606
+ *
607
+ * @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
608
+ * @param {any} images_array
609
+ * @returns {WasmPdf}
1058
610
  */
1059
- setAuthor(author) {
611
+ static fromMultipleImageBytes(images_array) {
1060
612
  try {
1061
613
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1062
- const ptr0 = passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1063
- const len0 = WASM_VECTOR_LEN;
1064
- wasm.wasmpdfdocument_setAuthor(retptr, this.__wbg_ptr, ptr0, len0);
614
+ wasm.wasmpdf_fromMultipleImageBytes(retptr, addHeapObject(images_array));
1065
615
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1066
616
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1067
- if (r1) {
1068
- throw takeObject(r0);
617
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
618
+ if (r2) {
619
+ throw takeObject(r1);
1069
620
  }
621
+ return WasmPdf.__wrap(r0);
1070
622
  } finally {
1071
623
  wasm.__wbindgen_add_to_stack_pointer(16);
1072
624
  }
1073
625
  }
1074
626
  /**
1075
- * Delete a page by index (0-based).
1076
- * @param {number} index
627
+ * Create a PDF from plain text.
628
+ *
629
+ * @param content - Plain text string
630
+ * @param title - Optional document title
631
+ * @param author - Optional document author
632
+ * @param {string} content
633
+ * @param {string | null} [title]
634
+ * @param {string | null} [author]
635
+ * @returns {WasmPdf}
1077
636
  */
1078
- deletePage(index) {
637
+ static fromText(content, title, author) {
1079
638
  try {
1080
639
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1081
- wasm.wasmpdfdocument_deletePage(retptr, this.__wbg_ptr, index);
640
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
641
+ const len0 = WASM_VECTOR_LEN;
642
+ var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
643
+ var len1 = WASM_VECTOR_LEN;
644
+ var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
645
+ var len2 = WASM_VECTOR_LEN;
646
+ wasm.wasmpdf_fromText(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1082
647
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1083
648
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1084
- if (r1) {
1085
- throw takeObject(r0);
649
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
650
+ if (r2) {
651
+ throw takeObject(r1);
1086
652
  }
653
+ return WasmPdf.__wrap(r0);
1087
654
  } finally {
1088
655
  wasm.__wbindgen_add_to_stack_pointer(16);
1089
656
  }
1090
657
  }
1091
658
  /**
1092
- * Deprecated: Use eraseFooter instead.
1093
- * @param {number} page_index
659
+ * Merge multiple PDF byte arrays into a single PDF.
660
+ *
661
+ * @param pdfs - Array of Uint8Array, each containing a PDF
662
+ * @returns WasmPdf containing all pages
663
+ * @param {Uint8Array[]} pdfs
664
+ * @returns {WasmPdf}
1094
665
  */
1095
- editFooter(page_index) {
666
+ static merge(pdfs) {
1096
667
  try {
1097
668
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1098
- wasm.wasmpdfdocument_editFooter(retptr, this.__wbg_ptr, page_index);
669
+ const ptr0 = passArrayJsValueToWasm0(pdfs, wasm.__wbindgen_export);
670
+ const len0 = WASM_VECTOR_LEN;
671
+ wasm.wasmpdf_merge(retptr, ptr0, len0);
1099
672
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1100
673
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1101
- if (r1) {
1102
- throw takeObject(r0);
674
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
675
+ if (r2) {
676
+ throw takeObject(r1);
1103
677
  }
678
+ return WasmPdf.__wrap(r0);
1104
679
  } finally {
1105
680
  wasm.__wbindgen_add_to_stack_pointer(16);
1106
681
  }
1107
682
  }
1108
683
  /**
1109
- * Deprecated: Use eraseHeader instead.
1110
- * @param {number} page_index
684
+ * Get the size of the PDF in bytes.
685
+ * @returns {number}
1111
686
  */
1112
- editHeader(page_index) {
687
+ get size() {
688
+ const ret = wasm.wasmpdf_size(this.__wbg_ptr);
689
+ return ret >>> 0;
690
+ }
691
+ /**
692
+ * Get the PDF as a Uint8Array.
693
+ * @returns {Uint8Array}
694
+ */
695
+ toBytes() {
1113
696
  try {
1114
697
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1115
- wasm.wasmpdfdocument_editHeader(retptr, this.__wbg_ptr, page_index);
698
+ wasm.wasmpdf_toBytes(retptr, this.__wbg_ptr);
1116
699
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1117
700
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1118
- if (r1) {
1119
- throw takeObject(r0);
1120
- }
701
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
702
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
703
+ return v1;
1121
704
  } finally {
1122
705
  wasm.__wbindgen_add_to_stack_pointer(16);
1123
706
  }
1124
707
  }
708
+ }
709
+ if (Symbol.dispose) WasmPdf.prototype[Symbol.dispose] = WasmPdf.prototype.free;
710
+ exports.WasmPdf = WasmPdf;
711
+
712
+ /**
713
+ * A PDF document loaded from bytes for use in WebAssembly.
714
+ *
715
+ * Create an instance by passing PDF file bytes to the constructor.
716
+ * Call `.free()` when done to release memory.
717
+ */
718
+ class WasmPdfDocument {
719
+ __destroy_into_raw() {
720
+ const ptr = this.__wbg_ptr;
721
+ this.__wbg_ptr = 0;
722
+ WasmPdfDocumentFinalization.unregister(this);
723
+ return ptr;
724
+ }
725
+ free() {
726
+ const ptr = this.__destroy_into_raw();
727
+ wasm.__wbg_wasmpdfdocument_free(ptr, 0);
728
+ }
1125
729
  /**
1126
- * Get the document outline (bookmarks / table of contents).
1127
- *
1128
- * @returns Array of outline items or null if no outline exists.
1129
- * Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
1130
- * @returns {any}
730
+ * Apply all redactions in the document.
1131
731
  */
1132
- getOutline() {
732
+ applyAllRedactions() {
1133
733
  try {
1134
734
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1135
- wasm.wasmpdfdocument_getOutline(retptr, this.__wbg_ptr);
735
+ wasm.wasmpdfdocument_applyAllRedactions(retptr, this.__wbg_ptr);
1136
736
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1137
737
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1138
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1139
- if (r2) {
1140
- throw takeObject(r1);
738
+ if (r1) {
739
+ throw takeObject(r0);
1141
740
  }
1142
- return takeObject(r0);
1143
741
  } finally {
1144
742
  wasm.__wbindgen_add_to_stack_pointer(16);
1145
743
  }
1146
744
  }
1147
745
  /**
1148
- * Get information about images on a page.
1149
- *
1150
- * Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
746
+ * Apply redactions on a page (removes redacted content permanently).
1151
747
  * @param {number} page_index
1152
- * @returns {any}
1153
748
  */
1154
- pageImages(page_index) {
749
+ applyPageRedactions(page_index) {
1155
750
  try {
1156
751
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1157
- wasm.wasmpdfdocument_pageImages(retptr, this.__wbg_ptr, page_index);
752
+ wasm.wasmpdfdocument_applyPageRedactions(retptr, this.__wbg_ptr, page_index);
1158
753
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1159
754
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1160
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1161
- if (r2) {
1162
- throw takeObject(r1);
755
+ if (r1) {
756
+ throw takeObject(r0);
1163
757
  }
1164
- return takeObject(r0);
1165
758
  } finally {
1166
759
  wasm.__wbindgen_add_to_stack_pointer(16);
1167
760
  }
1168
761
  }
1169
762
  /**
1170
- * Get page label ranges from the document.
763
+ * Authenticate with a password to decrypt an encrypted PDF.
1171
764
  *
1172
- * @returns Array of {start_page, style, prefix, start_value} objects, or empty array
1173
- * @returns {any}
765
+ * @param password - The password string
766
+ * @returns true if authentication succeeded
767
+ * @param {string} password
768
+ * @returns {boolean}
1174
769
  */
1175
- pageLabels() {
770
+ authenticate(password) {
1176
771
  try {
1177
772
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1178
- wasm.wasmpdfdocument_pageLabels(retptr, this.__wbg_ptr);
773
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
774
+ const len0 = WASM_VECTOR_LEN;
775
+ wasm.wasmpdfdocument_authenticate(retptr, this.__wbg_ptr, ptr0, len0);
1179
776
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1180
777
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1181
778
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1182
779
  if (r2) {
1183
780
  throw takeObject(r1);
1184
781
  }
1185
- return takeObject(r0);
782
+ return r0 !== 0;
1186
783
  } finally {
1187
784
  wasm.__wbindgen_add_to_stack_pointer(16);
1188
785
  }
1189
786
  }
1190
787
  /**
1191
- * Rotate a page by the given degrees (adds to current rotation).
788
+ * Clear all pending erase operations for a page.
1192
789
  * @param {number} page_index
1193
- * @param {number} degrees
1194
790
  */
1195
- rotatePage(page_index, degrees) {
791
+ clearEraseRegions(page_index) {
1196
792
  try {
1197
793
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1198
- wasm.wasmpdfdocument_rotatePage(retptr, this.__wbg_ptr, page_index, degrees);
794
+ wasm.wasmpdfdocument_clearEraseRegions(retptr, this.__wbg_ptr, page_index);
1199
795
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1200
796
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1201
797
  if (r1) {
@@ -1206,42 +802,33 @@ class WasmPdfDocument {
1206
802
  }
1207
803
  }
1208
804
  /**
1209
- * Search for text on a specific page.
1210
- * @param {number} page_index
1211
- * @param {string} pattern
1212
- * @param {boolean | null} [case_insensitive]
1213
- * @param {boolean | null} [literal]
1214
- * @param {boolean | null} [whole_word]
1215
- * @param {number | null} [max_results]
1216
- * @returns {any}
805
+ * Crop margins from all pages.
806
+ * @param {number} left
807
+ * @param {number} right
808
+ * @param {number} top
809
+ * @param {number} bottom
1217
810
  */
1218
- searchPage(page_index, pattern, case_insensitive, literal, whole_word, max_results) {
811
+ cropMargins(left, right, top, bottom) {
1219
812
  try {
1220
813
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1221
- const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1222
- const len0 = WASM_VECTOR_LEN;
1223
- wasm.wasmpdfdocument_searchPage(retptr, this.__wbg_ptr, page_index, ptr0, len0, isLikeNone(case_insensitive) ? 0xFFFFFF : case_insensitive ? 1 : 0, isLikeNone(literal) ? 0xFFFFFF : literal ? 1 : 0, isLikeNone(whole_word) ? 0xFFFFFF : whole_word ? 1 : 0, isLikeNone(max_results) ? 0x100000001 : (max_results) >>> 0);
814
+ wasm.wasmpdfdocument_cropMargins(retptr, this.__wbg_ptr, left, right, top, bottom);
1224
815
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1225
816
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1226
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1227
- if (r2) {
1228
- throw takeObject(r1);
817
+ if (r1) {
818
+ throw takeObject(r0);
1229
819
  }
1230
- return takeObject(r0);
1231
820
  } finally {
1232
821
  wasm.__wbindgen_add_to_stack_pointer(16);
1233
822
  }
1234
823
  }
1235
824
  /**
1236
- * Set the document subject.
1237
- * @param {string} subject
825
+ * Delete a page by index (0-based).
826
+ * @param {number} index
1238
827
  */
1239
- setSubject(subject) {
828
+ deletePage(index) {
1240
829
  try {
1241
830
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1242
- const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1243
- const len0 = WASM_VECTOR_LEN;
1244
- wasm.wasmpdfdocument_setSubject(retptr, this.__wbg_ptr, ptr0, len0);
831
+ wasm.wasmpdfdocument_deletePage(retptr, this.__wbg_ptr, index);
1245
832
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1246
833
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1247
834
  if (r1) {
@@ -1252,108 +839,74 @@ class WasmPdfDocument {
1252
839
  }
1253
840
  }
1254
841
  /**
1255
- * Convert all pages to HTML.
1256
- * @param {boolean | null} [preserve_layout]
1257
- * @param {boolean | null} [detect_headings]
1258
- * @param {boolean | null} [include_form_fields]
1259
- * @returns {string}
842
+ * Deprecated: Use eraseFooter instead.
843
+ * @param {number} page_index
1260
844
  */
1261
- toHtmlAll(preserve_layout, detect_headings, include_form_fields) {
1262
- let deferred2_0;
1263
- let deferred2_1;
845
+ editFooter(page_index) {
1264
846
  try {
1265
847
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1266
- wasm.wasmpdfdocument_toHtmlAll(retptr, this.__wbg_ptr, isLikeNone(preserve_layout) ? 0xFFFFFF : preserve_layout ? 1 : 0, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
848
+ wasm.wasmpdfdocument_editFooter(retptr, this.__wbg_ptr, page_index);
1267
849
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1268
850
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1269
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1270
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1271
- var ptr1 = r0;
1272
- var len1 = r1;
1273
- if (r3) {
1274
- ptr1 = 0; len1 = 0;
1275
- throw takeObject(r2);
1276
- }
1277
- deferred2_0 = ptr1;
1278
- deferred2_1 = len1;
1279
- return getStringFromWasm0(ptr1, len1);
851
+ if (r1) {
852
+ throw takeObject(r0);
853
+ }
1280
854
  } finally {
1281
855
  wasm.__wbindgen_add_to_stack_pointer(16);
1282
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1283
856
  }
1284
857
  }
1285
858
  /**
1286
- * Convert a single page to Markdown.
1287
- *
1288
- * @param page_index - Zero-based page number
1289
- * @param detect_headings - Whether to detect headings (default: true)
1290
- * @param include_images - Whether to include images (default: true)
859
+ * Deprecated: Use eraseHeader instead.
1291
860
  * @param {number} page_index
1292
- * @param {boolean | null} [detect_headings]
1293
- * @param {boolean | null} [include_images]
1294
- * @param {boolean | null} [include_form_fields]
1295
- * @returns {string}
1296
861
  */
1297
- toMarkdown(page_index, detect_headings, include_images, include_form_fields) {
1298
- let deferred2_0;
1299
- let deferred2_1;
862
+ editHeader(page_index) {
1300
863
  try {
1301
864
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1302
- wasm.wasmpdfdocument_toMarkdown(retptr, this.__wbg_ptr, page_index, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_images) ? 0xFFFFFF : include_images ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
865
+ wasm.wasmpdfdocument_editHeader(retptr, this.__wbg_ptr, page_index);
1303
866
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1304
867
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1305
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1306
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1307
- var ptr1 = r0;
1308
- var len1 = r1;
1309
- if (r3) {
1310
- ptr1 = 0; len1 = 0;
1311
- throw takeObject(r2);
868
+ if (r1) {
869
+ throw takeObject(r0);
1312
870
  }
1313
- deferred2_0 = ptr1;
1314
- deferred2_1 = len1;
1315
- return getStringFromWasm0(ptr1, len1);
1316
871
  } finally {
1317
872
  wasm.__wbindgen_add_to_stack_pointer(16);
1318
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1319
873
  }
1320
874
  }
1321
875
  /**
1322
- * Authenticate with a password to decrypt an encrypted PDF.
876
+ * Embed a file into the PDF document.
1323
877
  *
1324
- * @param password - The password string
1325
- * @returns true if authentication succeeded
1326
- * @param {string} password
1327
- * @returns {boolean}
878
+ * @param name - Display name for the embedded file
879
+ * @param data - File contents as a Uint8Array
880
+ * @param {string} name
881
+ * @param {Uint8Array} data
1328
882
  */
1329
- authenticate(password) {
883
+ embedFile(name, data) {
1330
884
  try {
1331
885
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1332
- const ptr0 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
886
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1333
887
  const len0 = WASM_VECTOR_LEN;
1334
- wasm.wasmpdfdocument_authenticate(retptr, this.__wbg_ptr, ptr0, len0);
888
+ const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
889
+ const len1 = WASM_VECTOR_LEN;
890
+ wasm.wasmpdfdocument_embedFile(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1335
891
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1336
892
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1337
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1338
- if (r2) {
1339
- throw takeObject(r1);
893
+ if (r1) {
894
+ throw takeObject(r0);
1340
895
  }
1341
- return r0 !== 0;
1342
896
  } finally {
1343
897
  wasm.__wbindgen_add_to_stack_pointer(16);
1344
898
  }
1345
899
  }
1346
900
  /**
1347
- * Crop margins from all pages.
1348
- * @param {number} left
1349
- * @param {number} right
1350
- * @param {number} top
1351
- * @param {number} bottom
901
+ * Erase both header and footer content.
902
+ *
903
+ * @param page_index - Zero-based page number
904
+ * @param {number} page_index
1352
905
  */
1353
- cropMargins(left, right, top, bottom) {
906
+ eraseArtifacts(page_index) {
1354
907
  try {
1355
908
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1356
- wasm.wasmpdfdocument_cropMargins(retptr, this.__wbg_ptr, left, right, top, bottom);
909
+ wasm.wasmpdfdocument_eraseArtifacts(retptr, this.__wbg_ptr, page_index);
1357
910
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1358
911
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1359
912
  if (r1) {
@@ -1427,20 +980,66 @@ class WasmPdfDocument {
1427
980
  }
1428
981
  }
1429
982
  /**
1430
- * Extract plain text from a single page.
983
+ * Erase multiple rectangular regions on a page.
1431
984
  *
1432
985
  * @param page_index - Zero-based page number
1433
- * @param region - Optional [x, y, width, height] to filter by
986
+ * @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
1434
987
  * @param {number} page_index
1435
- * @param {any} region
988
+ * @param {Float32Array} rects
989
+ */
990
+ eraseRegions(page_index, rects) {
991
+ try {
992
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
993
+ const ptr0 = passArrayF32ToWasm0(rects, wasm.__wbindgen_export);
994
+ const len0 = WASM_VECTOR_LEN;
995
+ wasm.wasmpdfdocument_eraseRegions(retptr, this.__wbg_ptr, page_index, ptr0, len0);
996
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
997
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
998
+ if (r1) {
999
+ throw takeObject(r0);
1000
+ }
1001
+ } finally {
1002
+ wasm.__wbindgen_add_to_stack_pointer(16);
1003
+ }
1004
+ }
1005
+ /**
1006
+ * Export form field data as FDF or XFDF bytes.
1007
+ *
1008
+ * @param format - "fdf" or "xfdf" (default: "fdf")
1009
+ * @returns Uint8Array containing the exported form data
1010
+ * @param {string | null} [format]
1011
+ * @returns {Uint8Array}
1012
+ */
1013
+ exportFormData(format) {
1014
+ try {
1015
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1016
+ var ptr0 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1017
+ var len0 = WASM_VECTOR_LEN;
1018
+ wasm.wasmpdfdocument_exportFormData(retptr, this.__wbg_ptr, ptr0, len0);
1019
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1020
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1021
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1022
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1023
+ if (r3) {
1024
+ throw takeObject(r2);
1025
+ }
1026
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1027
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1028
+ return v2;
1029
+ } finally {
1030
+ wasm.__wbindgen_add_to_stack_pointer(16);
1031
+ }
1032
+ }
1033
+ /**
1034
+ * Extract plain text from all pages, separated by form feed characters.
1436
1035
  * @returns {string}
1437
1036
  */
1438
- extractText(page_index, region) {
1037
+ extractAllText() {
1439
1038
  let deferred2_0;
1440
1039
  let deferred2_1;
1441
1040
  try {
1442
1041
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1443
- wasm.wasmpdfdocument_extractText(retptr, this.__wbg_ptr, page_index, addHeapObject(region));
1042
+ wasm.wasmpdfdocument_extractAllText(retptr, this.__wbg_ptr);
1444
1043
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1445
1044
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1446
1045
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1460,56 +1059,74 @@ class WasmPdfDocument {
1460
1059
  }
1461
1060
  }
1462
1061
  /**
1463
- * Resize an image on a page.
1062
+ * Extract character-level data from a page.
1063
+ *
1064
+ * Returns an array of objects with: char, bbox {x, y, width, height},
1065
+ * font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
1066
+ *
1067
+ * @param page_index - Zero-based page number
1068
+ * @param region - Optional [x, y, width, height] to filter by
1464
1069
  * @param {number} page_index
1465
- * @param {string} name
1466
- * @param {number} width
1467
- * @param {number} height
1070
+ * @param {Float32Array | null} [region]
1071
+ * @returns {any}
1468
1072
  */
1469
- resizeImage(page_index, name, width, height) {
1073
+ extractChars(page_index, region) {
1470
1074
  try {
1471
1075
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1472
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1473
- const len0 = WASM_VECTOR_LEN;
1474
- wasm.wasmpdfdocument_resizeImage(retptr, this.__wbg_ptr, page_index, ptr0, len0, width, height);
1076
+ var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1077
+ var len0 = WASM_VECTOR_LEN;
1078
+ wasm.wasmpdfdocument_extractChars(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1475
1079
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1476
1080
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1477
- if (r1) {
1478
- throw takeObject(r0);
1081
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1082
+ if (r2) {
1083
+ throw takeObject(r1);
1479
1084
  }
1085
+ return takeObject(r0);
1480
1086
  } finally {
1481
1087
  wasm.__wbindgen_add_to_stack_pointer(16);
1482
1088
  }
1483
1089
  }
1484
1090
  /**
1485
- * Set the document keywords.
1486
- * @param {string} keywords
1091
+ * Extract image bytes from a page as PNG data.
1092
+ *
1093
+ * Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
1094
+ * @param {number} page_index
1095
+ * @returns {any}
1487
1096
  */
1488
- setKeywords(keywords) {
1097
+ extractImageBytes(page_index) {
1489
1098
  try {
1490
1099
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1491
- const ptr0 = passStringToWasm0(keywords, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1492
- const len0 = WASM_VECTOR_LEN;
1493
- wasm.wasmpdfdocument_setKeywords(retptr, this.__wbg_ptr, ptr0, len0);
1100
+ wasm.wasmpdfdocument_extractImageBytes(retptr, this.__wbg_ptr, page_index);
1494
1101
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1495
1102
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1496
- if (r1) {
1497
- throw takeObject(r0);
1103
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1104
+ if (r2) {
1105
+ throw takeObject(r1);
1498
1106
  }
1107
+ return takeObject(r0);
1499
1108
  } finally {
1500
1109
  wasm.__wbindgen_add_to_stack_pointer(16);
1501
1110
  }
1502
1111
  }
1503
1112
  /**
1504
- * Get XMP metadata from the document.
1113
+ * Extract image metadata from a page.
1505
1114
  *
1506
- * @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
1115
+ * Returns an array of objects with: width, height, color_space,
1116
+ * bits_per_component, bbox (if available). Does NOT return raw image bytes.
1117
+ *
1118
+ * @param page_index - Zero-based page number
1119
+ * @param region - Optional [x, y, width, height] to filter by
1120
+ * @param {number} page_index
1121
+ * @param {Float32Array | null} [region]
1507
1122
  * @returns {any}
1508
1123
  */
1509
- xmpMetadata() {
1124
+ extractImages(page_index, region) {
1510
1125
  try {
1511
1126
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1512
- wasm.wasmpdfdocument_xmpMetadata(retptr, this.__wbg_ptr);
1127
+ var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1128
+ var len0 = WASM_VECTOR_LEN;
1129
+ wasm.wasmpdfdocument_extractImages(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1513
1130
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1514
1131
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1515
1132
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1522,46 +1139,104 @@ class WasmPdfDocument {
1522
1139
  }
1523
1140
  }
1524
1141
  /**
1525
- * Erase multiple rectangular regions on a page.
1142
+ * Extract only straight lines from a page (v0.3.14).
1143
+ *
1144
+ * Identifies paths that form a single straight line segment.
1526
1145
  *
1527
1146
  * @param page_index - Zero-based page number
1528
- * @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
1147
+ * @param region - Optional [x, y, width, height] to filter by
1148
+ * @returns Array of path objects
1529
1149
  * @param {number} page_index
1530
- * @param {Float32Array} rects
1150
+ * @param {Float32Array | null} [region]
1151
+ * @returns {any}
1531
1152
  */
1532
- eraseRegions(page_index, rects) {
1153
+ extractLines(page_index, region) {
1533
1154
  try {
1534
1155
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1535
- const ptr0 = passArrayF32ToWasm0(rects, wasm.__wbindgen_export);
1536
- const len0 = WASM_VECTOR_LEN;
1537
- wasm.wasmpdfdocument_eraseRegions(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1156
+ var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1157
+ var len0 = WASM_VECTOR_LEN;
1158
+ wasm.wasmpdfdocument_extractLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1538
1159
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1539
1160
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1540
- if (r1) {
1541
- throw takeObject(r0);
1161
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1162
+ if (r2) {
1163
+ throw takeObject(r1);
1542
1164
  }
1165
+ return takeObject(r0);
1543
1166
  } finally {
1544
1167
  wasm.__wbindgen_add_to_stack_pointer(16);
1545
1168
  }
1546
1169
  }
1547
1170
  /**
1548
- * Extract character-level data from a page.
1171
+ * Extract complete page text data in a single call.
1549
1172
  *
1550
- * Returns an array of objects with: char, bbox {x, y, width, height},
1551
- * font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
1173
+ * Returns `{ spans, chars, page_width, page_height }`.
1174
+ * The `chars` are derived from spans using font-metric widths when available.
1175
+ *
1176
+ * Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
1177
+ * or `"top_to_bottom"` (default).
1178
+ * @param {number} page_index
1179
+ * @param {string | null} [reading_order]
1180
+ * @returns {any}
1181
+ */
1182
+ extractPageText(page_index, reading_order) {
1183
+ try {
1184
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1185
+ var ptr0 = isLikeNone(reading_order) ? 0 : passStringToWasm0(reading_order, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1186
+ var len0 = WASM_VECTOR_LEN;
1187
+ wasm.wasmpdfdocument_extractPageText(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1188
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1189
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1190
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1191
+ if (r2) {
1192
+ throw takeObject(r1);
1193
+ }
1194
+ return takeObject(r0);
1195
+ } finally {
1196
+ wasm.__wbindgen_add_to_stack_pointer(16);
1197
+ }
1198
+ }
1199
+ /**
1200
+ * Extract specific pages to a new PDF (returns bytes).
1201
+ * @param {Uint32Array} pages
1202
+ * @returns {Uint8Array}
1203
+ */
1204
+ extractPages(pages) {
1205
+ try {
1206
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1207
+ const ptr0 = passArray32ToWasm0(pages, wasm.__wbindgen_export);
1208
+ const len0 = WASM_VECTOR_LEN;
1209
+ wasm.wasmpdfdocument_extractPages(retptr, this.__wbg_ptr, ptr0, len0);
1210
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1211
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1212
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1213
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1214
+ if (r3) {
1215
+ throw takeObject(r2);
1216
+ }
1217
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1218
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1219
+ return v2;
1220
+ } finally {
1221
+ wasm.__wbindgen_add_to_stack_pointer(16);
1222
+ }
1223
+ }
1224
+ /**
1225
+ * Extract vector paths (lines, curves, shapes) from a page.
1552
1226
  *
1553
1227
  * @param page_index - Zero-based page number
1554
1228
  * @param region - Optional [x, y, width, height] to filter by
1229
+ * @returns Array of path objects with bbox, stroke_color, fill_color, etc.
1555
1230
  * @param {number} page_index
1556
1231
  * @param {Float32Array | null} [region]
1557
1232
  * @returns {any}
1558
1233
  */
1559
- extractChars(page_index, region) {
1234
+ extractPaths(page_index, region) {
1560
1235
  try {
1561
1236
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1562
1237
  var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1563
1238
  var len0 = WASM_VECTOR_LEN;
1564
- wasm.wasmpdfdocument_extractChars(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1239
+ wasm.wasmpdfdocument_extractPaths(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1565
1240
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1566
1241
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1567
1242
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1574,9 +1249,9 @@ class WasmPdfDocument {
1574
1249
  }
1575
1250
  }
1576
1251
  /**
1577
- * Extract only straight lines from a page (v0.3.14).
1252
+ * Extract only rectangles from a page (v0.3.14).
1578
1253
  *
1579
- * Identifies paths that form a single straight line segment.
1254
+ * Identifies paths that form axis-aligned rectangles.
1580
1255
  *
1581
1256
  * @param page_index - Zero-based page number
1582
1257
  * @param region - Optional [x, y, width, height] to filter by
@@ -1585,12 +1260,12 @@ class WasmPdfDocument {
1585
1260
  * @param {Float32Array | null} [region]
1586
1261
  * @returns {any}
1587
1262
  */
1588
- extractLines(page_index, region) {
1263
+ extractRects(page_index, region) {
1589
1264
  try {
1590
1265
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1591
1266
  var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1592
1267
  var len0 = WASM_VECTOR_LEN;
1593
- wasm.wasmpdfdocument_extractLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1268
+ wasm.wasmpdfdocument_extractRects(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1594
1269
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1595
1270
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1596
1271
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1603,46 +1278,52 @@ class WasmPdfDocument {
1603
1278
  }
1604
1279
  }
1605
1280
  /**
1606
- * Extract specific pages to a new PDF (returns bytes).
1607
- * @param {Uint32Array} pages
1608
- * @returns {Uint8Array}
1281
+ * Extract span-level data from a page.
1282
+ *
1283
+ * Returns an array of objects with: text, bbox, font_name, font_size,
1284
+ * font_weight, is_italic, color, etc.
1285
+ *
1286
+ * Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
1287
+ * or `"top_to_bottom"` (default).
1288
+ * @param {number} page_index
1289
+ * @param {Float32Array | null} [region]
1290
+ * @param {string | null} [reading_order]
1291
+ * @returns {any}
1609
1292
  */
1610
- extractPages(pages) {
1293
+ extractSpans(page_index, region, reading_order) {
1611
1294
  try {
1612
1295
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1613
- const ptr0 = passArray32ToWasm0(pages, wasm.__wbindgen_export);
1614
- const len0 = WASM_VECTOR_LEN;
1615
- wasm.wasmpdfdocument_extractPages(retptr, this.__wbg_ptr, ptr0, len0);
1296
+ var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1297
+ var len0 = WASM_VECTOR_LEN;
1298
+ var ptr1 = isLikeNone(reading_order) ? 0 : passStringToWasm0(reading_order, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1299
+ var len1 = WASM_VECTOR_LEN;
1300
+ wasm.wasmpdfdocument_extractSpans(retptr, this.__wbg_ptr, page_index, ptr0, len0, ptr1, len1);
1616
1301
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1617
1302
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1618
1303
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1619
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1620
- if (r3) {
1621
- throw takeObject(r2);
1304
+ if (r2) {
1305
+ throw takeObject(r1);
1622
1306
  }
1623
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
1624
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1625
- return v2;
1307
+ return takeObject(r0);
1626
1308
  } finally {
1627
1309
  wasm.__wbindgen_add_to_stack_pointer(16);
1628
1310
  }
1629
1311
  }
1630
1312
  /**
1631
- * Extract vector paths (lines, curves, shapes) from a page.
1313
+ * Extract tables from a page (v0.3.14).
1632
1314
  *
1633
1315
  * @param page_index - Zero-based page number
1634
1316
  * @param region - Optional [x, y, width, height] to filter by
1635
- * @returns Array of path objects with bbox, stroke_color, fill_color, etc.
1636
1317
  * @param {number} page_index
1637
1318
  * @param {Float32Array | null} [region]
1638
1319
  * @returns {any}
1639
1320
  */
1640
- extractPaths(page_index, region) {
1321
+ extractTables(page_index, region) {
1641
1322
  try {
1642
1323
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1643
1324
  var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1644
1325
  var len0 = WASM_VECTOR_LEN;
1645
- wasm.wasmpdfdocument_extractPaths(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1326
+ wasm.wasmpdfdocument_extractTables(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1646
1327
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1647
1328
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1648
1329
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1655,49 +1336,52 @@ class WasmPdfDocument {
1655
1336
  }
1656
1337
  }
1657
1338
  /**
1658
- * Extract only rectangles from a page (v0.3.14).
1659
- *
1660
- * Identifies paths that form axis-aligned rectangles.
1339
+ * Extract plain text from a single page.
1661
1340
  *
1662
1341
  * @param page_index - Zero-based page number
1663
1342
  * @param region - Optional [x, y, width, height] to filter by
1664
- * @returns Array of path objects
1665
1343
  * @param {number} page_index
1666
- * @param {Float32Array | null} [region]
1667
- * @returns {any}
1344
+ * @param {any} region
1345
+ * @returns {string}
1668
1346
  */
1669
- extractRects(page_index, region) {
1347
+ extractText(page_index, region) {
1348
+ let deferred2_0;
1349
+ let deferred2_1;
1670
1350
  try {
1671
1351
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1672
- var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1673
- var len0 = WASM_VECTOR_LEN;
1674
- wasm.wasmpdfdocument_extractRects(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1352
+ wasm.wasmpdfdocument_extractText(retptr, this.__wbg_ptr, page_index, addHeapObject(region));
1675
1353
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1676
1354
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1677
1355
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1678
- if (r2) {
1679
- throw takeObject(r1);
1356
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1357
+ var ptr1 = r0;
1358
+ var len1 = r1;
1359
+ if (r3) {
1360
+ ptr1 = 0; len1 = 0;
1361
+ throw takeObject(r2);
1680
1362
  }
1681
- return takeObject(r0);
1363
+ deferred2_0 = ptr1;
1364
+ deferred2_1 = len1;
1365
+ return getStringFromWasm0(ptr1, len1);
1682
1366
  } finally {
1683
1367
  wasm.__wbindgen_add_to_stack_pointer(16);
1368
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1684
1369
  }
1685
1370
  }
1686
1371
  /**
1687
- * Extract span-level data from a page.
1372
+ * Extract text lines from a page.
1688
1373
  *
1689
- * Returns an array of objects with: text, bbox, font_name, font_size,
1690
- * font_weight, is_italic, color, etc.
1374
+ * Returns an array of objects with: text, bbox, words (array of Word objects).
1691
1375
  * @param {number} page_index
1692
1376
  * @param {Float32Array | null} [region]
1693
1377
  * @returns {any}
1694
1378
  */
1695
- extractSpans(page_index, region) {
1379
+ extractTextLines(page_index, region) {
1696
1380
  try {
1697
1381
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1698
1382
  var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1699
1383
  var len0 = WASM_VECTOR_LEN;
1700
- wasm.wasmpdfdocument_extractSpans(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1384
+ wasm.wasmpdfdocument_extractTextLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1701
1385
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1702
1386
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1703
1387
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1709,6 +1393,44 @@ class WasmPdfDocument {
1709
1393
  wasm.__wbindgen_add_to_stack_pointer(16);
1710
1394
  }
1711
1395
  }
1396
+ /**
1397
+ * Extract text using OCR (optical character recognition).
1398
+ *
1399
+ * NOTE: OCR is not yet supported in the WebAssembly build due to missing
1400
+ * ONNX Runtime support for the web backend in the current implementation.
1401
+ * @param {number} _page_index
1402
+ * @param {WasmOcrEngine | null} [_engine]
1403
+ * @returns {string}
1404
+ */
1405
+ extractTextOcr(_page_index, _engine) {
1406
+ let deferred3_0;
1407
+ let deferred3_1;
1408
+ try {
1409
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1410
+ let ptr0 = 0;
1411
+ if (!isLikeNone(_engine)) {
1412
+ _assertClass(_engine, WasmOcrEngine);
1413
+ ptr0 = _engine.__destroy_into_raw();
1414
+ }
1415
+ wasm.wasmpdfdocument_extractTextOcr(retptr, this.__wbg_ptr, _page_index, ptr0);
1416
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1417
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1418
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1419
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1420
+ var ptr2 = r0;
1421
+ var len2 = r1;
1422
+ if (r3) {
1423
+ ptr2 = 0; len2 = 0;
1424
+ throw takeObject(r2);
1425
+ }
1426
+ deferred3_0 = ptr2;
1427
+ deferred3_1 = len2;
1428
+ return getStringFromWasm0(ptr2, len2);
1429
+ } finally {
1430
+ wasm.__wbindgen_add_to_stack_pointer(16);
1431
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1432
+ }
1433
+ }
1712
1434
  /**
1713
1435
  * Extract word-level data from a page.
1714
1436
  *
@@ -1735,6 +1457,22 @@ class WasmPdfDocument {
1735
1457
  wasm.__wbindgen_add_to_stack_pointer(16);
1736
1458
  }
1737
1459
  }
1460
+ /**
1461
+ * Flatten all annotations in the document into page content.
1462
+ */
1463
+ flattenAllAnnotations() {
1464
+ try {
1465
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1466
+ wasm.wasmpdfdocument_flattenAllAnnotations(retptr, this.__wbg_ptr);
1467
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1468
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1469
+ if (r1) {
1470
+ throw takeObject(r0);
1471
+ }
1472
+ } finally {
1473
+ wasm.__wbindgen_add_to_stack_pointer(16);
1474
+ }
1475
+ }
1738
1476
  /**
1739
1477
  * Flatten all form fields into page content.
1740
1478
  *
@@ -1754,117 +1492,130 @@ class WasmPdfDocument {
1754
1492
  }
1755
1493
  }
1756
1494
  /**
1757
- * Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
1495
+ * Flatten form fields on a specific page.
1496
+ *
1497
+ * @param page_index - Zero-based page number
1758
1498
  * @param {number} page_index
1759
- * @returns {any}
1760
1499
  */
1761
- pageCropBox(page_index) {
1500
+ flattenFormsOnPage(page_index) {
1762
1501
  try {
1763
1502
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1764
- wasm.wasmpdfdocument_pageCropBox(retptr, this.__wbg_ptr, page_index);
1503
+ wasm.wasmpdfdocument_flattenFormsOnPage(retptr, this.__wbg_ptr, page_index);
1765
1504
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1766
1505
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1767
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1768
- if (r2) {
1769
- throw takeObject(r1);
1506
+ if (r1) {
1507
+ throw takeObject(r0);
1770
1508
  }
1771
- return takeObject(r0);
1772
1509
  } finally {
1773
1510
  wasm.__wbindgen_add_to_stack_pointer(16);
1774
1511
  }
1775
1512
  }
1776
1513
  /**
1777
- * Get the rotation of a page in degrees (0, 90, 180, 270).
1514
+ * Flatten annotations on a page into the page content.
1778
1515
  * @param {number} page_index
1779
- * @returns {number}
1780
1516
  */
1781
- pageRotation(page_index) {
1517
+ flattenPageAnnotations(page_index) {
1782
1518
  try {
1783
1519
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1784
- wasm.wasmpdfdocument_pageRotation(retptr, this.__wbg_ptr, page_index);
1520
+ wasm.wasmpdfdocument_flattenPageAnnotations(retptr, this.__wbg_ptr, page_index);
1521
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1522
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1523
+ if (r1) {
1524
+ throw takeObject(r0);
1525
+ }
1526
+ } finally {
1527
+ wasm.__wbindgen_add_to_stack_pointer(16);
1528
+ }
1529
+ }
1530
+ /**
1531
+ * Get annotations from a page.
1532
+ *
1533
+ * @param page_index - Zero-based page number
1534
+ * @returns Array of annotation objects with fields like subtype, rect, contents, etc.
1535
+ * @param {number} page_index
1536
+ * @returns {any}
1537
+ */
1538
+ getAnnotations(page_index) {
1539
+ try {
1540
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1541
+ wasm.wasmpdfdocument_getAnnotations(retptr, this.__wbg_ptr, page_index);
1785
1542
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1786
1543
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1787
1544
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1788
1545
  if (r2) {
1789
1546
  throw takeObject(r1);
1790
1547
  }
1791
- return r0;
1548
+ return takeObject(r0);
1792
1549
  } finally {
1793
1550
  wasm.__wbindgen_add_to_stack_pointer(16);
1794
1551
  }
1795
1552
  }
1796
1553
  /**
1797
- * Save the modified PDF and return as bytes.
1798
- * `saveToBytes()` is the original method; `save()` is a convenience alias.
1554
+ * Get the value of a specific form field by name.
1799
1555
  *
1800
- * @returns Uint8Array containing the modified PDF
1801
- * @returns {Uint8Array}
1556
+ * @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
1557
+ * @returns The field value: string for text, boolean for checkbox, null if not found
1558
+ * @param {string} name
1559
+ * @returns {any}
1802
1560
  */
1803
- saveToBytes() {
1561
+ getFormFieldValue(name) {
1804
1562
  try {
1805
1563
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1806
- wasm.wasmpdfdocument_save(retptr, this.__wbg_ptr);
1564
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1565
+ const len0 = WASM_VECTOR_LEN;
1566
+ wasm.wasmpdfdocument_getFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0);
1807
1567
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1808
1568
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1809
1569
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1810
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1811
- if (r3) {
1812
- throw takeObject(r2);
1570
+ if (r2) {
1571
+ throw takeObject(r1);
1813
1572
  }
1814
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
1815
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1816
- return v1;
1573
+ return takeObject(r0);
1817
1574
  } finally {
1818
1575
  wasm.__wbindgen_add_to_stack_pointer(16);
1819
1576
  }
1820
1577
  }
1821
1578
  /**
1822
- * Convert a single page to plain text (with layout preservation options).
1823
- * @param {number} page_index
1824
- * @returns {string}
1579
+ * Get all form fields from the document.
1580
+ *
1581
+ * Returns an array of form field objects, each with:
1582
+ * - name: Full qualified field name
1583
+ * - field_type: "text", "button", "choice", "signature", or "unknown"
1584
+ * - value: string, boolean, array of strings, or null
1585
+ * - tooltip: string or null
1586
+ * - bounds: [x1, y1, x2, y2] or null
1587
+ * - flags: number or null
1588
+ * - max_length: number or null
1589
+ * - is_readonly: boolean
1590
+ * - is_required: boolean
1591
+ * @returns {any}
1825
1592
  */
1826
- toPlainText(page_index) {
1827
- let deferred2_0;
1828
- let deferred2_1;
1593
+ getFormFields() {
1829
1594
  try {
1830
1595
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1831
- wasm.wasmpdfdocument_toPlainText(retptr, this.__wbg_ptr, page_index);
1596
+ wasm.wasmpdfdocument_getFormFields(retptr, this.__wbg_ptr);
1832
1597
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1833
1598
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1834
1599
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1835
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1836
- var ptr1 = r0;
1837
- var len1 = r1;
1838
- if (r3) {
1839
- ptr1 = 0; len1 = 0;
1840
- throw takeObject(r2);
1600
+ if (r2) {
1601
+ throw takeObject(r1);
1841
1602
  }
1842
- deferred2_0 = ptr1;
1843
- deferred2_1 = len1;
1844
- return getStringFromWasm0(ptr1, len1);
1603
+ return takeObject(r0);
1845
1604
  } finally {
1846
1605
  wasm.__wbindgen_add_to_stack_pointer(16);
1847
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1848
1606
  }
1849
1607
  }
1850
1608
  /**
1851
- * Extract image metadata from a page.
1852
- *
1853
- * Returns an array of objects with: width, height, color_space,
1854
- * bits_per_component, bbox (if available). Does NOT return raw image bytes.
1609
+ * Get the document outline (bookmarks / table of contents).
1855
1610
  *
1856
- * @param page_index - Zero-based page number
1857
- * @param region - Optional [x, y, width, height] to filter by
1858
- * @param {number} page_index
1859
- * @param {Float32Array | null} [region]
1611
+ * @returns Array of outline items or null if no outline exists.
1612
+ * Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
1860
1613
  * @returns {any}
1861
1614
  */
1862
- extractImages(page_index, region) {
1615
+ getOutline() {
1863
1616
  try {
1864
1617
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1865
- var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1866
- var len0 = WASM_VECTOR_LEN;
1867
- wasm.wasmpdfdocument_extractImages(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1618
+ wasm.wasmpdfdocument_getOutline(retptr, this.__wbg_ptr);
1868
1619
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1869
1620
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1870
1621
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1877,68 +1628,59 @@ class WasmPdfDocument {
1877
1628
  }
1878
1629
  }
1879
1630
  /**
1880
- * Extract tables from a page (v0.3.14).
1881
- *
1882
- * @param page_index - Zero-based page number
1883
- * @param region - Optional [x, y, width, height] to filter by
1884
- * @param {number} page_index
1885
- * @param {Float32Array | null} [region]
1886
- * @returns {any}
1631
+ * Check if the document has a structure tree (Tagged PDF).
1632
+ * @returns {boolean}
1887
1633
  */
1888
- extractTables(page_index, region) {
1634
+ hasStructureTree() {
1889
1635
  try {
1890
1636
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1891
- var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
1892
- var len0 = WASM_VECTOR_LEN;
1893
- wasm.wasmpdfdocument_extractTables(retptr, this.__wbg_ptr, page_index, ptr0, len0);
1637
+ wasm.wasmpdfdocument_hasStructureTree(retptr, this.__wbg_ptr);
1894
1638
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1895
1639
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1896
1640
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1897
1641
  if (r2) {
1898
1642
  throw takeObject(r1);
1899
1643
  }
1900
- return takeObject(r0);
1644
+ return r0 !== 0;
1901
1645
  } finally {
1902
1646
  wasm.__wbindgen_add_to_stack_pointer(16);
1903
1647
  }
1904
1648
  }
1905
1649
  /**
1906
- * Get the MediaBox of a page as [llx, lly, urx, ury].
1907
- * @param {number} page_index
1908
- * @returns {Float32Array}
1650
+ * Check if the document contains XFA form data.
1651
+ *
1652
+ * @returns true if the document has XFA form data
1653
+ * @returns {boolean}
1909
1654
  */
1910
- pageMediaBox(page_index) {
1655
+ hasXfa() {
1911
1656
  try {
1912
1657
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1913
- wasm.wasmpdfdocument_pageMediaBox(retptr, this.__wbg_ptr, page_index);
1658
+ wasm.wasmpdfdocument_hasXfa(retptr, this.__wbg_ptr);
1914
1659
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1915
1660
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1916
1661
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1917
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1918
- if (r3) {
1919
- throw takeObject(r2);
1662
+ if (r2) {
1663
+ throw takeObject(r1);
1920
1664
  }
1921
- var v1 = getArrayF32FromWasm0(r0, r1).slice();
1922
- wasm.__wbindgen_export4(r0, r1 * 4, 4);
1923
- return v1;
1665
+ return r0 !== 0;
1924
1666
  } finally {
1925
1667
  wasm.__wbindgen_add_to_stack_pointer(16);
1926
1668
  }
1927
1669
  }
1928
1670
  /**
1929
- * Identify and remove footers.
1930
- *
1931
- * Uses spec-compliant /Artifact tags when available (100% accuracy), or
1932
- * falls back to heuristic analysis of the bottom 15% of pages.
1671
+ * Merge another PDF (provided as bytes) into this document.
1933
1672
  *
1934
- * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
1935
- * @param {number} threshold
1673
+ * @param data - The PDF file contents to merge as a Uint8Array
1674
+ * @returns Number of pages merged
1675
+ * @param {Uint8Array} data
1936
1676
  * @returns {number}
1937
1677
  */
1938
- removeFooters(threshold) {
1678
+ mergeFrom(data) {
1939
1679
  try {
1940
1680
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1941
- wasm.wasmpdfdocument_removeFooters(retptr, this.__wbg_ptr, threshold);
1681
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1682
+ const len0 = WASM_VECTOR_LEN;
1683
+ wasm.wasmpdfdocument_mergeFrom(retptr, this.__wbg_ptr, ptr0, len0);
1942
1684
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1943
1685
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1944
1686
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1951,83 +1693,85 @@ class WasmPdfDocument {
1951
1693
  }
1952
1694
  }
1953
1695
  /**
1954
- * Identify and remove headers.
1955
- *
1956
- * Uses spec-compliant /Artifact tags when available (100% accuracy), or
1957
- * falls back to heuristic analysis of the top 15% of pages.
1696
+ * Load a PDF document from raw bytes.
1958
1697
  *
1959
- * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
1960
- * @param {number} threshold
1961
- * @returns {number}
1698
+ * @param data - PDF file contents as Uint8Array
1699
+ * @param password - Optional password for encrypted PDFs
1700
+ * @throws Error if the PDF is invalid or cannot be parsed
1701
+ * @param {Uint8Array} data
1702
+ * @param {string | null} [password]
1962
1703
  */
1963
- removeHeaders(threshold) {
1704
+ constructor(data, password) {
1964
1705
  try {
1965
1706
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1966
- wasm.wasmpdfdocument_removeHeaders(retptr, this.__wbg_ptr, threshold);
1707
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1708
+ const len0 = WASM_VECTOR_LEN;
1709
+ var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1710
+ var len1 = WASM_VECTOR_LEN;
1711
+ wasm.wasmpdfdocument_new(retptr, ptr0, len0, ptr1, len1);
1967
1712
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1968
1713
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1969
1714
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1970
1715
  if (r2) {
1971
1716
  throw takeObject(r1);
1972
1717
  }
1973
- return r0 >>> 0;
1718
+ this.__wbg_ptr = r0 >>> 0;
1719
+ WasmPdfDocumentFinalization.register(this, this.__wbg_ptr, this);
1720
+ return this;
1974
1721
  } finally {
1975
1722
  wasm.__wbindgen_add_to_stack_pointer(16);
1976
1723
  }
1977
1724
  }
1978
1725
  /**
1979
- * Validate PDF/A compliance. Level: "1b", "2b", etc.
1980
- * @param {string} level
1981
- * @returns {any}
1726
+ * Get the number of pages in the document.
1727
+ * @returns {number}
1982
1728
  */
1983
- validatePdfA(level) {
1729
+ pageCount() {
1984
1730
  try {
1985
1731
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1986
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1987
- const len0 = WASM_VECTOR_LEN;
1988
- wasm.wasmpdfdocument_validatePdfA(retptr, this.__wbg_ptr, ptr0, len0);
1732
+ wasm.wasmpdfdocument_pageCount(retptr, this.__wbg_ptr);
1989
1733
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1990
1734
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1991
1735
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1992
1736
  if (r2) {
1993
1737
  throw takeObject(r1);
1994
1738
  }
1995
- return takeObject(r0);
1739
+ return r0 >>> 0;
1996
1740
  } finally {
1997
1741
  wasm.__wbindgen_add_to_stack_pointer(16);
1998
1742
  }
1999
1743
  }
2000
1744
  /**
2001
- * Erase both header and footer content.
2002
- *
2003
- * @param page_index - Zero-based page number
1745
+ * Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
2004
1746
  * @param {number} page_index
1747
+ * @returns {any}
2005
1748
  */
2006
- eraseArtifacts(page_index) {
1749
+ pageCropBox(page_index) {
2007
1750
  try {
2008
1751
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2009
- wasm.wasmpdfdocument_eraseArtifacts(retptr, this.__wbg_ptr, page_index);
1752
+ wasm.wasmpdfdocument_pageCropBox(retptr, this.__wbg_ptr, page_index);
2010
1753
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2011
1754
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2012
- if (r1) {
2013
- throw takeObject(r0);
1755
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1756
+ if (r2) {
1757
+ throw takeObject(r1);
2014
1758
  }
1759
+ return takeObject(r0);
2015
1760
  } finally {
2016
1761
  wasm.__wbindgen_add_to_stack_pointer(16);
2017
1762
  }
2018
1763
  }
2019
1764
  /**
2020
- * Get annotations from a page.
1765
+ * Get information about images on a page.
2021
1766
  *
2022
- * @param page_index - Zero-based page number
2023
- * @returns Array of annotation objects with fields like subtype, rect, contents, etc.
1767
+ * Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
2024
1768
  * @param {number} page_index
2025
1769
  * @returns {any}
2026
1770
  */
2027
- getAnnotations(page_index) {
1771
+ pageImages(page_index) {
2028
1772
  try {
2029
1773
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2030
- wasm.wasmpdfdocument_getAnnotations(retptr, this.__wbg_ptr, page_index);
1774
+ wasm.wasmpdfdocument_pageImages(retptr, this.__wbg_ptr, page_index);
2031
1775
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2032
1776
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2033
1777
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2040,24 +1784,15 @@ class WasmPdfDocument {
2040
1784
  }
2041
1785
  }
2042
1786
  /**
2043
- * Get all form fields from the document.
1787
+ * Get page label ranges from the document.
2044
1788
  *
2045
- * Returns an array of form field objects, each with:
2046
- * - name: Full qualified field name
2047
- * - field_type: "text", "button", "choice", "signature", or "unknown"
2048
- * - value: string, boolean, array of strings, or null
2049
- * - tooltip: string or null
2050
- * - bounds: [x1, y1, x2, y2] or null
2051
- * - flags: number or null
2052
- * - max_length: number or null
2053
- * - is_readonly: boolean
2054
- * - is_required: boolean
1789
+ * @returns Array of {start_page, style, prefix, start_value} objects, or empty array
2055
1790
  * @returns {any}
2056
1791
  */
2057
- getFormFields() {
1792
+ pageLabels() {
2058
1793
  try {
2059
1794
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2060
- wasm.wasmpdfdocument_getFormFields(retptr, this.__wbg_ptr);
1795
+ wasm.wasmpdfdocument_pageLabels(retptr, this.__wbg_ptr);
2061
1796
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2062
1797
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2063
1798
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2070,144 +1805,112 @@ class WasmPdfDocument {
2070
1805
  }
2071
1806
  }
2072
1807
  /**
2073
- * Convert all pages to Markdown.
2074
- * @param {boolean | null} [detect_headings]
2075
- * @param {boolean | null} [include_images]
2076
- * @param {boolean | null} [include_form_fields]
2077
- * @returns {string}
1808
+ * Get the MediaBox of a page as [llx, lly, urx, ury].
1809
+ * @param {number} page_index
1810
+ * @returns {Float32Array}
2078
1811
  */
2079
- toMarkdownAll(detect_headings, include_images, include_form_fields) {
2080
- let deferred2_0;
2081
- let deferred2_1;
1812
+ pageMediaBox(page_index) {
2082
1813
  try {
2083
1814
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2084
- wasm.wasmpdfdocument_toMarkdownAll(retptr, this.__wbg_ptr, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_images) ? 0xFFFFFF : include_images ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
1815
+ wasm.wasmpdfdocument_pageMediaBox(retptr, this.__wbg_ptr, page_index);
2085
1816
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2086
1817
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2087
1818
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2088
1819
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2089
- var ptr1 = r0;
2090
- var len1 = r1;
2091
1820
  if (r3) {
2092
- ptr1 = 0; len1 = 0;
2093
1821
  throw takeObject(r2);
2094
1822
  }
2095
- deferred2_0 = ptr1;
2096
- deferred2_1 = len1;
2097
- return getStringFromWasm0(ptr1, len1);
1823
+ var v1 = getArrayF32FromWasm0(r0, r1).slice();
1824
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
1825
+ return v1;
2098
1826
  } finally {
2099
1827
  wasm.__wbindgen_add_to_stack_pointer(16);
2100
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2101
1828
  }
2102
1829
  }
2103
1830
  /**
2104
- * Export form field data as FDF or XFDF bytes.
2105
- *
2106
- * @param format - "fdf" or "xfdf" (default: "fdf")
2107
- * @returns Uint8Array containing the exported form data
2108
- * @param {string | null} [format]
2109
- * @returns {Uint8Array}
1831
+ * Get the rotation of a page in degrees (0, 90, 180, 270).
1832
+ * @param {number} page_index
1833
+ * @returns {number}
2110
1834
  */
2111
- exportFormData(format) {
1835
+ pageRotation(page_index) {
2112
1836
  try {
2113
1837
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2114
- var ptr0 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2115
- var len0 = WASM_VECTOR_LEN;
2116
- wasm.wasmpdfdocument_exportFormData(retptr, this.__wbg_ptr, ptr0, len0);
1838
+ wasm.wasmpdfdocument_pageRotation(retptr, this.__wbg_ptr, page_index);
2117
1839
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2118
1840
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2119
1841
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2120
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2121
- if (r3) {
2122
- throw takeObject(r2);
1842
+ if (r2) {
1843
+ throw takeObject(r1);
2123
1844
  }
2124
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
2125
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
2126
- return v2;
1845
+ return r0;
2127
1846
  } finally {
2128
1847
  wasm.__wbindgen_add_to_stack_pointer(16);
2129
1848
  }
2130
1849
  }
2131
1850
  /**
2132
- * Extract plain text from all pages, separated by form feed characters.
2133
- * @returns {string}
1851
+ * Identify and remove both headers and footers.
1852
+ *
1853
+ * Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
1854
+ * fallback for untagged PDFs.
1855
+ *
1856
+ * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
1857
+ * @param {number} threshold
1858
+ * @returns {number}
2134
1859
  */
2135
- extractAllText() {
2136
- let deferred2_0;
2137
- let deferred2_1;
1860
+ removeArtifacts(threshold) {
2138
1861
  try {
2139
1862
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2140
- wasm.wasmpdfdocument_extractAllText(retptr, this.__wbg_ptr);
1863
+ wasm.wasmpdfdocument_removeArtifacts(retptr, this.__wbg_ptr, threshold);
2141
1864
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2142
1865
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2143
1866
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2144
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2145
- var ptr1 = r0;
2146
- var len1 = r1;
2147
- if (r3) {
2148
- ptr1 = 0; len1 = 0;
2149
- throw takeObject(r2);
1867
+ if (r2) {
1868
+ throw takeObject(r1);
2150
1869
  }
2151
- deferred2_0 = ptr1;
2152
- deferred2_1 = len1;
2153
- return getStringFromWasm0(ptr1, len1);
1870
+ return r0 >>> 0;
2154
1871
  } finally {
2155
1872
  wasm.__wbindgen_add_to_stack_pointer(16);
2156
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2157
1873
  }
2158
1874
  }
2159
1875
  /**
2160
- * Extract text using OCR (optical character recognition).
1876
+ * Identify and remove footers.
2161
1877
  *
2162
- * NOTE: OCR is not yet supported in the WebAssembly build due to missing
2163
- * ONNX Runtime support for the web backend in the current implementation.
2164
- * @param {number} _page_index
2165
- * @param {WasmOcrEngine | null} [_engine]
2166
- * @returns {string}
1878
+ * Uses spec-compliant /Artifact tags when available (100% accuracy), or
1879
+ * falls back to heuristic analysis of the bottom 15% of pages.
1880
+ *
1881
+ * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
1882
+ * @param {number} threshold
1883
+ * @returns {number}
2167
1884
  */
2168
- extractTextOcr(_page_index, _engine) {
2169
- let deferred3_0;
2170
- let deferred3_1;
1885
+ removeFooters(threshold) {
2171
1886
  try {
2172
1887
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2173
- let ptr0 = 0;
2174
- if (!isLikeNone(_engine)) {
2175
- _assertClass(_engine, WasmOcrEngine);
2176
- ptr0 = _engine.__destroy_into_raw();
2177
- }
2178
- wasm.wasmpdfdocument_extractTextOcr(retptr, this.__wbg_ptr, _page_index, ptr0);
1888
+ wasm.wasmpdfdocument_removeFooters(retptr, this.__wbg_ptr, threshold);
2179
1889
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2180
1890
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2181
1891
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2182
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2183
- var ptr2 = r0;
2184
- var len2 = r1;
2185
- if (r3) {
2186
- ptr2 = 0; len2 = 0;
2187
- throw takeObject(r2);
1892
+ if (r2) {
1893
+ throw takeObject(r1);
2188
1894
  }
2189
- deferred3_0 = ptr2;
2190
- deferred3_1 = len2;
2191
- return getStringFromWasm0(ptr2, len2);
1895
+ return r0 >>> 0;
2192
1896
  } finally {
2193
1897
  wasm.__wbindgen_add_to_stack_pointer(16);
2194
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
2195
1898
  }
2196
1899
  }
2197
1900
  /**
2198
- * Identify and remove both headers and footers.
1901
+ * Identify and remove headers.
2199
1902
  *
2200
- * Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
2201
- * fallback for untagged PDFs.
1903
+ * Uses spec-compliant /Artifact tags when available (100% accuracy), or
1904
+ * falls back to heuristic analysis of the top 15% of pages.
2202
1905
  *
2203
1906
  * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
2204
1907
  * @param {number} threshold
2205
1908
  * @returns {number}
2206
1909
  */
2207
- removeArtifacts(threshold) {
1910
+ removeHeaders(threshold) {
2208
1911
  try {
2209
1912
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2210
- wasm.wasmpdfdocument_removeArtifacts(retptr, this.__wbg_ptr, threshold);
1913
+ wasm.wasmpdfdocument_removeHeaders(retptr, this.__wbg_ptr, threshold);
2211
1914
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2212
1915
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2213
1916
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2242,37 +1945,18 @@ class WasmPdfDocument {
2242
1945
  }
2243
1946
  }
2244
1947
  /**
2245
- * Rotate all pages by the given degrees.
2246
- * @param {number} degrees
2247
- */
2248
- rotateAllPages(degrees) {
2249
- try {
2250
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2251
- wasm.wasmpdfdocument_rotateAllPages(retptr, this.__wbg_ptr, degrees);
2252
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2253
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2254
- if (r1) {
2255
- throw takeObject(r0);
2256
- }
2257
- } finally {
2258
- wasm.__wbindgen_add_to_stack_pointer(16);
2259
- }
2260
- }
2261
- /**
2262
- * Set the complete bounds of an image on a page.
1948
+ * Resize an image on a page.
2263
1949
  * @param {number} page_index
2264
1950
  * @param {string} name
2265
- * @param {number} x
2266
- * @param {number} y
2267
1951
  * @param {number} width
2268
1952
  * @param {number} height
2269
1953
  */
2270
- setImageBounds(page_index, name, x, y, width, height) {
1954
+ resizeImage(page_index, name, width, height) {
2271
1955
  try {
2272
1956
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2273
1957
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2274
1958
  const len0 = WASM_VECTOR_LEN;
2275
- wasm.wasmpdfdocument_setImageBounds(retptr, this.__wbg_ptr, page_index, ptr0, len0, x, y, width, height);
1959
+ wasm.wasmpdfdocument_resizeImage(retptr, this.__wbg_ptr, page_index, ptr0, len0, width, height);
2276
1960
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2277
1961
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2278
1962
  if (r1) {
@@ -2283,17 +1967,13 @@ class WasmPdfDocument {
2283
1967
  }
2284
1968
  }
2285
1969
  /**
2286
- * Set the CropBox of a page.
2287
- * @param {number} page_index
2288
- * @param {number} llx
2289
- * @param {number} lly
2290
- * @param {number} urx
2291
- * @param {number} ury
1970
+ * Rotate all pages by the given degrees.
1971
+ * @param {number} degrees
2292
1972
  */
2293
- setPageCropBox(page_index, llx, lly, urx, ury) {
1973
+ rotateAllPages(degrees) {
2294
1974
  try {
2295
1975
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2296
- wasm.wasmpdfdocument_setPageCropBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
1976
+ wasm.wasmpdfdocument_rotateAllPages(retptr, this.__wbg_ptr, degrees);
2297
1977
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2298
1978
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2299
1979
  if (r1) {
@@ -2304,14 +1984,14 @@ class WasmPdfDocument {
2304
1984
  }
2305
1985
  }
2306
1986
  /**
2307
- * Set the rotation of a page (0, 90, 180, or 270 degrees).
1987
+ * Rotate a page by the given degrees (adds to current rotation).
2308
1988
  * @param {number} page_index
2309
1989
  * @param {number} degrees
2310
1990
  */
2311
- setPageRotation(page_index, degrees) {
1991
+ rotatePage(page_index, degrees) {
2312
1992
  try {
2313
1993
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2314
- wasm.wasmpdfdocument_setPageRotation(retptr, this.__wbg_ptr, page_index, degrees);
1994
+ wasm.wasmpdfdocument_rotatePage(retptr, this.__wbg_ptr, page_index, degrees);
2315
1995
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2316
1996
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2317
1997
  if (r1) {
@@ -2322,144 +2002,180 @@ class WasmPdfDocument {
2322
2002
  }
2323
2003
  }
2324
2004
  /**
2325
- * Convert all pages to plain text.
2326
- * @returns {string}
2005
+ * Save all edits and return the resulting PDF as bytes.
2006
+ *
2007
+ * @returns Uint8Array containing the modified PDF
2008
+ * @returns {Uint8Array}
2327
2009
  */
2328
- toPlainTextAll() {
2329
- let deferred2_0;
2330
- let deferred2_1;
2010
+ save() {
2331
2011
  try {
2332
2012
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2333
- wasm.wasmpdfdocument_toPlainTextAll(retptr, this.__wbg_ptr);
2013
+ wasm.wasmpdfdocument_save(retptr, this.__wbg_ptr);
2334
2014
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2335
2015
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2336
2016
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2337
2017
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2338
- var ptr1 = r0;
2339
- var len1 = r1;
2340
2018
  if (r3) {
2341
- ptr1 = 0; len1 = 0;
2342
2019
  throw takeObject(r2);
2343
2020
  }
2344
- deferred2_0 = ptr1;
2345
- deferred2_1 = len1;
2346
- return getStringFromWasm0(ptr1, len1);
2021
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2022
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2023
+ return v1;
2347
2024
  } finally {
2348
2025
  wasm.__wbindgen_add_to_stack_pointer(16);
2349
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2350
2026
  }
2351
2027
  }
2352
2028
  /**
2353
- * Extract text lines from a page.
2354
- *
2355
- * Returns an array of objects with: text, bbox, words (array of Word objects).
2356
- * @param {number} page_index
2357
- * @param {Float32Array | null} [region]
2358
- * @returns {any}
2029
+ * Save with encryption and return the resulting PDF as bytes.
2030
+ * @param {string} user_password
2031
+ * @param {string | null} [owner_password]
2032
+ * @param {boolean | null} [allow_print]
2033
+ * @param {boolean | null} [allow_copy]
2034
+ * @param {boolean | null} [allow_modify]
2035
+ * @param {boolean | null} [allow_annotate]
2036
+ * @returns {Uint8Array}
2359
2037
  */
2360
- extractTextLines(page_index, region) {
2038
+ saveEncryptedToBytes(user_password, owner_password, allow_print, allow_copy, allow_modify, allow_annotate) {
2361
2039
  try {
2362
2040
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2363
- var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
2364
- var len0 = WASM_VECTOR_LEN;
2365
- wasm.wasmpdfdocument_extractTextLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
2041
+ const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2042
+ const len0 = WASM_VECTOR_LEN;
2043
+ var ptr1 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2044
+ var len1 = WASM_VECTOR_LEN;
2045
+ wasm.wasmpdfdocument_saveEncryptedToBytes(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(allow_print) ? 0xFFFFFF : allow_print ? 1 : 0, isLikeNone(allow_copy) ? 0xFFFFFF : allow_copy ? 1 : 0, isLikeNone(allow_modify) ? 0xFFFFFF : allow_modify ? 1 : 0, isLikeNone(allow_annotate) ? 0xFFFFFF : allow_annotate ? 1 : 0);
2366
2046
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2367
2047
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2368
2048
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2369
- if (r2) {
2370
- throw takeObject(r1);
2049
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2050
+ if (r3) {
2051
+ throw takeObject(r2);
2371
2052
  }
2372
- return takeObject(r0);
2053
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
2054
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2055
+ return v3;
2373
2056
  } finally {
2374
2057
  wasm.__wbindgen_add_to_stack_pointer(16);
2375
2058
  }
2376
2059
  }
2377
2060
  /**
2378
- * Check if the document has a structure tree (Tagged PDF).
2379
- * @returns {boolean}
2061
+ * Save the modified PDF and return as bytes.
2062
+ * `saveToBytes()` is the original method; `save()` is a convenience alias.
2063
+ *
2064
+ * @returns Uint8Array containing the modified PDF
2065
+ * @returns {Uint8Array}
2380
2066
  */
2381
- hasStructureTree() {
2067
+ saveToBytes() {
2382
2068
  try {
2383
2069
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2384
- wasm.wasmpdfdocument_hasStructureTree(retptr, this.__wbg_ptr);
2070
+ wasm.wasmpdfdocument_saveToBytes(retptr, this.__wbg_ptr);
2385
2071
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2386
2072
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2387
2073
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2388
- if (r2) {
2389
- throw takeObject(r1);
2074
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2075
+ if (r3) {
2076
+ throw takeObject(r2);
2390
2077
  }
2391
- return r0 !== 0;
2078
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2079
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2080
+ return v1;
2392
2081
  } finally {
2393
2082
  wasm.__wbindgen_add_to_stack_pointer(16);
2394
2083
  }
2395
2084
  }
2396
2085
  /**
2397
- * Set the MediaBox of a page.
2398
- * @param {number} page_index
2399
- * @param {number} llx
2400
- * @param {number} lly
2401
- * @param {number} urx
2402
- * @param {number} ury
2086
+ * Search for text across all pages.
2087
+ *
2088
+ * @param pattern - Regex pattern or literal text to search for
2089
+ * @param case_insensitive - Case insensitive search (default: false)
2090
+ * @param literal - Treat pattern as literal text, not regex (default: false)
2091
+ * @param whole_word - Match whole words only (default: false)
2092
+ * @param max_results - Maximum results to return, 0 = unlimited (default: 0)
2093
+ *
2094
+ * Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
2095
+ * @param {string} pattern
2096
+ * @param {boolean | null} [case_insensitive]
2097
+ * @param {boolean | null} [literal]
2098
+ * @param {boolean | null} [whole_word]
2099
+ * @param {number | null} [max_results]
2100
+ * @returns {any}
2403
2101
  */
2404
- setPageMediaBox(page_index, llx, lly, urx, ury) {
2102
+ search(pattern, case_insensitive, literal, whole_word, max_results) {
2405
2103
  try {
2406
2104
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2407
- wasm.wasmpdfdocument_setPageMediaBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
2105
+ const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2106
+ const len0 = WASM_VECTOR_LEN;
2107
+ wasm.wasmpdfdocument_search(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(case_insensitive) ? 0xFFFFFF : case_insensitive ? 1 : 0, isLikeNone(literal) ? 0xFFFFFF : literal ? 1 : 0, isLikeNone(whole_word) ? 0xFFFFFF : whole_word ? 1 : 0, isLikeNone(max_results) ? 0x100000001 : (max_results) >>> 0);
2408
2108
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2409
2109
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2410
- if (r1) {
2411
- throw takeObject(r0);
2110
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2111
+ if (r2) {
2112
+ throw takeObject(r1);
2412
2113
  }
2114
+ return takeObject(r0);
2413
2115
  } finally {
2414
2116
  wasm.__wbindgen_add_to_stack_pointer(16);
2415
2117
  }
2416
2118
  }
2417
2119
  /**
2418
- * Clear all pending erase operations for a page.
2120
+ * Search for text on a specific page.
2419
2121
  * @param {number} page_index
2122
+ * @param {string} pattern
2123
+ * @param {boolean | null} [case_insensitive]
2124
+ * @param {boolean | null} [literal]
2125
+ * @param {boolean | null} [whole_word]
2126
+ * @param {number | null} [max_results]
2127
+ * @returns {any}
2420
2128
  */
2421
- clearEraseRegions(page_index) {
2129
+ searchPage(page_index, pattern, case_insensitive, literal, whole_word, max_results) {
2422
2130
  try {
2423
2131
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2424
- wasm.wasmpdfdocument_clearEraseRegions(retptr, this.__wbg_ptr, page_index);
2132
+ const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2133
+ const len0 = WASM_VECTOR_LEN;
2134
+ wasm.wasmpdfdocument_searchPage(retptr, this.__wbg_ptr, page_index, ptr0, len0, isLikeNone(case_insensitive) ? 0xFFFFFF : case_insensitive ? 1 : 0, isLikeNone(literal) ? 0xFFFFFF : literal ? 1 : 0, isLikeNone(whole_word) ? 0xFFFFFF : whole_word ? 1 : 0, isLikeNone(max_results) ? 0x100000001 : (max_results) >>> 0);
2425
2135
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2426
2136
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2427
- if (r1) {
2428
- throw takeObject(r0);
2137
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2138
+ if (r2) {
2139
+ throw takeObject(r1);
2429
2140
  }
2141
+ return takeObject(r0);
2430
2142
  } finally {
2431
2143
  wasm.__wbindgen_add_to_stack_pointer(16);
2432
2144
  }
2433
2145
  }
2434
2146
  /**
2435
- * Extract image bytes from a page as PNG data.
2436
- *
2437
- * Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
2438
- * @param {number} page_index
2439
- * @returns {any}
2147
+ * Set the document author.
2148
+ * @param {string} author
2440
2149
  */
2441
- extractImageBytes(page_index) {
2150
+ setAuthor(author) {
2442
2151
  try {
2443
2152
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2444
- wasm.wasmpdfdocument_extractImageBytes(retptr, this.__wbg_ptr, page_index);
2153
+ const ptr0 = passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2154
+ const len0 = WASM_VECTOR_LEN;
2155
+ wasm.wasmpdfdocument_setAuthor(retptr, this.__wbg_ptr, ptr0, len0);
2445
2156
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2446
2157
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2447
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2448
- if (r2) {
2449
- throw takeObject(r1);
2158
+ if (r1) {
2159
+ throw takeObject(r0);
2450
2160
  }
2451
- return takeObject(r0);
2452
2161
  } finally {
2453
2162
  wasm.__wbindgen_add_to_stack_pointer(16);
2454
2163
  }
2455
2164
  }
2456
2165
  /**
2457
- * Apply all redactions in the document.
2166
+ * Set the value of a form field.
2167
+ *
2168
+ * @param name - Full qualified field name
2169
+ * @param value - New value: string for text fields, boolean for checkboxes
2170
+ * @param {string} name
2171
+ * @param {any} value
2458
2172
  */
2459
- applyAllRedactions() {
2173
+ setFormFieldValue(name, value) {
2460
2174
  try {
2461
2175
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2462
- wasm.wasmpdfdocument_applyAllRedactions(retptr, this.__wbg_ptr);
2176
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2177
+ const len0 = WASM_VECTOR_LEN;
2178
+ wasm.wasmpdfdocument_setFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
2463
2179
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2464
2180
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2465
2181
  if (r1) {
@@ -2470,44 +2186,39 @@ class WasmPdfDocument {
2470
2186
  }
2471
2187
  }
2472
2188
  /**
2473
- * Get the value of a specific form field by name.
2474
- *
2475
- * @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
2476
- * @returns The field value: string for text, boolean for checkbox, null if not found
2189
+ * Set the complete bounds of an image on a page.
2190
+ * @param {number} page_index
2477
2191
  * @param {string} name
2478
- * @returns {any}
2192
+ * @param {number} x
2193
+ * @param {number} y
2194
+ * @param {number} width
2195
+ * @param {number} height
2479
2196
  */
2480
- getFormFieldValue(name) {
2197
+ setImageBounds(page_index, name, x, y, width, height) {
2481
2198
  try {
2482
2199
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2483
2200
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2484
2201
  const len0 = WASM_VECTOR_LEN;
2485
- wasm.wasmpdfdocument_getFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0);
2202
+ wasm.wasmpdfdocument_setImageBounds(retptr, this.__wbg_ptr, page_index, ptr0, len0, x, y, width, height);
2486
2203
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2487
2204
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2488
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2489
- if (r2) {
2490
- throw takeObject(r1);
2205
+ if (r1) {
2206
+ throw takeObject(r0);
2491
2207
  }
2492
- return takeObject(r0);
2493
2208
  } finally {
2494
2209
  wasm.__wbindgen_add_to_stack_pointer(16);
2495
2210
  }
2496
2211
  }
2497
2212
  /**
2498
- * Set the value of a form field.
2499
- *
2500
- * @param name - Full qualified field name
2501
- * @param value - New value: string for text fields, boolean for checkboxes
2502
- * @param {string} name
2503
- * @param {any} value
2213
+ * Set the document keywords.
2214
+ * @param {string} keywords
2504
2215
  */
2505
- setFormFieldValue(name, value) {
2216
+ setKeywords(keywords) {
2506
2217
  try {
2507
2218
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2508
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2219
+ const ptr0 = passStringToWasm0(keywords, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2509
2220
  const len0 = WASM_VECTOR_LEN;
2510
- wasm.wasmpdfdocument_setFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
2221
+ wasm.wasmpdfdocument_setKeywords(retptr, this.__wbg_ptr, ptr0, len0);
2511
2222
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2512
2223
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2513
2224
  if (r1) {
@@ -2518,13 +2229,17 @@ class WasmPdfDocument {
2518
2229
  }
2519
2230
  }
2520
2231
  /**
2521
- * Apply redactions on a page (removes redacted content permanently).
2232
+ * Set the CropBox of a page.
2522
2233
  * @param {number} page_index
2234
+ * @param {number} llx
2235
+ * @param {number} lly
2236
+ * @param {number} urx
2237
+ * @param {number} ury
2523
2238
  */
2524
- applyPageRedactions(page_index) {
2239
+ setPageCropBox(page_index, llx, lly, urx, ury) {
2525
2240
  try {
2526
2241
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2527
- wasm.wasmpdfdocument_applyPageRedactions(retptr, this.__wbg_ptr, page_index);
2242
+ wasm.wasmpdfdocument_setPageCropBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
2528
2243
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2529
2244
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2530
2245
  if (r1) {
@@ -2535,15 +2250,17 @@ class WasmPdfDocument {
2535
2250
  }
2536
2251
  }
2537
2252
  /**
2538
- * Flatten form fields on a specific page.
2539
- *
2540
- * @param page_index - Zero-based page number
2253
+ * Set the MediaBox of a page.
2541
2254
  * @param {number} page_index
2255
+ * @param {number} llx
2256
+ * @param {number} lly
2257
+ * @param {number} urx
2258
+ * @param {number} ury
2542
2259
  */
2543
- flattenFormsOnPage(page_index) {
2260
+ setPageMediaBox(page_index, llx, lly, urx, ury) {
2544
2261
  try {
2545
2262
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2546
- wasm.wasmpdfdocument_flattenFormsOnPage(retptr, this.__wbg_ptr, page_index);
2263
+ wasm.wasmpdfdocument_setPageMediaBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
2547
2264
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2548
2265
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2549
2266
  if (r1) {
@@ -2554,12 +2271,14 @@ class WasmPdfDocument {
2554
2271
  }
2555
2272
  }
2556
2273
  /**
2557
- * Flatten all annotations in the document into page content.
2274
+ * Set the rotation of a page (0, 90, 180, or 270 degrees).
2275
+ * @param {number} page_index
2276
+ * @param {number} degrees
2558
2277
  */
2559
- flattenAllAnnotations() {
2278
+ setPageRotation(page_index, degrees) {
2560
2279
  try {
2561
2280
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2562
- wasm.wasmpdfdocument_flattenAllAnnotations(retptr, this.__wbg_ptr);
2281
+ wasm.wasmpdfdocument_setPageRotation(retptr, this.__wbg_ptr, page_index, degrees);
2563
2282
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2564
2283
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2565
2284
  if (r1) {
@@ -2570,45 +2289,34 @@ class WasmPdfDocument {
2570
2289
  }
2571
2290
  }
2572
2291
  /**
2573
- * Save with encryption and return the resulting PDF as bytes.
2574
- * @param {string} user_password
2575
- * @param {string | null} [owner_password]
2576
- * @param {boolean | null} [allow_print]
2577
- * @param {boolean | null} [allow_copy]
2578
- * @param {boolean | null} [allow_modify]
2579
- * @param {boolean | null} [allow_annotate]
2580
- * @returns {Uint8Array}
2292
+ * Set the document subject.
2293
+ * @param {string} subject
2581
2294
  */
2582
- saveEncryptedToBytes(user_password, owner_password, allow_print, allow_copy, allow_modify, allow_annotate) {
2295
+ setSubject(subject) {
2583
2296
  try {
2584
2297
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2585
- const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2298
+ const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2586
2299
  const len0 = WASM_VECTOR_LEN;
2587
- var ptr1 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2588
- var len1 = WASM_VECTOR_LEN;
2589
- wasm.wasmpdfdocument_saveEncryptedToBytes(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(allow_print) ? 0xFFFFFF : allow_print ? 1 : 0, isLikeNone(allow_copy) ? 0xFFFFFF : allow_copy ? 1 : 0, isLikeNone(allow_modify) ? 0xFFFFFF : allow_modify ? 1 : 0, isLikeNone(allow_annotate) ? 0xFFFFFF : allow_annotate ? 1 : 0);
2300
+ wasm.wasmpdfdocument_setSubject(retptr, this.__wbg_ptr, ptr0, len0);
2590
2301
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2591
2302
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2592
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2593
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2594
- if (r3) {
2595
- throw takeObject(r2);
2303
+ if (r1) {
2304
+ throw takeObject(r0);
2596
2305
  }
2597
- var v3 = getArrayU8FromWasm0(r0, r1).slice();
2598
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
2599
- return v3;
2600
2306
  } finally {
2601
2307
  wasm.__wbindgen_add_to_stack_pointer(16);
2602
2308
  }
2603
2309
  }
2604
2310
  /**
2605
- * Flatten annotations on a page into the page content.
2606
- * @param {number} page_index
2311
+ * Set the document title.
2312
+ * @param {string} title
2607
2313
  */
2608
- flattenPageAnnotations(page_index) {
2314
+ setTitle(title) {
2609
2315
  try {
2610
2316
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2611
- wasm.wasmpdfdocument_flattenPageAnnotations(retptr, this.__wbg_ptr, page_index);
2317
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2318
+ const len0 = WASM_VECTOR_LEN;
2319
+ wasm.wasmpdfdocument_setTitle(retptr, this.__wbg_ptr, ptr0, len0);
2612
2320
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2613
2321
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2614
2322
  if (r1) {
@@ -2619,158 +2327,178 @@ class WasmPdfDocument {
2619
2327
  }
2620
2328
  }
2621
2329
  /**
2622
- * Load a PDF document from raw bytes.
2330
+ * Convert a single page to HTML.
2623
2331
  *
2624
- * @param data - PDF file contents as Uint8Array
2625
- * @param password - Optional password for encrypted PDFs
2626
- * @throws Error if the PDF is invalid or cannot be parsed
2627
- * @param {Uint8Array} data
2628
- * @param {string | null} [password]
2332
+ * @param page_index - Zero-based page number
2333
+ * @param preserve_layout - Use CSS positioning to preserve layout (default: false)
2334
+ * @param detect_headings - Whether to detect headings (default: true)
2335
+ * @param {number} page_index
2336
+ * @param {boolean | null} [preserve_layout]
2337
+ * @param {boolean | null} [detect_headings]
2338
+ * @param {boolean | null} [include_form_fields]
2339
+ * @returns {string}
2629
2340
  */
2630
- constructor(data, password) {
2341
+ toHtml(page_index, preserve_layout, detect_headings, include_form_fields) {
2342
+ let deferred2_0;
2343
+ let deferred2_1;
2631
2344
  try {
2632
2345
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2633
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
2634
- const len0 = WASM_VECTOR_LEN;
2635
- var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2636
- var len1 = WASM_VECTOR_LEN;
2637
- wasm.wasmpdfdocument_new(retptr, ptr0, len0, ptr1, len1);
2346
+ wasm.wasmpdfdocument_toHtml(retptr, this.__wbg_ptr, page_index, isLikeNone(preserve_layout) ? 0xFFFFFF : preserve_layout ? 1 : 0, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
2638
2347
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2639
2348
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2640
2349
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2641
- if (r2) {
2642
- throw takeObject(r1);
2350
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2351
+ var ptr1 = r0;
2352
+ var len1 = r1;
2353
+ if (r3) {
2354
+ ptr1 = 0; len1 = 0;
2355
+ throw takeObject(r2);
2643
2356
  }
2644
- this.__wbg_ptr = r0 >>> 0;
2645
- WasmPdfDocumentFinalization.register(this, this.__wbg_ptr, this);
2646
- return this;
2357
+ deferred2_0 = ptr1;
2358
+ deferred2_1 = len1;
2359
+ return getStringFromWasm0(ptr1, len1);
2647
2360
  } finally {
2648
2361
  wasm.__wbindgen_add_to_stack_pointer(16);
2362
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2649
2363
  }
2650
2364
  }
2651
2365
  /**
2652
- * Save all edits and return the resulting PDF as bytes.
2653
- *
2654
- * @returns Uint8Array containing the modified PDF
2655
- * @returns {Uint8Array}
2366
+ * Convert all pages to HTML.
2367
+ * @param {boolean | null} [preserve_layout]
2368
+ * @param {boolean | null} [detect_headings]
2369
+ * @param {boolean | null} [include_form_fields]
2370
+ * @returns {string}
2656
2371
  */
2657
- save() {
2372
+ toHtmlAll(preserve_layout, detect_headings, include_form_fields) {
2373
+ let deferred2_0;
2374
+ let deferred2_1;
2658
2375
  try {
2659
2376
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2660
- wasm.wasmpdfdocument_save(retptr, this.__wbg_ptr);
2377
+ wasm.wasmpdfdocument_toHtmlAll(retptr, this.__wbg_ptr, isLikeNone(preserve_layout) ? 0xFFFFFF : preserve_layout ? 1 : 0, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
2661
2378
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2662
2379
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2663
2380
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2664
2381
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2382
+ var ptr1 = r0;
2383
+ var len1 = r1;
2665
2384
  if (r3) {
2385
+ ptr1 = 0; len1 = 0;
2666
2386
  throw takeObject(r2);
2667
2387
  }
2668
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
2669
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
2670
- return v1;
2388
+ deferred2_0 = ptr1;
2389
+ deferred2_1 = len1;
2390
+ return getStringFromWasm0(ptr1, len1);
2671
2391
  } finally {
2672
2392
  wasm.__wbindgen_add_to_stack_pointer(16);
2393
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2673
2394
  }
2674
2395
  }
2675
2396
  /**
2676
- * Search for text across all pages.
2677
- *
2678
- * @param pattern - Regex pattern or literal text to search for
2679
- * @param case_insensitive - Case insensitive search (default: false)
2680
- * @param literal - Treat pattern as literal text, not regex (default: false)
2681
- * @param whole_word - Match whole words only (default: false)
2682
- * @param max_results - Maximum results to return, 0 = unlimited (default: 0)
2397
+ * Convert a single page to Markdown.
2683
2398
  *
2684
- * Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
2685
- * @param {string} pattern
2686
- * @param {boolean | null} [case_insensitive]
2687
- * @param {boolean | null} [literal]
2688
- * @param {boolean | null} [whole_word]
2689
- * @param {number | null} [max_results]
2690
- * @returns {any}
2399
+ * @param page_index - Zero-based page number
2400
+ * @param detect_headings - Whether to detect headings (default: true)
2401
+ * @param include_images - Whether to include images (default: false)
2402
+ * @param {number} page_index
2403
+ * @param {boolean | null} [detect_headings]
2404
+ * @param {boolean | null} [include_images]
2405
+ * @param {boolean | null} [include_form_fields]
2406
+ * @returns {string}
2691
2407
  */
2692
- search(pattern, case_insensitive, literal, whole_word, max_results) {
2408
+ toMarkdown(page_index, detect_headings, include_images, include_form_fields) {
2409
+ let deferred2_0;
2410
+ let deferred2_1;
2693
2411
  try {
2694
2412
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2695
- const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2696
- const len0 = WASM_VECTOR_LEN;
2697
- wasm.wasmpdfdocument_search(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(case_insensitive) ? 0xFFFFFF : case_insensitive ? 1 : 0, isLikeNone(literal) ? 0xFFFFFF : literal ? 1 : 0, isLikeNone(whole_word) ? 0xFFFFFF : whole_word ? 1 : 0, isLikeNone(max_results) ? 0x100000001 : (max_results) >>> 0);
2413
+ wasm.wasmpdfdocument_toMarkdown(retptr, this.__wbg_ptr, page_index, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_images) ? 0xFFFFFF : include_images ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
2698
2414
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2699
2415
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2700
2416
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2701
- if (r2) {
2702
- throw takeObject(r1);
2417
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2418
+ var ptr1 = r0;
2419
+ var len1 = r1;
2420
+ if (r3) {
2421
+ ptr1 = 0; len1 = 0;
2422
+ throw takeObject(r2);
2703
2423
  }
2704
- return takeObject(r0);
2424
+ deferred2_0 = ptr1;
2425
+ deferred2_1 = len1;
2426
+ return getStringFromWasm0(ptr1, len1);
2705
2427
  } finally {
2706
2428
  wasm.__wbindgen_add_to_stack_pointer(16);
2429
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2707
2430
  }
2708
2431
  }
2709
2432
  /**
2710
- * Focus extraction on a specific rectangular region of a page (v0.3.14).
2711
- *
2712
- * @param page_index - Zero-based page number
2713
- * @param region - [x, y, width, height] in points
2714
- * @param {number} page_index
2715
- * @param {Float32Array} region
2716
- * @returns {WasmPdfPageRegion}
2433
+ * Convert all pages to Markdown.
2434
+ * @param {boolean | null} [detect_headings]
2435
+ * @param {boolean | null} [include_images]
2436
+ * @param {boolean | null} [include_form_fields]
2437
+ * @returns {string}
2717
2438
  */
2718
- within(page_index, region) {
2439
+ toMarkdownAll(detect_headings, include_images, include_form_fields) {
2440
+ let deferred2_0;
2441
+ let deferred2_1;
2719
2442
  try {
2720
2443
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2721
- const ptr0 = passArrayF32ToWasm0(region, wasm.__wbindgen_export);
2722
- const len0 = WASM_VECTOR_LEN;
2723
- wasm.wasmpdfdocument_within(retptr, this.__wbg_ptr, page_index, ptr0, len0);
2444
+ wasm.wasmpdfdocument_toMarkdownAll(retptr, this.__wbg_ptr, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_images) ? 0xFFFFFF : include_images ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
2724
2445
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2725
2446
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2726
2447
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2727
- if (r2) {
2728
- throw takeObject(r1);
2448
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2449
+ var ptr1 = r0;
2450
+ var len1 = r1;
2451
+ if (r3) {
2452
+ ptr1 = 0; len1 = 0;
2453
+ throw takeObject(r2);
2729
2454
  }
2730
- return WasmPdfPageRegion.__wrap(r0);
2455
+ deferred2_0 = ptr1;
2456
+ deferred2_1 = len1;
2457
+ return getStringFromWasm0(ptr1, len1);
2731
2458
  } finally {
2732
2459
  wasm.__wbindgen_add_to_stack_pointer(16);
2460
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2733
2461
  }
2734
2462
  }
2735
2463
  /**
2736
- * Check if the document contains XFA form data.
2737
- *
2738
- * @returns true if the document has XFA form data
2739
- * @returns {boolean}
2464
+ * Convert a single page to plain text (with layout preservation options).
2465
+ * @param {number} page_index
2466
+ * @returns {string}
2740
2467
  */
2741
- hasXfa() {
2468
+ toPlainText(page_index) {
2469
+ let deferred2_0;
2470
+ let deferred2_1;
2742
2471
  try {
2743
2472
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2744
- wasm.wasmpdfdocument_hasXfa(retptr, this.__wbg_ptr);
2473
+ wasm.wasmpdfdocument_toPlainText(retptr, this.__wbg_ptr, page_index);
2745
2474
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2746
2475
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2747
2476
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2748
- if (r2) {
2749
- throw takeObject(r1);
2477
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2478
+ var ptr1 = r0;
2479
+ var len1 = r1;
2480
+ if (r3) {
2481
+ ptr1 = 0; len1 = 0;
2482
+ throw takeObject(r2);
2750
2483
  }
2751
- return r0 !== 0;
2484
+ deferred2_0 = ptr1;
2485
+ deferred2_1 = len1;
2486
+ return getStringFromWasm0(ptr1, len1);
2752
2487
  } finally {
2753
2488
  wasm.__wbindgen_add_to_stack_pointer(16);
2489
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2754
2490
  }
2755
2491
  }
2756
2492
  /**
2757
- * Convert a single page to HTML.
2758
- *
2759
- * @param page_index - Zero-based page number
2760
- * @param preserve_layout - Use CSS positioning to preserve layout (default: false)
2761
- * @param detect_headings - Whether to detect headings (default: true)
2762
- * @param {number} page_index
2763
- * @param {boolean | null} [preserve_layout]
2764
- * @param {boolean | null} [detect_headings]
2765
- * @param {boolean | null} [include_form_fields]
2493
+ * Convert all pages to plain text.
2766
2494
  * @returns {string}
2767
2495
  */
2768
- toHtml(page_index, preserve_layout, detect_headings, include_form_fields) {
2496
+ toPlainTextAll() {
2769
2497
  let deferred2_0;
2770
2498
  let deferred2_1;
2771
2499
  try {
2772
2500
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2773
- wasm.wasmpdfdocument_toHtml(retptr, this.__wbg_ptr, page_index, isLikeNone(preserve_layout) ? 0xFFFFFF : preserve_layout ? 1 : 0, isLikeNone(detect_headings) ? 0xFFFFFF : detect_headings ? 1 : 0, isLikeNone(include_form_fields) ? 0xFFFFFF : include_form_fields ? 1 : 0);
2501
+ wasm.wasmpdfdocument_toPlainTextAll(retptr, this.__wbg_ptr);
2774
2502
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2775
2503
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2776
2504
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2781,12 +2509,34 @@ class WasmPdfDocument {
2781
2509
  ptr1 = 0; len1 = 0;
2782
2510
  throw takeObject(r2);
2783
2511
  }
2784
- deferred2_0 = ptr1;
2785
- deferred2_1 = len1;
2786
- return getStringFromWasm0(ptr1, len1);
2512
+ deferred2_0 = ptr1;
2513
+ deferred2_1 = len1;
2514
+ return getStringFromWasm0(ptr1, len1);
2515
+ } finally {
2516
+ wasm.__wbindgen_add_to_stack_pointer(16);
2517
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2518
+ }
2519
+ }
2520
+ /**
2521
+ * Validate PDF/A compliance. Level: "1b", "2b", etc.
2522
+ * @param {string} level
2523
+ * @returns {any}
2524
+ */
2525
+ validatePdfA(level) {
2526
+ try {
2527
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2528
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2529
+ const len0 = WASM_VECTOR_LEN;
2530
+ wasm.wasmpdfdocument_validatePdfA(retptr, this.__wbg_ptr, ptr0, len0);
2531
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2532
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2533
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2534
+ if (r2) {
2535
+ throw takeObject(r1);
2536
+ }
2537
+ return takeObject(r0);
2787
2538
  } finally {
2788
2539
  wasm.__wbindgen_add_to_stack_pointer(16);
2789
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2790
2540
  }
2791
2541
  }
2792
2542
  /**
@@ -2812,20 +2562,48 @@ class WasmPdfDocument {
2812
2562
  }
2813
2563
  }
2814
2564
  /**
2815
- * Set the document title.
2816
- * @param {string} title
2565
+ * Focus extraction on a specific rectangular region of a page (v0.3.14).
2566
+ *
2567
+ * @param page_index - Zero-based page number
2568
+ * @param region - [x, y, width, height] in points
2569
+ * @param {number} page_index
2570
+ * @param {Float32Array} region
2571
+ * @returns {WasmPdfPageRegion}
2817
2572
  */
2818
- setTitle(title) {
2573
+ within(page_index, region) {
2819
2574
  try {
2820
2575
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2821
- const ptr0 = passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2576
+ const ptr0 = passArrayF32ToWasm0(region, wasm.__wbindgen_export);
2822
2577
  const len0 = WASM_VECTOR_LEN;
2823
- wasm.wasmpdfdocument_setTitle(retptr, this.__wbg_ptr, ptr0, len0);
2578
+ wasm.wasmpdfdocument_within(retptr, this.__wbg_ptr, page_index, ptr0, len0);
2824
2579
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2825
2580
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2826
- if (r1) {
2827
- throw takeObject(r0);
2581
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2582
+ if (r2) {
2583
+ throw takeObject(r1);
2584
+ }
2585
+ return WasmPdfPageRegion.__wrap(r0);
2586
+ } finally {
2587
+ wasm.__wbindgen_add_to_stack_pointer(16);
2588
+ }
2589
+ }
2590
+ /**
2591
+ * Get XMP metadata from the document.
2592
+ *
2593
+ * @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
2594
+ * @returns {any}
2595
+ */
2596
+ xmpMetadata() {
2597
+ try {
2598
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2599
+ wasm.wasmpdfdocument_xmpMetadata(retptr, this.__wbg_ptr);
2600
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2601
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2602
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2603
+ if (r2) {
2604
+ throw takeObject(r1);
2828
2605
  }
2606
+ return takeObject(r0);
2829
2607
  } finally {
2830
2608
  wasm.__wbindgen_add_to_stack_pointer(16);
2831
2609
  }
@@ -2856,41 +2634,32 @@ class WasmPdfPageRegion {
2856
2634
  wasm.__wbg_wasmpdfpageregion_free(ptr, 0);
2857
2635
  }
2858
2636
  /**
2859
- * Extract text from this region.
2860
- * @returns {string}
2637
+ * Extract character-level data from this region.
2638
+ * @returns {any}
2861
2639
  */
2862
- extractText() {
2863
- let deferred2_0;
2864
- let deferred2_1;
2640
+ extractChars() {
2865
2641
  try {
2866
2642
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2867
- wasm.wasmpdfpageregion_extractText(retptr, this.__wbg_ptr);
2643
+ wasm.wasmpdfpageregion_extractChars(retptr, this.__wbg_ptr);
2868
2644
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2869
2645
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2870
2646
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2871
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2872
- var ptr1 = r0;
2873
- var len1 = r1;
2874
- if (r3) {
2875
- ptr1 = 0; len1 = 0;
2876
- throw takeObject(r2);
2647
+ if (r2) {
2648
+ throw takeObject(r1);
2877
2649
  }
2878
- deferred2_0 = ptr1;
2879
- deferred2_1 = len1;
2880
- return getStringFromWasm0(ptr1, len1);
2650
+ return takeObject(r0);
2881
2651
  } finally {
2882
2652
  wasm.__wbindgen_add_to_stack_pointer(16);
2883
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2884
2653
  }
2885
2654
  }
2886
2655
  /**
2887
- * Extract character-level data from this region.
2656
+ * Extract images from this region.
2888
2657
  * @returns {any}
2889
2658
  */
2890
- extractChars() {
2659
+ extractImages() {
2891
2660
  try {
2892
2661
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2893
- wasm.wasmpdfpageregion_extractChars(retptr, this.__wbg_ptr);
2662
+ wasm.wasmpdfpageregion_extractImages(retptr, this.__wbg_ptr);
2894
2663
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2895
2664
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2896
2665
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2960,13 +2729,13 @@ class WasmPdfPageRegion {
2960
2729
  }
2961
2730
  }
2962
2731
  /**
2963
- * Extract words from this region.
2732
+ * Extract tables from this region.
2964
2733
  * @returns {any}
2965
2734
  */
2966
- extractWords() {
2735
+ extractTables() {
2967
2736
  try {
2968
2737
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2969
- wasm.wasmpdfpageregion_extractWords(retptr, this.__wbg_ptr);
2738
+ wasm.wasmpdfpageregion_extractTables(retptr, this.__wbg_ptr);
2970
2739
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2971
2740
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2972
2741
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2979,13 +2748,41 @@ class WasmPdfPageRegion {
2979
2748
  }
2980
2749
  }
2981
2750
  /**
2982
- * Extract images from this region.
2751
+ * Extract text from this region.
2752
+ * @returns {string}
2753
+ */
2754
+ extractText() {
2755
+ let deferred2_0;
2756
+ let deferred2_1;
2757
+ try {
2758
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2759
+ wasm.wasmpdfpageregion_extractText(retptr, this.__wbg_ptr);
2760
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2761
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2762
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2763
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2764
+ var ptr1 = r0;
2765
+ var len1 = r1;
2766
+ if (r3) {
2767
+ ptr1 = 0; len1 = 0;
2768
+ throw takeObject(r2);
2769
+ }
2770
+ deferred2_0 = ptr1;
2771
+ deferred2_1 = len1;
2772
+ return getStringFromWasm0(ptr1, len1);
2773
+ } finally {
2774
+ wasm.__wbindgen_add_to_stack_pointer(16);
2775
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2776
+ }
2777
+ }
2778
+ /**
2779
+ * Extract text lines from this region.
2983
2780
  * @returns {any}
2984
2781
  */
2985
- extractImages() {
2782
+ extractTextLines() {
2986
2783
  try {
2987
2784
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2988
- wasm.wasmpdfpageregion_extractImages(retptr, this.__wbg_ptr);
2785
+ wasm.wasmpdfpageregion_extractTextLines(retptr, this.__wbg_ptr);
2989
2786
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2990
2787
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2991
2788
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2998,13 +2795,47 @@ class WasmPdfPageRegion {
2998
2795
  }
2999
2796
  }
3000
2797
  /**
3001
- * Extract tables from this region.
2798
+ * Extract text using OCR from this region.
2799
+ * @param {WasmOcrEngine | null} [_engine]
2800
+ * @returns {string}
2801
+ */
2802
+ extractTextOcr(_engine) {
2803
+ let deferred3_0;
2804
+ let deferred3_1;
2805
+ try {
2806
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2807
+ let ptr0 = 0;
2808
+ if (!isLikeNone(_engine)) {
2809
+ _assertClass(_engine, WasmOcrEngine);
2810
+ ptr0 = _engine.__destroy_into_raw();
2811
+ }
2812
+ wasm.wasmpdfpageregion_extractTextOcr(retptr, this.__wbg_ptr, ptr0);
2813
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2814
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2815
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2816
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2817
+ var ptr2 = r0;
2818
+ var len2 = r1;
2819
+ if (r3) {
2820
+ ptr2 = 0; len2 = 0;
2821
+ throw takeObject(r2);
2822
+ }
2823
+ deferred3_0 = ptr2;
2824
+ deferred3_1 = len2;
2825
+ return getStringFromWasm0(ptr2, len2);
2826
+ } finally {
2827
+ wasm.__wbindgen_add_to_stack_pointer(16);
2828
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
2829
+ }
2830
+ }
2831
+ /**
2832
+ * Extract words from this region.
3002
2833
  * @returns {any}
3003
2834
  */
3004
- extractTables() {
2835
+ extractWords() {
3005
2836
  try {
3006
2837
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3007
- wasm.wasmpdfpageregion_extractTables(retptr, this.__wbg_ptr);
2838
+ wasm.wasmpdfpageregion_extractWords(retptr, this.__wbg_ptr);
3008
2839
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3009
2840
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3010
2841
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -3016,363 +2847,608 @@ class WasmPdfPageRegion {
3016
2847
  wasm.__wbindgen_add_to_stack_pointer(16);
3017
2848
  }
3018
2849
  }
3019
- /**
3020
- * Extract text using OCR from this region.
3021
- * @param {WasmOcrEngine | null} [_engine]
3022
- * @returns {string}
3023
- */
3024
- extractTextOcr(_engine) {
3025
- let deferred3_0;
3026
- let deferred3_1;
3027
- try {
3028
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3029
- let ptr0 = 0;
3030
- if (!isLikeNone(_engine)) {
3031
- _assertClass(_engine, WasmOcrEngine);
3032
- ptr0 = _engine.__destroy_into_raw();
3033
- }
3034
- wasm.wasmpdfpageregion_extractTextOcr(retptr, this.__wbg_ptr, ptr0);
3035
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3036
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3037
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3038
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3039
- var ptr2 = r0;
3040
- var len2 = r1;
3041
- if (r3) {
3042
- ptr2 = 0; len2 = 0;
3043
- throw takeObject(r2);
3044
- }
3045
- deferred3_0 = ptr2;
3046
- deferred3_1 = len2;
3047
- return getStringFromWasm0(ptr2, len2);
3048
- } finally {
3049
- wasm.__wbindgen_add_to_stack_pointer(16);
3050
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
2850
+ }
2851
+ if (Symbol.dispose) WasmPdfPageRegion.prototype[Symbol.dispose] = WasmPdfPageRegion.prototype.free;
2852
+ exports.WasmPdfPageRegion = WasmPdfPageRegion;
2853
+
2854
+ /**
2855
+ * Disable all pdf_oxide log output — convenience wrapper for
2856
+ * `setLogLevel("off")`.
2857
+ */
2858
+ function disableLogging() {
2859
+ wasm.disableLogging();
2860
+ }
2861
+ exports.disableLogging = disableLogging;
2862
+
2863
+ /**
2864
+ * Set the maximum log level for pdf_oxide messages.
2865
+ *
2866
+ * Accepts one of: `"off"`, `"error"`, `"warn"` / `"warning"`, `"info"`,
2867
+ * `"debug"`, `"trace"`. Case-insensitive. Default is `"off"` the library
2868
+ * is silent unless explicitly enabled.
2869
+ *
2870
+ * Logs are forwarded to the browser console (`console.log`, `console.warn`,
2871
+ * `console.error`, etc.). Fixes issue #280.
2872
+ *
2873
+ * @example
2874
+ * ```javascript
2875
+ * import init, { setLogLevel } from "pdf-oxide-wasm";
2876
+ * await init();
2877
+ * setLogLevel("warn");
2878
+ * ```
2879
+ * @param {string} level
2880
+ */
2881
+ function setLogLevel(level) {
2882
+ try {
2883
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2884
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2885
+ const len0 = WASM_VECTOR_LEN;
2886
+ wasm.setLogLevel(retptr, ptr0, len0);
2887
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2888
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2889
+ if (r1) {
2890
+ throw takeObject(r0);
2891
+ }
2892
+ } finally {
2893
+ wasm.__wbindgen_add_to_stack_pointer(16);
2894
+ }
2895
+ }
2896
+ exports.setLogLevel = setLogLevel;
2897
+
2898
+ function __wbg_get_imports() {
2899
+ const import0 = {
2900
+ __proto__: null,
2901
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
2902
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2903
+ return addHeapObject(ret);
2904
+ },
2905
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
2906
+ const ret = String(getObject(arg1));
2907
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2908
+ const len1 = WASM_VECTOR_LEN;
2909
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2910
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2911
+ },
2912
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
2913
+ const v = getObject(arg0);
2914
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2915
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2916
+ },
2917
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
2918
+ const ret = debugString(getObject(arg1));
2919
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2920
+ const len1 = WASM_VECTOR_LEN;
2921
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2922
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2923
+ },
2924
+ __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
2925
+ const ret = typeof(getObject(arg0)) === 'function';
2926
+ return ret;
2927
+ },
2928
+ __wbg___wbindgen_is_null_344c8750a8525473: function(arg0) {
2929
+ const ret = getObject(arg0) === null;
2930
+ return ret;
2931
+ },
2932
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
2933
+ const val = getObject(arg0);
2934
+ const ret = typeof(val) === 'object' && val !== null;
2935
+ return ret;
2936
+ },
2937
+ __wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
2938
+ const ret = typeof(getObject(arg0)) === 'string';
2939
+ return ret;
2940
+ },
2941
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
2942
+ const ret = getObject(arg0) === undefined;
2943
+ return ret;
2944
+ },
2945
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
2946
+ const ret = getObject(arg0) == getObject(arg1);
2947
+ return ret;
2948
+ },
2949
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
2950
+ const obj = getObject(arg1);
2951
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2952
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2953
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2954
+ },
2955
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
2956
+ const obj = getObject(arg1);
2957
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2958
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2959
+ var len1 = WASM_VECTOR_LEN;
2960
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2961
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2962
+ },
2963
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
2964
+ throw new Error(getStringFromWasm0(arg0, arg1));
2965
+ },
2966
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
2967
+ const ret = getObject(arg0).call(getObject(arg1));
2968
+ return addHeapObject(ret);
2969
+ }, arguments); },
2970
+ __wbg_debug_58754cc8dbfec7ec: function(arg0, arg1, arg2, arg3) {
2971
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
2972
+ },
2973
+ __wbg_done_547d467e97529006: function(arg0) {
2974
+ const ret = getObject(arg0).done;
2975
+ return ret;
2976
+ },
2977
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
2978
+ let deferred0_0;
2979
+ let deferred0_1;
2980
+ try {
2981
+ deferred0_0 = arg0;
2982
+ deferred0_1 = arg1;
2983
+ console.error(getStringFromWasm0(arg0, arg1));
2984
+ } finally {
2985
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2986
+ }
2987
+ },
2988
+ __wbg_error_f8d1622cb1d8c53c: function(arg0, arg1, arg2, arg3) {
2989
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
2990
+ },
2991
+ __wbg_fromCodePoint_967e9ce245607f1b: function() { return handleError(function (arg0) {
2992
+ const ret = String.fromCodePoint(arg0 >>> 0);
2993
+ return addHeapObject(ret);
2994
+ }, arguments); },
2995
+ __wbg_from_741da0f916ab74aa: function(arg0) {
2996
+ const ret = Array.from(getObject(arg0));
2997
+ return addHeapObject(ret);
2998
+ },
2999
+ __wbg_getRandomValues_d49329ff89a07af1: function() { return handleError(function (arg0, arg1) {
3000
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
3001
+ }, arguments); },
3002
+ __wbg_getTime_f6ac312467f7cf09: function(arg0) {
3003
+ const ret = getObject(arg0).getTime();
3004
+ return ret;
3005
+ },
3006
+ __wbg_getTimezoneOffset_ac5be603b21a5797: function(arg0) {
3007
+ const ret = getObject(arg0).getTimezoneOffset();
3008
+ return ret;
3009
+ },
3010
+ __wbg_get_4848e350b40afc16: function(arg0, arg1) {
3011
+ const ret = getObject(arg0)[arg1 >>> 0];
3012
+ return addHeapObject(ret);
3013
+ },
3014
+ __wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
3015
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
3016
+ return addHeapObject(ret);
3017
+ }, arguments); },
3018
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
3019
+ const ret = getObject(arg0)[arg1 >>> 0];
3020
+ return addHeapObject(ret);
3021
+ },
3022
+ __wbg_info_8e80eb6c0f1d9449: function(arg0, arg1, arg2, arg3) {
3023
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
3024
+ },
3025
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
3026
+ let result;
3027
+ try {
3028
+ result = getObject(arg0) instanceof ArrayBuffer;
3029
+ } catch (_) {
3030
+ result = false;
3031
+ }
3032
+ const ret = result;
3033
+ return ret;
3034
+ },
3035
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
3036
+ let result;
3037
+ try {
3038
+ result = getObject(arg0) instanceof Uint8Array;
3039
+ } catch (_) {
3040
+ result = false;
3041
+ }
3042
+ const ret = result;
3043
+ return ret;
3044
+ },
3045
+ __wbg_isArray_db61795ad004c139: function(arg0) {
3046
+ const ret = Array.isArray(getObject(arg0));
3047
+ return ret;
3048
+ },
3049
+ __wbg_iterator_de403ef31815a3e6: function() {
3050
+ const ret = Symbol.iterator;
3051
+ return addHeapObject(ret);
3052
+ },
3053
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
3054
+ const ret = getObject(arg0).length;
3055
+ return ret;
3056
+ },
3057
+ __wbg_length_6e821edde497a532: function(arg0) {
3058
+ const ret = getObject(arg0).length;
3059
+ return ret;
3060
+ },
3061
+ __wbg_log_dafe9ed5100e3a8c: function(arg0, arg1, arg2, arg3) {
3062
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
3063
+ },
3064
+ __wbg_new_0_bfa2ef4bc447daa2: function() {
3065
+ const ret = new Date();
3066
+ return addHeapObject(ret);
3067
+ },
3068
+ __wbg_new_0f6d2ddfe083319b: function(arg0) {
3069
+ const ret = new Date(getObject(arg0));
3070
+ return addHeapObject(ret);
3071
+ },
3072
+ __wbg_new_227d7c05414eb861: function() {
3073
+ const ret = new Error();
3074
+ return addHeapObject(ret);
3075
+ },
3076
+ __wbg_new_4f9fafbb3909af72: function() {
3077
+ const ret = new Object();
3078
+ return addHeapObject(ret);
3079
+ },
3080
+ __wbg_new_99cabae501c0a8a0: function() {
3081
+ const ret = new Map();
3082
+ return addHeapObject(ret);
3083
+ },
3084
+ __wbg_new_a560378ea1240b14: function(arg0) {
3085
+ const ret = new Uint8Array(getObject(arg0));
3086
+ return addHeapObject(ret);
3087
+ },
3088
+ __wbg_new_f3c9df4f38f3f798: function() {
3089
+ const ret = new Array();
3090
+ return addHeapObject(ret);
3091
+ },
3092
+ __wbg_new_from_slice_2580ff33d0d10520: function(arg0, arg1) {
3093
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
3094
+ return addHeapObject(ret);
3095
+ },
3096
+ __wbg_next_01132ed6134b8ef5: function(arg0) {
3097
+ const ret = getObject(arg0).next;
3098
+ return addHeapObject(ret);
3099
+ },
3100
+ __wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
3101
+ const ret = getObject(arg0).next();
3102
+ return addHeapObject(ret);
3103
+ }, arguments); },
3104
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
3105
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
3106
+ },
3107
+ __wbg_push_6bdbc990be5ac37b: function(arg0, arg1) {
3108
+ const ret = getObject(arg0).push(getObject(arg1));
3109
+ return ret;
3110
+ },
3111
+ __wbg_set_08463b1df38a7e29: function(arg0, arg1, arg2) {
3112
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
3113
+ return addHeapObject(ret);
3114
+ },
3115
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
3116
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
3117
+ },
3118
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
3119
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
3120
+ },
3121
+ __wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
3122
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
3123
+ return ret;
3124
+ }, arguments); },
3125
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
3126
+ const ret = getObject(arg1).stack;
3127
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3128
+ const len1 = WASM_VECTOR_LEN;
3129
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3130
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3131
+ },
3132
+ __wbg_value_7f6052747ccf940f: function(arg0) {
3133
+ const ret = getObject(arg0).value;
3134
+ return addHeapObject(ret);
3135
+ },
3136
+ __wbg_warn_b5013c1036317367: function(arg0, arg1, arg2, arg3) {
3137
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
3138
+ },
3139
+ __wbindgen_cast_0000000000000001: function(arg0) {
3140
+ // Cast intrinsic for `F64 -> Externref`.
3141
+ const ret = arg0;
3142
+ return addHeapObject(ret);
3143
+ },
3144
+ __wbindgen_cast_0000000000000002: function(arg0) {
3145
+ // Cast intrinsic for `I64 -> Externref`.
3146
+ const ret = arg0;
3147
+ return addHeapObject(ret);
3148
+ },
3149
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
3150
+ // Cast intrinsic for `Ref(String) -> Externref`.
3151
+ const ret = getStringFromWasm0(arg0, arg1);
3152
+ return addHeapObject(ret);
3153
+ },
3154
+ __wbindgen_cast_0000000000000004: function(arg0) {
3155
+ // Cast intrinsic for `U64 -> Externref`.
3156
+ const ret = BigInt.asUintN(64, arg0);
3157
+ return addHeapObject(ret);
3158
+ },
3159
+ __wbindgen_object_clone_ref: function(arg0) {
3160
+ const ret = getObject(arg0);
3161
+ return addHeapObject(ret);
3162
+ },
3163
+ __wbindgen_object_drop_ref: function(arg0) {
3164
+ takeObject(arg0);
3165
+ },
3166
+ };
3167
+ return {
3168
+ __proto__: null,
3169
+ "./pdf_oxide_bg.js": import0,
3170
+ };
3171
+ }
3172
+
3173
+ const WasmArtifactFinalization = (typeof FinalizationRegistry === 'undefined')
3174
+ ? { register: () => {}, unregister: () => {} }
3175
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmartifact_free(ptr >>> 0, 1));
3176
+ const ArtifactStyleFinalization = (typeof FinalizationRegistry === 'undefined')
3177
+ ? { register: () => {}, unregister: () => {} }
3178
+ : new FinalizationRegistry(ptr => wasm.__wbg_artifactstyle_free(ptr >>> 0, 1));
3179
+ const WasmFooterFinalization = (typeof FinalizationRegistry === 'undefined')
3180
+ ? { register: () => {}, unregister: () => {} }
3181
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmfooter_free(ptr >>> 0, 1));
3182
+ const WasmHeaderFinalization = (typeof FinalizationRegistry === 'undefined')
3183
+ ? { register: () => {}, unregister: () => {} }
3184
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmheader_free(ptr >>> 0, 1));
3185
+ const WasmOcrConfigFinalization = (typeof FinalizationRegistry === 'undefined')
3186
+ ? { register: () => {}, unregister: () => {} }
3187
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmocrconfig_free(ptr >>> 0, 1));
3188
+ const WasmOcrEngineFinalization = (typeof FinalizationRegistry === 'undefined')
3189
+ ? { register: () => {}, unregister: () => {} }
3190
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmocrengine_free(ptr >>> 0, 1));
3191
+ const WasmPageTemplateFinalization = (typeof FinalizationRegistry === 'undefined')
3192
+ ? { register: () => {}, unregister: () => {} }
3193
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmpagetemplate_free(ptr >>> 0, 1));
3194
+ const WasmPdfFinalization = (typeof FinalizationRegistry === 'undefined')
3195
+ ? { register: () => {}, unregister: () => {} }
3196
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdf_free(ptr >>> 0, 1));
3197
+ const WasmPdfDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
3198
+ ? { register: () => {}, unregister: () => {} }
3199
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfdocument_free(ptr >>> 0, 1));
3200
+ const WasmPdfPageRegionFinalization = (typeof FinalizationRegistry === 'undefined')
3201
+ ? { register: () => {}, unregister: () => {} }
3202
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfpageregion_free(ptr >>> 0, 1));
3203
+
3204
+ function addHeapObject(obj) {
3205
+ if (heap_next === heap.length) heap.push(heap.length + 1);
3206
+ const idx = heap_next;
3207
+ heap_next = heap[idx];
3208
+
3209
+ heap[idx] = obj;
3210
+ return idx;
3211
+ }
3212
+
3213
+ function _assertClass(instance, klass) {
3214
+ if (!(instance instanceof klass)) {
3215
+ throw new Error(`expected instance of ${klass.name}`);
3216
+ }
3217
+ }
3218
+
3219
+ function debugString(val) {
3220
+ // primitive types
3221
+ const type = typeof val;
3222
+ if (type == 'number' || type == 'boolean' || val == null) {
3223
+ return `${val}`;
3224
+ }
3225
+ if (type == 'string') {
3226
+ return `"${val}"`;
3227
+ }
3228
+ if (type == 'symbol') {
3229
+ const description = val.description;
3230
+ if (description == null) {
3231
+ return 'Symbol';
3232
+ } else {
3233
+ return `Symbol(${description})`;
3234
+ }
3235
+ }
3236
+ if (type == 'function') {
3237
+ const name = val.name;
3238
+ if (typeof name == 'string' && name.length > 0) {
3239
+ return `Function(${name})`;
3240
+ } else {
3241
+ return 'Function';
3242
+ }
3243
+ }
3244
+ // objects
3245
+ if (Array.isArray(val)) {
3246
+ const length = val.length;
3247
+ let debug = '[';
3248
+ if (length > 0) {
3249
+ debug += debugString(val[0]);
3250
+ }
3251
+ for(let i = 1; i < length; i++) {
3252
+ debug += ', ' + debugString(val[i]);
3051
3253
  }
3254
+ debug += ']';
3255
+ return debug;
3052
3256
  }
3053
- /**
3054
- * Extract text lines from this region.
3055
- * @returns {any}
3056
- */
3057
- extractTextLines() {
3257
+ // Test for built-in
3258
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
3259
+ let className;
3260
+ if (builtInMatches && builtInMatches.length > 1) {
3261
+ className = builtInMatches[1];
3262
+ } else {
3263
+ // Failed to match the standard '[object ClassName]'
3264
+ return toString.call(val);
3265
+ }
3266
+ if (className == 'Object') {
3267
+ // we're a user defined class or Object
3268
+ // JSON.stringify avoids problems with cycles, and is generally much
3269
+ // easier than looping through ownProperties of `val`.
3058
3270
  try {
3059
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3060
- wasm.wasmpdfpageregion_extractTextLines(retptr, this.__wbg_ptr);
3061
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3062
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3063
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3064
- if (r2) {
3065
- throw takeObject(r1);
3066
- }
3067
- return takeObject(r0);
3068
- } finally {
3069
- wasm.__wbindgen_add_to_stack_pointer(16);
3271
+ return 'Object(' + JSON.stringify(val) + ')';
3272
+ } catch (_) {
3273
+ return 'Object';
3070
3274
  }
3071
3275
  }
3276
+ // errors
3277
+ if (val instanceof Error) {
3278
+ return `${val.name}: ${val.message}\n${val.stack}`;
3279
+ }
3280
+ // TODO we could test for more things here, like `Set`s and `Map`s.
3281
+ return className;
3072
3282
  }
3073
- if (Symbol.dispose) WasmPdfPageRegion.prototype[Symbol.dispose] = WasmPdfPageRegion.prototype.free;
3074
- exports.WasmPdfPageRegion = WasmPdfPageRegion;
3075
-
3076
- exports.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
3077
- const ret = Error(getStringFromWasm0(arg0, arg1));
3078
- return addHeapObject(ret);
3079
- };
3080
-
3081
- exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
3082
- const ret = String(getObject(arg1));
3083
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3084
- const len1 = WASM_VECTOR_LEN;
3085
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3086
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3087
- };
3088
-
3089
- exports.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
3090
- const v = getObject(arg0);
3091
- const ret = typeof(v) === 'boolean' ? v : undefined;
3092
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
3093
- };
3094
-
3095
- exports.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
3096
- const ret = debugString(getObject(arg1));
3097
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3098
- const len1 = WASM_VECTOR_LEN;
3099
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3100
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3101
- };
3102
3283
 
3103
- exports.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
3104
- const ret = typeof(getObject(arg0)) === 'function';
3105
- return ret;
3106
- };
3107
-
3108
- exports.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
3109
- const ret = getObject(arg0) === null;
3110
- return ret;
3111
- };
3112
-
3113
- exports.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
3114
- const val = getObject(arg0);
3115
- const ret = typeof(val) === 'object' && val !== null;
3116
- return ret;
3117
- };
3284
+ function dropObject(idx) {
3285
+ if (idx < 1028) return;
3286
+ heap[idx] = heap_next;
3287
+ heap_next = idx;
3288
+ }
3118
3289
 
3119
- exports.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
3120
- const ret = typeof(getObject(arg0)) === 'string';
3121
- return ret;
3122
- };
3290
+ function getArrayF32FromWasm0(ptr, len) {
3291
+ ptr = ptr >>> 0;
3292
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
3293
+ }
3123
3294
 
3124
- exports.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
3125
- const ret = getObject(arg0) === undefined;
3126
- return ret;
3127
- };
3295
+ function getArrayU8FromWasm0(ptr, len) {
3296
+ ptr = ptr >>> 0;
3297
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
3298
+ }
3128
3299
 
3129
- exports.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
3130
- const ret = getObject(arg0) == getObject(arg1);
3131
- return ret;
3132
- };
3300
+ let cachedDataViewMemory0 = null;
3301
+ function getDataViewMemory0() {
3302
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
3303
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
3304
+ }
3305
+ return cachedDataViewMemory0;
3306
+ }
3133
3307
 
3134
- exports.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
3135
- const obj = getObject(arg1);
3136
- const ret = typeof(obj) === 'number' ? obj : undefined;
3137
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3138
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3139
- };
3308
+ let cachedFloat32ArrayMemory0 = null;
3309
+ function getFloat32ArrayMemory0() {
3310
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
3311
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
3312
+ }
3313
+ return cachedFloat32ArrayMemory0;
3314
+ }
3140
3315
 
3141
- exports.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
3142
- const obj = getObject(arg1);
3143
- const ret = typeof(obj) === 'string' ? obj : undefined;
3144
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3145
- var len1 = WASM_VECTOR_LEN;
3146
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3147
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3148
- };
3316
+ function getStringFromWasm0(ptr, len) {
3317
+ ptr = ptr >>> 0;
3318
+ return decodeText(ptr, len);
3319
+ }
3149
3320
 
3150
- exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
3151
- throw new Error(getStringFromWasm0(arg0, arg1));
3152
- };
3321
+ let cachedUint32ArrayMemory0 = null;
3322
+ function getUint32ArrayMemory0() {
3323
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
3324
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
3325
+ }
3326
+ return cachedUint32ArrayMemory0;
3327
+ }
3153
3328
 
3154
- exports.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
3155
- const ret = getObject(arg0).call(getObject(arg1));
3156
- return addHeapObject(ret);
3157
- }, arguments) };
3329
+ let cachedUint8ArrayMemory0 = null;
3330
+ function getUint8ArrayMemory0() {
3331
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
3332
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
3333
+ }
3334
+ return cachedUint8ArrayMemory0;
3335
+ }
3158
3336
 
3159
- exports.__wbg_done_62ea16af4ce34b24 = function(arg0) {
3160
- const ret = getObject(arg0).done;
3161
- return ret;
3162
- };
3337
+ function getObject(idx) { return heap[idx]; }
3163
3338
 
3164
- exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
3165
- let deferred0_0;
3166
- let deferred0_1;
3339
+ function handleError(f, args) {
3167
3340
  try {
3168
- deferred0_0 = arg0;
3169
- deferred0_1 = arg1;
3170
- console.error(getStringFromWasm0(arg0, arg1));
3171
- } finally {
3172
- wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
3341
+ return f.apply(this, args);
3342
+ } catch (e) {
3343
+ wasm.__wbindgen_export3(addHeapObject(e));
3173
3344
  }
3174
- };
3175
-
3176
- exports.__wbg_fromCodePoint_50facac709b76f67 = function() { return handleError(function (arg0) {
3177
- const ret = String.fromCodePoint(arg0 >>> 0);
3178
- return addHeapObject(ret);
3179
- }, arguments) };
3345
+ }
3180
3346
 
3181
- exports.__wbg_from_29a8414a7a7cd19d = function(arg0) {
3182
- const ret = Array.from(getObject(arg0));
3183
- return addHeapObject(ret);
3184
- };
3347
+ let heap = new Array(1024).fill(undefined);
3348
+ heap.push(undefined, null, true, false);
3185
3349
 
3186
- exports.__wbg_getRandomValues_9b655bdd369112f2 = function() { return handleError(function (arg0, arg1) {
3187
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
3188
- }, arguments) };
3350
+ let heap_next = heap.length;
3189
3351
 
3190
- exports.__wbg_getTime_ad1e9878a735af08 = function(arg0) {
3191
- const ret = getObject(arg0).getTime();
3192
- return ret;
3193
- };
3352
+ function isLikeNone(x) {
3353
+ return x === undefined || x === null;
3354
+ }
3194
3355
 
3195
- exports.__wbg_getTimezoneOffset_45389e26d6f46823 = function(arg0) {
3196
- const ret = getObject(arg0).getTimezoneOffset();
3197
- return ret;
3198
- };
3356
+ function passArray32ToWasm0(arg, malloc) {
3357
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3358
+ getUint32ArrayMemory0().set(arg, ptr / 4);
3359
+ WASM_VECTOR_LEN = arg.length;
3360
+ return ptr;
3361
+ }
3199
3362
 
3200
- exports.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
3201
- const ret = getObject(arg0)[arg1 >>> 0];
3202
- return addHeapObject(ret);
3203
- };
3363
+ function passArray8ToWasm0(arg, malloc) {
3364
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
3365
+ getUint8ArrayMemory0().set(arg, ptr / 1);
3366
+ WASM_VECTOR_LEN = arg.length;
3367
+ return ptr;
3368
+ }
3204
3369
 
3205
- exports.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
3206
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
3207
- return addHeapObject(ret);
3208
- }, arguments) };
3370
+ function passArrayF32ToWasm0(arg, malloc) {
3371
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3372
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
3373
+ WASM_VECTOR_LEN = arg.length;
3374
+ return ptr;
3375
+ }
3209
3376
 
3210
- exports.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
3211
- let result;
3212
- try {
3213
- result = getObject(arg0) instanceof ArrayBuffer;
3214
- } catch (_) {
3215
- result = false;
3377
+ function passArrayJsValueToWasm0(array, malloc) {
3378
+ const ptr = malloc(array.length * 4, 4) >>> 0;
3379
+ const mem = getDataViewMemory0();
3380
+ for (let i = 0; i < array.length; i++) {
3381
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
3216
3382
  }
3217
- const ret = result;
3218
- return ret;
3219
- };
3383
+ WASM_VECTOR_LEN = array.length;
3384
+ return ptr;
3385
+ }
3220
3386
 
3221
- exports.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
3222
- let result;
3223
- try {
3224
- result = getObject(arg0) instanceof Uint8Array;
3225
- } catch (_) {
3226
- result = false;
3387
+ function passStringToWasm0(arg, malloc, realloc) {
3388
+ if (realloc === undefined) {
3389
+ const buf = cachedTextEncoder.encode(arg);
3390
+ const ptr = malloc(buf.length, 1) >>> 0;
3391
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
3392
+ WASM_VECTOR_LEN = buf.length;
3393
+ return ptr;
3227
3394
  }
3228
- const ret = result;
3229
- return ret;
3230
- };
3231
-
3232
- exports.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
3233
- const ret = Array.isArray(getObject(arg0));
3234
- return ret;
3235
- };
3236
-
3237
- exports.__wbg_iterator_27b7c8b35ab3e86b = function() {
3238
- const ret = Symbol.iterator;
3239
- return addHeapObject(ret);
3240
- };
3241
-
3242
- exports.__wbg_length_22ac23eaec9d8053 = function(arg0) {
3243
- const ret = getObject(arg0).length;
3244
- return ret;
3245
- };
3246
-
3247
- exports.__wbg_length_d45040a40c570362 = function(arg0) {
3248
- const ret = getObject(arg0).length;
3249
- return ret;
3250
- };
3251
3395
 
3252
- exports.__wbg_new_0_23cedd11d9b40c9d = function() {
3253
- const ret = new Date();
3254
- return addHeapObject(ret);
3255
- };
3256
-
3257
- exports.__wbg_new_1ba21ce319a06297 = function() {
3258
- const ret = new Object();
3259
- return addHeapObject(ret);
3260
- };
3261
-
3262
- exports.__wbg_new_25f239778d6112b9 = function() {
3263
- const ret = new Array();
3264
- return addHeapObject(ret);
3265
- };
3266
-
3267
- exports.__wbg_new_6421f6084cc5bc5a = function(arg0) {
3268
- const ret = new Uint8Array(getObject(arg0));
3269
- return addHeapObject(ret);
3270
- };
3271
-
3272
- exports.__wbg_new_8a6f238a6ece86ea = function() {
3273
- const ret = new Error();
3274
- return addHeapObject(ret);
3275
- };
3276
-
3277
- exports.__wbg_new_b2db8aa2650f793a = function(arg0) {
3278
- const ret = new Date(getObject(arg0));
3279
- return addHeapObject(ret);
3280
- };
3281
-
3282
- exports.__wbg_new_b546ae120718850e = function() {
3283
- const ret = new Map();
3284
- return addHeapObject(ret);
3285
- };
3286
-
3287
- exports.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
3288
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
3289
- return addHeapObject(ret);
3290
- };
3396
+ let len = arg.length;
3397
+ let ptr = malloc(len, 1) >>> 0;
3291
3398
 
3292
- exports.__wbg_next_138a17bbf04e926c = function(arg0) {
3293
- const ret = getObject(arg0).next;
3294
- return addHeapObject(ret);
3295
- };
3399
+ const mem = getUint8ArrayMemory0();
3296
3400
 
3297
- exports.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
3298
- const ret = getObject(arg0).next();
3299
- return addHeapObject(ret);
3300
- }, arguments) };
3401
+ let offset = 0;
3301
3402
 
3302
- exports.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
3303
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
3304
- };
3403
+ for (; offset < len; offset++) {
3404
+ const code = arg.charCodeAt(offset);
3405
+ if (code > 0x7F) break;
3406
+ mem[ptr + offset] = code;
3407
+ }
3408
+ if (offset !== len) {
3409
+ if (offset !== 0) {
3410
+ arg = arg.slice(offset);
3411
+ }
3412
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
3413
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
3414
+ const ret = cachedTextEncoder.encodeInto(arg, view);
3305
3415
 
3306
- exports.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
3307
- const ret = getObject(arg0).push(getObject(arg1));
3308
- return ret;
3309
- };
3416
+ offset += ret.written;
3417
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
3418
+ }
3310
3419
 
3311
- exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
3312
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
3313
- };
3420
+ WASM_VECTOR_LEN = offset;
3421
+ return ptr;
3422
+ }
3314
3423
 
3315
- exports.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
3316
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
3424
+ function takeObject(idx) {
3425
+ const ret = getObject(idx);
3426
+ dropObject(idx);
3317
3427
  return ret;
3318
- }, arguments) };
3319
-
3320
- exports.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
3321
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
3322
- };
3323
-
3324
- exports.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
3325
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
3326
- return addHeapObject(ret);
3327
- };
3328
-
3329
- exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
3330
- const ret = getObject(arg1).stack;
3331
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3332
- const len1 = WASM_VECTOR_LEN;
3333
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3334
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3335
- };
3336
-
3337
- exports.__wbg_value_57b7b035e117f7ee = function(arg0) {
3338
- const ret = getObject(arg0).value;
3339
- return addHeapObject(ret);
3340
- };
3341
-
3342
- exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3343
- // Cast intrinsic for `Ref(String) -> Externref`.
3344
- const ret = getStringFromWasm0(arg0, arg1);
3345
- return addHeapObject(ret);
3346
- };
3347
-
3348
- exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3349
- // Cast intrinsic for `U64 -> Externref`.
3350
- const ret = BigInt.asUintN(64, arg0);
3351
- return addHeapObject(ret);
3352
- };
3428
+ }
3353
3429
 
3354
- exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
3355
- // Cast intrinsic for `I64 -> Externref`.
3356
- const ret = arg0;
3357
- return addHeapObject(ret);
3358
- };
3430
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3431
+ cachedTextDecoder.decode();
3432
+ function decodeText(ptr, len) {
3433
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
3434
+ }
3359
3435
 
3360
- exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
3361
- // Cast intrinsic for `F64 -> Externref`.
3362
- const ret = arg0;
3363
- return addHeapObject(ret);
3364
- };
3436
+ const cachedTextEncoder = new TextEncoder();
3365
3437
 
3366
- exports.__wbindgen_object_clone_ref = function(arg0) {
3367
- const ret = getObject(arg0);
3368
- return addHeapObject(ret);
3369
- };
3438
+ if (!('encodeInto' in cachedTextEncoder)) {
3439
+ cachedTextEncoder.encodeInto = function (arg, view) {
3440
+ const buf = cachedTextEncoder.encode(arg);
3441
+ view.set(buf);
3442
+ return {
3443
+ read: arg.length,
3444
+ written: buf.length
3445
+ };
3446
+ };
3447
+ }
3370
3448
 
3371
- exports.__wbindgen_object_drop_ref = function(arg0) {
3372
- takeObject(arg0);
3373
- };
3449
+ let WASM_VECTOR_LEN = 0;
3374
3450
 
3375
3451
  const wasmPath = `${__dirname}/pdf_oxide_bg.wasm`;
3376
3452
  const wasmBytes = require('fs').readFileSync(wasmPath);
3377
3453
  const wasmModule = new WebAssembly.Module(wasmBytes);
3378
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
3454
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;