pdf-oxide-wasm 0.3.13 → 0.3.15
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/package.json +1 -1
- package/pdf_oxide.d.ts +245 -12
- package/pdf_oxide.js +1096 -45
- package/pdf_oxide_bg.wasm +0 -0
- package/pdf_oxide_bg.wasm.d.ts +61 -6
package/pdf_oxide.js
CHANGED
|
@@ -1,5 +1,404 @@
|
|
|
1
1
|
/* @ts-self-types="./pdf_oxide.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Style configuration for header/footer text.
|
|
5
|
+
*/
|
|
6
|
+
class ArtifactStyle {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
ptr = ptr >>> 0;
|
|
9
|
+
const obj = Object.create(ArtifactStyle.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
ArtifactStyleFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
ArtifactStyleFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_artifactstyle_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @returns {ArtifactStyle}
|
|
26
|
+
*/
|
|
27
|
+
bold() {
|
|
28
|
+
const ptr = this.__destroy_into_raw();
|
|
29
|
+
const ret = wasm.wasmartifactstyle_bold(ptr);
|
|
30
|
+
return ArtifactStyle.__wrap(ret);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} r
|
|
34
|
+
* @param {number} g
|
|
35
|
+
* @param {number} b
|
|
36
|
+
* @returns {ArtifactStyle}
|
|
37
|
+
*/
|
|
38
|
+
color(r, g, b) {
|
|
39
|
+
const ptr = this.__destroy_into_raw();
|
|
40
|
+
const ret = wasm.wasmartifactstyle_color(ptr, r, g, b);
|
|
41
|
+
return ArtifactStyle.__wrap(ret);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} name
|
|
45
|
+
* @param {number} size
|
|
46
|
+
* @returns {ArtifactStyle}
|
|
47
|
+
*/
|
|
48
|
+
font(name, size) {
|
|
49
|
+
const ptr = this.__destroy_into_raw();
|
|
50
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.wasmartifactstyle_font(ptr, ptr0, len0, size);
|
|
53
|
+
return ArtifactStyle.__wrap(ret);
|
|
54
|
+
}
|
|
55
|
+
constructor() {
|
|
56
|
+
const ret = wasm.wasmartifactstyle_new();
|
|
57
|
+
this.__wbg_ptr = ret >>> 0;
|
|
58
|
+
ArtifactStyleFinalization.register(this, this.__wbg_ptr, this);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (Symbol.dispose) ArtifactStyle.prototype[Symbol.dispose] = ArtifactStyle.prototype.free;
|
|
63
|
+
exports.ArtifactStyle = ArtifactStyle;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A header or footer artifact definition.
|
|
67
|
+
*/
|
|
68
|
+
class WasmArtifact {
|
|
69
|
+
static __wrap(ptr) {
|
|
70
|
+
ptr = ptr >>> 0;
|
|
71
|
+
const obj = Object.create(WasmArtifact.prototype);
|
|
72
|
+
obj.__wbg_ptr = ptr;
|
|
73
|
+
WasmArtifactFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
__destroy_into_raw() {
|
|
77
|
+
const ptr = this.__wbg_ptr;
|
|
78
|
+
this.__wbg_ptr = 0;
|
|
79
|
+
WasmArtifactFinalization.unregister(this);
|
|
80
|
+
return ptr;
|
|
81
|
+
}
|
|
82
|
+
free() {
|
|
83
|
+
const ptr = this.__destroy_into_raw();
|
|
84
|
+
wasm.__wbg_wasmartifact_free(ptr, 0);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @param {string} text
|
|
88
|
+
* @returns {WasmArtifact}
|
|
89
|
+
*/
|
|
90
|
+
static center(text) {
|
|
91
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
92
|
+
const len0 = WASM_VECTOR_LEN;
|
|
93
|
+
const ret = wasm.wasmartifact_center(ptr0, len0);
|
|
94
|
+
return WasmArtifact.__wrap(ret);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} text
|
|
98
|
+
* @returns {WasmArtifact}
|
|
99
|
+
*/
|
|
100
|
+
static left(text) {
|
|
101
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ret = wasm.wasmartifact_left(ptr0, len0);
|
|
104
|
+
return WasmArtifact.__wrap(ret);
|
|
105
|
+
}
|
|
106
|
+
constructor() {
|
|
107
|
+
const ret = wasm.wasmartifact_new();
|
|
108
|
+
this.__wbg_ptr = ret >>> 0;
|
|
109
|
+
WasmArtifactFinalization.register(this, this.__wbg_ptr, this);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} text
|
|
114
|
+
* @returns {WasmArtifact}
|
|
115
|
+
*/
|
|
116
|
+
static right(text) {
|
|
117
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.wasmartifact_right(ptr0, len0);
|
|
120
|
+
return WasmArtifact.__wrap(ret);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {number} offset
|
|
124
|
+
* @returns {WasmArtifact}
|
|
125
|
+
*/
|
|
126
|
+
withOffset(offset) {
|
|
127
|
+
const ptr = this.__destroy_into_raw();
|
|
128
|
+
const ret = wasm.wasmartifact_withOffset(ptr, offset);
|
|
129
|
+
return WasmArtifact.__wrap(ret);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {ArtifactStyle} style
|
|
133
|
+
* @returns {WasmArtifact}
|
|
134
|
+
*/
|
|
135
|
+
withStyle(style) {
|
|
136
|
+
const ptr = this.__destroy_into_raw();
|
|
137
|
+
_assertClass(style, ArtifactStyle);
|
|
138
|
+
const ret = wasm.wasmartifact_withStyle(ptr, style.__wbg_ptr);
|
|
139
|
+
return WasmArtifact.__wrap(ret);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (Symbol.dispose) WasmArtifact.prototype[Symbol.dispose] = WasmArtifact.prototype.free;
|
|
143
|
+
exports.WasmArtifact = WasmArtifact;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A footer definition.
|
|
147
|
+
*/
|
|
148
|
+
class WasmFooter {
|
|
149
|
+
static __wrap(ptr) {
|
|
150
|
+
ptr = ptr >>> 0;
|
|
151
|
+
const obj = Object.create(WasmFooter.prototype);
|
|
152
|
+
obj.__wbg_ptr = ptr;
|
|
153
|
+
WasmFooterFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
154
|
+
return obj;
|
|
155
|
+
}
|
|
156
|
+
__destroy_into_raw() {
|
|
157
|
+
const ptr = this.__wbg_ptr;
|
|
158
|
+
this.__wbg_ptr = 0;
|
|
159
|
+
WasmFooterFinalization.unregister(this);
|
|
160
|
+
return ptr;
|
|
161
|
+
}
|
|
162
|
+
free() {
|
|
163
|
+
const ptr = this.__destroy_into_raw();
|
|
164
|
+
wasm.__wbg_wasmfooter_free(ptr, 0);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @param {string} text
|
|
168
|
+
* @returns {WasmFooter}
|
|
169
|
+
*/
|
|
170
|
+
static center(text) {
|
|
171
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ret = wasm.wasmfooter_center(ptr0, len0);
|
|
174
|
+
return WasmFooter.__wrap(ret);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {string} text
|
|
178
|
+
* @returns {WasmFooter}
|
|
179
|
+
*/
|
|
180
|
+
static left(text) {
|
|
181
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
182
|
+
const len0 = WASM_VECTOR_LEN;
|
|
183
|
+
const ret = wasm.wasmfooter_left(ptr0, len0);
|
|
184
|
+
return WasmFooter.__wrap(ret);
|
|
185
|
+
}
|
|
186
|
+
constructor() {
|
|
187
|
+
const ret = wasm.wasmfooter_new();
|
|
188
|
+
this.__wbg_ptr = ret >>> 0;
|
|
189
|
+
WasmFooterFinalization.register(this, this.__wbg_ptr, this);
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @param {string} text
|
|
194
|
+
* @returns {WasmFooter}
|
|
195
|
+
*/
|
|
196
|
+
static right(text) {
|
|
197
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
198
|
+
const len0 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.wasmfooter_right(ptr0, len0);
|
|
200
|
+
return WasmFooter.__wrap(ret);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (Symbol.dispose) WasmFooter.prototype[Symbol.dispose] = WasmFooter.prototype.free;
|
|
204
|
+
exports.WasmFooter = WasmFooter;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* A header definition.
|
|
208
|
+
*/
|
|
209
|
+
class WasmHeader {
|
|
210
|
+
static __wrap(ptr) {
|
|
211
|
+
ptr = ptr >>> 0;
|
|
212
|
+
const obj = Object.create(WasmHeader.prototype);
|
|
213
|
+
obj.__wbg_ptr = ptr;
|
|
214
|
+
WasmHeaderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
215
|
+
return obj;
|
|
216
|
+
}
|
|
217
|
+
__destroy_into_raw() {
|
|
218
|
+
const ptr = this.__wbg_ptr;
|
|
219
|
+
this.__wbg_ptr = 0;
|
|
220
|
+
WasmHeaderFinalization.unregister(this);
|
|
221
|
+
return ptr;
|
|
222
|
+
}
|
|
223
|
+
free() {
|
|
224
|
+
const ptr = this.__destroy_into_raw();
|
|
225
|
+
wasm.__wbg_wasmheader_free(ptr, 0);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @param {string} text
|
|
229
|
+
* @returns {WasmHeader}
|
|
230
|
+
*/
|
|
231
|
+
static center(text) {
|
|
232
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
233
|
+
const len0 = WASM_VECTOR_LEN;
|
|
234
|
+
const ret = wasm.wasmheader_center(ptr0, len0);
|
|
235
|
+
return WasmHeader.__wrap(ret);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @param {string} text
|
|
239
|
+
* @returns {WasmHeader}
|
|
240
|
+
*/
|
|
241
|
+
static left(text) {
|
|
242
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
244
|
+
const ret = wasm.wasmheader_left(ptr0, len0);
|
|
245
|
+
return WasmHeader.__wrap(ret);
|
|
246
|
+
}
|
|
247
|
+
constructor() {
|
|
248
|
+
const ret = wasm.wasmheader_new();
|
|
249
|
+
this.__wbg_ptr = ret >>> 0;
|
|
250
|
+
WasmHeaderFinalization.register(this, this.__wbg_ptr, this);
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @param {string} text
|
|
255
|
+
* @returns {WasmHeader}
|
|
256
|
+
*/
|
|
257
|
+
static right(text) {
|
|
258
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.wasmheader_right(ptr0, len0);
|
|
261
|
+
return WasmHeader.__wrap(ret);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (Symbol.dispose) WasmHeader.prototype[Symbol.dispose] = WasmHeader.prototype.free;
|
|
265
|
+
exports.WasmHeader = WasmHeader;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* OCR configuration for WebAssembly.
|
|
269
|
+
*/
|
|
270
|
+
class WasmOcrConfig {
|
|
271
|
+
__destroy_into_raw() {
|
|
272
|
+
const ptr = this.__wbg_ptr;
|
|
273
|
+
this.__wbg_ptr = 0;
|
|
274
|
+
WasmOcrConfigFinalization.unregister(this);
|
|
275
|
+
return ptr;
|
|
276
|
+
}
|
|
277
|
+
free() {
|
|
278
|
+
const ptr = this.__destroy_into_raw();
|
|
279
|
+
wasm.__wbg_wasmocrconfig_free(ptr, 0);
|
|
280
|
+
}
|
|
281
|
+
constructor() {
|
|
282
|
+
const ret = wasm.wasmocrconfig_new();
|
|
283
|
+
this.__wbg_ptr = ret >>> 0;
|
|
284
|
+
WasmOcrConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (Symbol.dispose) WasmOcrConfig.prototype[Symbol.dispose] = WasmOcrConfig.prototype.free;
|
|
289
|
+
exports.WasmOcrConfig = WasmOcrConfig;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* OCR engine for WebAssembly.
|
|
293
|
+
*/
|
|
294
|
+
class WasmOcrEngine {
|
|
295
|
+
__destroy_into_raw() {
|
|
296
|
+
const ptr = this.__wbg_ptr;
|
|
297
|
+
this.__wbg_ptr = 0;
|
|
298
|
+
WasmOcrEngineFinalization.unregister(this);
|
|
299
|
+
return ptr;
|
|
300
|
+
}
|
|
301
|
+
free() {
|
|
302
|
+
const ptr = this.__destroy_into_raw();
|
|
303
|
+
wasm.__wbg_wasmocrengine_free(ptr, 0);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* @param {string} _det_model_path
|
|
307
|
+
* @param {string} _rec_model_path
|
|
308
|
+
* @param {string} _dict_path
|
|
309
|
+
* @param {WasmOcrConfig | null} [_config]
|
|
310
|
+
*/
|
|
311
|
+
constructor(_det_model_path, _rec_model_path, _dict_path, _config) {
|
|
312
|
+
try {
|
|
313
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
314
|
+
const ptr0 = passStringToWasm0(_det_model_path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
316
|
+
const ptr1 = passStringToWasm0(_rec_model_path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
317
|
+
const len1 = WASM_VECTOR_LEN;
|
|
318
|
+
const ptr2 = passStringToWasm0(_dict_path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
319
|
+
const len2 = WASM_VECTOR_LEN;
|
|
320
|
+
let ptr3 = 0;
|
|
321
|
+
if (!isLikeNone(_config)) {
|
|
322
|
+
_assertClass(_config, WasmOcrConfig);
|
|
323
|
+
ptr3 = _config.__destroy_into_raw();
|
|
324
|
+
}
|
|
325
|
+
wasm.wasmocrengine_new(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3);
|
|
326
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
327
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
328
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
329
|
+
if (r2) {
|
|
330
|
+
throw takeObject(r1);
|
|
331
|
+
}
|
|
332
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
333
|
+
WasmOcrEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
334
|
+
return this;
|
|
335
|
+
} finally {
|
|
336
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (Symbol.dispose) WasmOcrEngine.prototype[Symbol.dispose] = WasmOcrEngine.prototype.free;
|
|
341
|
+
exports.WasmOcrEngine = WasmOcrEngine;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* A complete page template with header and footer.
|
|
345
|
+
*/
|
|
346
|
+
class WasmPageTemplate {
|
|
347
|
+
static __wrap(ptr) {
|
|
348
|
+
ptr = ptr >>> 0;
|
|
349
|
+
const obj = Object.create(WasmPageTemplate.prototype);
|
|
350
|
+
obj.__wbg_ptr = ptr;
|
|
351
|
+
WasmPageTemplateFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
352
|
+
return obj;
|
|
353
|
+
}
|
|
354
|
+
__destroy_into_raw() {
|
|
355
|
+
const ptr = this.__wbg_ptr;
|
|
356
|
+
this.__wbg_ptr = 0;
|
|
357
|
+
WasmPageTemplateFinalization.unregister(this);
|
|
358
|
+
return ptr;
|
|
359
|
+
}
|
|
360
|
+
free() {
|
|
361
|
+
const ptr = this.__destroy_into_raw();
|
|
362
|
+
wasm.__wbg_wasmpagetemplate_free(ptr, 0);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @param {WasmArtifact} footer
|
|
366
|
+
* @returns {WasmPageTemplate}
|
|
367
|
+
*/
|
|
368
|
+
footer(footer) {
|
|
369
|
+
const ptr = this.__destroy_into_raw();
|
|
370
|
+
_assertClass(footer, WasmArtifact);
|
|
371
|
+
const ret = wasm.wasmpagetemplate_footer(ptr, footer.__wbg_ptr);
|
|
372
|
+
return WasmPageTemplate.__wrap(ret);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @param {WasmArtifact} header
|
|
376
|
+
* @returns {WasmPageTemplate}
|
|
377
|
+
*/
|
|
378
|
+
header(header) {
|
|
379
|
+
const ptr = this.__destroy_into_raw();
|
|
380
|
+
_assertClass(header, WasmArtifact);
|
|
381
|
+
const ret = wasm.wasmpagetemplate_header(ptr, header.__wbg_ptr);
|
|
382
|
+
return WasmPageTemplate.__wrap(ret);
|
|
383
|
+
}
|
|
384
|
+
constructor() {
|
|
385
|
+
const ret = wasm.wasmpagetemplate_new();
|
|
386
|
+
this.__wbg_ptr = ret >>> 0;
|
|
387
|
+
WasmPageTemplateFinalization.register(this, this.__wbg_ptr, this);
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* @returns {WasmPageTemplate}
|
|
392
|
+
*/
|
|
393
|
+
skipFirstPage() {
|
|
394
|
+
const ptr = this.__destroy_into_raw();
|
|
395
|
+
const ret = wasm.wasmpagetemplate_skipFirstPage(ptr);
|
|
396
|
+
return WasmPageTemplate.__wrap(ret);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (Symbol.dispose) WasmPageTemplate.prototype[Symbol.dispose] = WasmPageTemplate.prototype.free;
|
|
400
|
+
exports.WasmPageTemplate = WasmPageTemplate;
|
|
401
|
+
|
|
3
402
|
/**
|
|
4
403
|
* Create new PDF documents from Markdown, HTML, or plain text.
|
|
5
404
|
*
|
|
@@ -337,6 +736,67 @@ class WasmPdfDocument {
|
|
|
337
736
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
737
|
}
|
|
339
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* Erase both header and footer content.
|
|
741
|
+
*
|
|
742
|
+
* @param page_index - Zero-based page number
|
|
743
|
+
* @param {number} page_index
|
|
744
|
+
*/
|
|
745
|
+
eraseArtifacts(page_index) {
|
|
746
|
+
try {
|
|
747
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
748
|
+
wasm.wasmpdfdocument_eraseArtifacts(retptr, this.__wbg_ptr, page_index);
|
|
749
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
750
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
751
|
+
if (r1) {
|
|
752
|
+
throw takeObject(r0);
|
|
753
|
+
}
|
|
754
|
+
} finally {
|
|
755
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Erase existing footer content.
|
|
760
|
+
*
|
|
761
|
+
* Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
|
|
762
|
+
*
|
|
763
|
+
* @param page_index - Zero-based page number
|
|
764
|
+
* @param {number} page_index
|
|
765
|
+
*/
|
|
766
|
+
eraseFooter(page_index) {
|
|
767
|
+
try {
|
|
768
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
769
|
+
wasm.wasmpdfdocument_eraseFooter(retptr, this.__wbg_ptr, page_index);
|
|
770
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
771
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
772
|
+
if (r1) {
|
|
773
|
+
throw takeObject(r0);
|
|
774
|
+
}
|
|
775
|
+
} finally {
|
|
776
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Erase existing header content.
|
|
781
|
+
*
|
|
782
|
+
* Identifies existing text in the header area (top 15%) and marks it for erasure.
|
|
783
|
+
*
|
|
784
|
+
* @param page_index - Zero-based page number
|
|
785
|
+
* @param {number} page_index
|
|
786
|
+
*/
|
|
787
|
+
eraseHeader(page_index) {
|
|
788
|
+
try {
|
|
789
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
790
|
+
wasm.wasmpdfdocument_eraseHeader(retptr, this.__wbg_ptr, page_index);
|
|
791
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
792
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
793
|
+
if (r1) {
|
|
794
|
+
throw takeObject(r0);
|
|
795
|
+
}
|
|
796
|
+
} finally {
|
|
797
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
340
800
|
/**
|
|
341
801
|
* Erase (whiteout) a rectangular region on a page.
|
|
342
802
|
* @param {number} page_index
|
|
@@ -442,13 +902,19 @@ class WasmPdfDocument {
|
|
|
442
902
|
*
|
|
443
903
|
* Returns an array of objects with: char, bbox {x, y, width, height},
|
|
444
904
|
* font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
|
|
905
|
+
*
|
|
906
|
+
* @param page_index - Zero-based page number
|
|
907
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
445
908
|
* @param {number} page_index
|
|
909
|
+
* @param {Float32Array | null} [region]
|
|
446
910
|
* @returns {any}
|
|
447
911
|
*/
|
|
448
|
-
extractChars(page_index) {
|
|
912
|
+
extractChars(page_index, region) {
|
|
449
913
|
try {
|
|
450
914
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
451
|
-
|
|
915
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
916
|
+
var len0 = WASM_VECTOR_LEN;
|
|
917
|
+
wasm.wasmpdfdocument_extractChars(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
452
918
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
453
919
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
454
920
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -487,13 +953,48 @@ class WasmPdfDocument {
|
|
|
487
953
|
*
|
|
488
954
|
* Returns an array of objects with: width, height, color_space,
|
|
489
955
|
* bits_per_component, bbox (if available). Does NOT return raw image bytes.
|
|
956
|
+
*
|
|
957
|
+
* @param page_index - Zero-based page number
|
|
958
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
490
959
|
* @param {number} page_index
|
|
960
|
+
* @param {Float32Array | null} [region]
|
|
491
961
|
* @returns {any}
|
|
492
962
|
*/
|
|
493
|
-
extractImages(page_index) {
|
|
963
|
+
extractImages(page_index, region) {
|
|
494
964
|
try {
|
|
495
965
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
496
|
-
|
|
966
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
967
|
+
var len0 = WASM_VECTOR_LEN;
|
|
968
|
+
wasm.wasmpdfdocument_extractImages(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
969
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
970
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
971
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
972
|
+
if (r2) {
|
|
973
|
+
throw takeObject(r1);
|
|
974
|
+
}
|
|
975
|
+
return takeObject(r0);
|
|
976
|
+
} finally {
|
|
977
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Extract only straight lines from a page (v0.3.14).
|
|
982
|
+
*
|
|
983
|
+
* Identifies paths that form a single straight line segment.
|
|
984
|
+
*
|
|
985
|
+
* @param page_index - Zero-based page number
|
|
986
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
987
|
+
* @returns Array of path objects
|
|
988
|
+
* @param {number} page_index
|
|
989
|
+
* @param {Float32Array | null} [region]
|
|
990
|
+
* @returns {any}
|
|
991
|
+
*/
|
|
992
|
+
extractLines(page_index, region) {
|
|
993
|
+
try {
|
|
994
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
995
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
996
|
+
var len0 = WASM_VECTOR_LEN;
|
|
997
|
+
wasm.wasmpdfdocument_extractLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
497
998
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
498
999
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
499
1000
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -509,14 +1010,47 @@ class WasmPdfDocument {
|
|
|
509
1010
|
* Extract vector paths (lines, curves, shapes) from a page.
|
|
510
1011
|
*
|
|
511
1012
|
* @param page_index - Zero-based page number
|
|
1013
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
512
1014
|
* @returns Array of path objects with bbox, stroke_color, fill_color, etc.
|
|
513
1015
|
* @param {number} page_index
|
|
1016
|
+
* @param {Float32Array | null} [region]
|
|
514
1017
|
* @returns {any}
|
|
515
1018
|
*/
|
|
516
|
-
extractPaths(page_index) {
|
|
1019
|
+
extractPaths(page_index, region) {
|
|
517
1020
|
try {
|
|
518
1021
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
519
|
-
|
|
1022
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1023
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1024
|
+
wasm.wasmpdfdocument_extractPaths(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
1025
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1026
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1027
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1028
|
+
if (r2) {
|
|
1029
|
+
throw takeObject(r1);
|
|
1030
|
+
}
|
|
1031
|
+
return takeObject(r0);
|
|
1032
|
+
} finally {
|
|
1033
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Extract only rectangles from a page (v0.3.14).
|
|
1038
|
+
*
|
|
1039
|
+
* Identifies paths that form axis-aligned rectangles.
|
|
1040
|
+
*
|
|
1041
|
+
* @param page_index - Zero-based page number
|
|
1042
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
1043
|
+
* @returns Array of path objects
|
|
1044
|
+
* @param {number} page_index
|
|
1045
|
+
* @param {Float32Array | null} [region]
|
|
1046
|
+
* @returns {any}
|
|
1047
|
+
*/
|
|
1048
|
+
extractRects(page_index, region) {
|
|
1049
|
+
try {
|
|
1050
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1051
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1052
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1053
|
+
wasm.wasmpdfdocument_extractRects(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
520
1054
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
521
1055
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
522
1056
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -534,12 +1068,41 @@ class WasmPdfDocument {
|
|
|
534
1068
|
* Returns an array of objects with: text, bbox, font_name, font_size,
|
|
535
1069
|
* font_weight, is_italic, color, etc.
|
|
536
1070
|
* @param {number} page_index
|
|
1071
|
+
* @param {Float32Array | null} [region]
|
|
1072
|
+
* @returns {any}
|
|
1073
|
+
*/
|
|
1074
|
+
extractSpans(page_index, region) {
|
|
1075
|
+
try {
|
|
1076
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1077
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1078
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1079
|
+
wasm.wasmpdfdocument_extractSpans(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
1080
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1081
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1082
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1083
|
+
if (r2) {
|
|
1084
|
+
throw takeObject(r1);
|
|
1085
|
+
}
|
|
1086
|
+
return takeObject(r0);
|
|
1087
|
+
} finally {
|
|
1088
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Extract tables from a page (v0.3.14).
|
|
1093
|
+
*
|
|
1094
|
+
* @param page_index - Zero-based page number
|
|
1095
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
1096
|
+
* @param {number} page_index
|
|
1097
|
+
* @param {Float32Array | null} [region]
|
|
537
1098
|
* @returns {any}
|
|
538
1099
|
*/
|
|
539
|
-
|
|
1100
|
+
extractTables(page_index, region) {
|
|
540
1101
|
try {
|
|
541
1102
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
542
|
-
|
|
1103
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1104
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1105
|
+
wasm.wasmpdfdocument_extractTables(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
543
1106
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
544
1107
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
545
1108
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -555,31 +1118,124 @@ class WasmPdfDocument {
|
|
|
555
1118
|
* Extract plain text from a single page.
|
|
556
1119
|
*
|
|
557
1120
|
* @param page_index - Zero-based page number
|
|
1121
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
558
1122
|
* @param {number} page_index
|
|
1123
|
+
* @param {Float32Array | null} [region]
|
|
559
1124
|
* @returns {string}
|
|
560
1125
|
*/
|
|
561
|
-
extractText(page_index) {
|
|
562
|
-
let
|
|
563
|
-
let
|
|
1126
|
+
extractText(page_index, region) {
|
|
1127
|
+
let deferred3_0;
|
|
1128
|
+
let deferred3_1;
|
|
564
1129
|
try {
|
|
565
1130
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
566
|
-
|
|
1131
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1132
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1133
|
+
wasm.wasmpdfdocument_extractText(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
567
1134
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
568
1135
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
569
1136
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
570
1137
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
571
|
-
var
|
|
572
|
-
var
|
|
1138
|
+
var ptr2 = r0;
|
|
1139
|
+
var len2 = r1;
|
|
573
1140
|
if (r3) {
|
|
574
|
-
|
|
1141
|
+
ptr2 = 0; len2 = 0;
|
|
575
1142
|
throw takeObject(r2);
|
|
576
1143
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
return getStringFromWasm0(
|
|
1144
|
+
deferred3_0 = ptr2;
|
|
1145
|
+
deferred3_1 = len2;
|
|
1146
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1147
|
+
} finally {
|
|
1148
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1149
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Extract text lines from a page.
|
|
1154
|
+
*
|
|
1155
|
+
* Returns an array of objects with: text, bbox, words (array of Word objects).
|
|
1156
|
+
* @param {number} page_index
|
|
1157
|
+
* @param {Float32Array | null} [region]
|
|
1158
|
+
* @returns {any}
|
|
1159
|
+
*/
|
|
1160
|
+
extractTextLines(page_index, region) {
|
|
1161
|
+
try {
|
|
1162
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1163
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1164
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1165
|
+
wasm.wasmpdfdocument_extractTextLines(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
1166
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1167
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1168
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1169
|
+
if (r2) {
|
|
1170
|
+
throw takeObject(r1);
|
|
1171
|
+
}
|
|
1172
|
+
return takeObject(r0);
|
|
1173
|
+
} finally {
|
|
1174
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Extract text using OCR (optical character recognition).
|
|
1179
|
+
*
|
|
1180
|
+
* NOTE: OCR is not yet supported in the WebAssembly build due to missing
|
|
1181
|
+
* ONNX Runtime support for the web backend in the current implementation.
|
|
1182
|
+
* @param {number} _page_index
|
|
1183
|
+
* @param {WasmOcrEngine | null} [_engine]
|
|
1184
|
+
* @returns {string}
|
|
1185
|
+
*/
|
|
1186
|
+
extractTextOcr(_page_index, _engine) {
|
|
1187
|
+
let deferred3_0;
|
|
1188
|
+
let deferred3_1;
|
|
1189
|
+
try {
|
|
1190
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1191
|
+
let ptr0 = 0;
|
|
1192
|
+
if (!isLikeNone(_engine)) {
|
|
1193
|
+
_assertClass(_engine, WasmOcrEngine);
|
|
1194
|
+
ptr0 = _engine.__destroy_into_raw();
|
|
1195
|
+
}
|
|
1196
|
+
wasm.wasmpdfdocument_extractTextOcr(retptr, this.__wbg_ptr, _page_index, ptr0);
|
|
1197
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1198
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1199
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1200
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1201
|
+
var ptr2 = r0;
|
|
1202
|
+
var len2 = r1;
|
|
1203
|
+
if (r3) {
|
|
1204
|
+
ptr2 = 0; len2 = 0;
|
|
1205
|
+
throw takeObject(r2);
|
|
1206
|
+
}
|
|
1207
|
+
deferred3_0 = ptr2;
|
|
1208
|
+
deferred3_1 = len2;
|
|
1209
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1210
|
+
} finally {
|
|
1211
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1212
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Extract word-level data from a page.
|
|
1217
|
+
*
|
|
1218
|
+
* Returns an array of objects with: text, bbox, font_name, font_size,
|
|
1219
|
+
* font_weight, is_italic, is_bold.
|
|
1220
|
+
* @param {number} page_index
|
|
1221
|
+
* @param {Float32Array | null} [region]
|
|
1222
|
+
* @returns {any}
|
|
1223
|
+
*/
|
|
1224
|
+
extractWords(page_index, region) {
|
|
1225
|
+
try {
|
|
1226
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1227
|
+
var ptr0 = isLikeNone(region) ? 0 : passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
1228
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1229
|
+
wasm.wasmpdfdocument_extractWords(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
1230
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1231
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1232
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1233
|
+
if (r2) {
|
|
1234
|
+
throw takeObject(r1);
|
|
1235
|
+
}
|
|
1236
|
+
return takeObject(r0);
|
|
580
1237
|
} finally {
|
|
581
1238
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
582
|
-
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
583
1239
|
}
|
|
584
1240
|
}
|
|
585
1241
|
/**
|
|
@@ -757,8 +1413,19 @@ class WasmPdfDocument {
|
|
|
757
1413
|
* @returns {boolean}
|
|
758
1414
|
*/
|
|
759
1415
|
hasStructureTree() {
|
|
760
|
-
|
|
761
|
-
|
|
1416
|
+
try {
|
|
1417
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1418
|
+
wasm.wasmpdfdocument_hasStructureTree(retptr, this.__wbg_ptr);
|
|
1419
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1420
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1421
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1422
|
+
if (r2) {
|
|
1423
|
+
throw takeObject(r1);
|
|
1424
|
+
}
|
|
1425
|
+
return r0 !== 0;
|
|
1426
|
+
} finally {
|
|
1427
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1428
|
+
}
|
|
762
1429
|
}
|
|
763
1430
|
/**
|
|
764
1431
|
* Check if the document contains XFA form data.
|
|
@@ -915,44 +1582,119 @@ class WasmPdfDocument {
|
|
|
915
1582
|
}
|
|
916
1583
|
}
|
|
917
1584
|
/**
|
|
918
|
-
* Get the MediaBox of a page as [llx, lly, urx, ury].
|
|
919
|
-
* @param {number} page_index
|
|
920
|
-
* @returns {Float32Array}
|
|
1585
|
+
* Get the MediaBox of a page as [llx, lly, urx, ury].
|
|
1586
|
+
* @param {number} page_index
|
|
1587
|
+
* @returns {Float32Array}
|
|
1588
|
+
*/
|
|
1589
|
+
pageMediaBox(page_index) {
|
|
1590
|
+
try {
|
|
1591
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1592
|
+
wasm.wasmpdfdocument_pageMediaBox(retptr, this.__wbg_ptr, page_index);
|
|
1593
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1594
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1595
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1596
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1597
|
+
if (r3) {
|
|
1598
|
+
throw takeObject(r2);
|
|
1599
|
+
}
|
|
1600
|
+
var v1 = getArrayF32FromWasm0(r0, r1).slice();
|
|
1601
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
1602
|
+
return v1;
|
|
1603
|
+
} finally {
|
|
1604
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Get the rotation of a page in degrees (0, 90, 180, 270).
|
|
1609
|
+
* @param {number} page_index
|
|
1610
|
+
* @returns {number}
|
|
1611
|
+
*/
|
|
1612
|
+
pageRotation(page_index) {
|
|
1613
|
+
try {
|
|
1614
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1615
|
+
wasm.wasmpdfdocument_pageRotation(retptr, this.__wbg_ptr, page_index);
|
|
1616
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1617
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1618
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1619
|
+
if (r2) {
|
|
1620
|
+
throw takeObject(r1);
|
|
1621
|
+
}
|
|
1622
|
+
return r0;
|
|
1623
|
+
} finally {
|
|
1624
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Identify and remove both headers and footers.
|
|
1629
|
+
*
|
|
1630
|
+
* Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
|
|
1631
|
+
* fallback for untagged PDFs.
|
|
1632
|
+
*
|
|
1633
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1634
|
+
* @param {number} threshold
|
|
1635
|
+
* @returns {number}
|
|
1636
|
+
*/
|
|
1637
|
+
removeArtifacts(threshold) {
|
|
1638
|
+
try {
|
|
1639
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1640
|
+
wasm.wasmpdfdocument_removeArtifacts(retptr, this.__wbg_ptr, threshold);
|
|
1641
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1642
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1643
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1644
|
+
if (r2) {
|
|
1645
|
+
throw takeObject(r1);
|
|
1646
|
+
}
|
|
1647
|
+
return r0 >>> 0;
|
|
1648
|
+
} finally {
|
|
1649
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Identify and remove footers.
|
|
1654
|
+
*
|
|
1655
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1656
|
+
* falls back to heuristic analysis of the bottom 15% of pages.
|
|
1657
|
+
*
|
|
1658
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1659
|
+
* @param {number} threshold
|
|
1660
|
+
* @returns {number}
|
|
921
1661
|
*/
|
|
922
|
-
|
|
1662
|
+
removeFooters(threshold) {
|
|
923
1663
|
try {
|
|
924
1664
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
925
|
-
wasm.
|
|
1665
|
+
wasm.wasmpdfdocument_removeFooters(retptr, this.__wbg_ptr, threshold);
|
|
926
1666
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
927
1667
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
928
1668
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
throw takeObject(r2);
|
|
1669
|
+
if (r2) {
|
|
1670
|
+
throw takeObject(r1);
|
|
932
1671
|
}
|
|
933
|
-
|
|
934
|
-
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
935
|
-
return v1;
|
|
1672
|
+
return r0 >>> 0;
|
|
936
1673
|
} finally {
|
|
937
1674
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
938
1675
|
}
|
|
939
1676
|
}
|
|
940
1677
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
1678
|
+
* Identify and remove headers.
|
|
1679
|
+
*
|
|
1680
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1681
|
+
* falls back to heuristic analysis of the top 15% of pages.
|
|
1682
|
+
*
|
|
1683
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1684
|
+
* @param {number} threshold
|
|
943
1685
|
* @returns {number}
|
|
944
1686
|
*/
|
|
945
|
-
|
|
1687
|
+
removeHeaders(threshold) {
|
|
946
1688
|
try {
|
|
947
1689
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
948
|
-
wasm.
|
|
1690
|
+
wasm.wasmpdfdocument_removeHeaders(retptr, this.__wbg_ptr, threshold);
|
|
949
1691
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
950
1692
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
951
1693
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
952
1694
|
if (r2) {
|
|
953
1695
|
throw takeObject(r1);
|
|
954
1696
|
}
|
|
955
|
-
return r0;
|
|
1697
|
+
return r0 >>> 0;
|
|
956
1698
|
} finally {
|
|
957
1699
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
958
1700
|
}
|
|
@@ -1038,13 +1780,6 @@ class WasmPdfDocument {
|
|
|
1038
1780
|
}
|
|
1039
1781
|
/**
|
|
1040
1782
|
* Save with encryption and return the resulting PDF as bytes.
|
|
1041
|
-
*
|
|
1042
|
-
* @param user_password - Password required to open the document
|
|
1043
|
-
* @param owner_password - Password for full access (defaults to user_password)
|
|
1044
|
-
* @param allow_print - Allow printing (default: true)
|
|
1045
|
-
* @param allow_copy - Allow copying text (default: true)
|
|
1046
|
-
* @param allow_modify - Allow modifying (default: true)
|
|
1047
|
-
* @param allow_annotate - Allow annotations (default: true)
|
|
1048
1783
|
* @param {string} user_password
|
|
1049
1784
|
* @param {string | null} [owner_password]
|
|
1050
1785
|
* @param {boolean | null} [allow_print]
|
|
@@ -1544,6 +2279,11 @@ class WasmPdfDocument {
|
|
|
1544
2279
|
wasm.wasmpdfdocument_version(retptr, this.__wbg_ptr);
|
|
1545
2280
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1546
2281
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2282
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2283
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2284
|
+
if (r3) {
|
|
2285
|
+
throw takeObject(r2);
|
|
2286
|
+
}
|
|
1547
2287
|
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1548
2288
|
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1549
2289
|
return v1;
|
|
@@ -1551,6 +2291,32 @@ class WasmPdfDocument {
|
|
|
1551
2291
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1552
2292
|
}
|
|
1553
2293
|
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Focus extraction on a specific rectangular region of a page (v0.3.14).
|
|
2296
|
+
*
|
|
2297
|
+
* @param page_index - Zero-based page number
|
|
2298
|
+
* @param region - [x, y, width, height] in points
|
|
2299
|
+
* @param {number} page_index
|
|
2300
|
+
* @param {Float32Array} region
|
|
2301
|
+
* @returns {WasmPdfPageRegion}
|
|
2302
|
+
*/
|
|
2303
|
+
within(page_index, region) {
|
|
2304
|
+
try {
|
|
2305
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2306
|
+
const ptr0 = passArrayF32ToWasm0(region, wasm.__wbindgen_export);
|
|
2307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2308
|
+
wasm.wasmpdfdocument_within(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
2309
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2310
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2311
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2312
|
+
if (r2) {
|
|
2313
|
+
throw takeObject(r1);
|
|
2314
|
+
}
|
|
2315
|
+
return WasmPdfPageRegion.__wrap(r0);
|
|
2316
|
+
} finally {
|
|
2317
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
1554
2320
|
/**
|
|
1555
2321
|
* Get XMP metadata from the document.
|
|
1556
2322
|
*
|
|
@@ -1576,6 +2342,245 @@ class WasmPdfDocument {
|
|
|
1576
2342
|
if (Symbol.dispose) WasmPdfDocument.prototype[Symbol.dispose] = WasmPdfDocument.prototype.free;
|
|
1577
2343
|
exports.WasmPdfDocument = WasmPdfDocument;
|
|
1578
2344
|
|
|
2345
|
+
/**
|
|
2346
|
+
* A focused view of a PDF page region for scoped extraction (v0.3.14).
|
|
2347
|
+
*/
|
|
2348
|
+
class WasmPdfPageRegion {
|
|
2349
|
+
static __wrap(ptr) {
|
|
2350
|
+
ptr = ptr >>> 0;
|
|
2351
|
+
const obj = Object.create(WasmPdfPageRegion.prototype);
|
|
2352
|
+
obj.__wbg_ptr = ptr;
|
|
2353
|
+
WasmPdfPageRegionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2354
|
+
return obj;
|
|
2355
|
+
}
|
|
2356
|
+
__destroy_into_raw() {
|
|
2357
|
+
const ptr = this.__wbg_ptr;
|
|
2358
|
+
this.__wbg_ptr = 0;
|
|
2359
|
+
WasmPdfPageRegionFinalization.unregister(this);
|
|
2360
|
+
return ptr;
|
|
2361
|
+
}
|
|
2362
|
+
free() {
|
|
2363
|
+
const ptr = this.__destroy_into_raw();
|
|
2364
|
+
wasm.__wbg_wasmpdfpageregion_free(ptr, 0);
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Extract character-level data from this region.
|
|
2368
|
+
* @returns {any}
|
|
2369
|
+
*/
|
|
2370
|
+
extractChars() {
|
|
2371
|
+
try {
|
|
2372
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2373
|
+
wasm.wasmpdfpageregion_extractChars(retptr, this.__wbg_ptr);
|
|
2374
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2375
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2376
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2377
|
+
if (r2) {
|
|
2378
|
+
throw takeObject(r1);
|
|
2379
|
+
}
|
|
2380
|
+
return takeObject(r0);
|
|
2381
|
+
} finally {
|
|
2382
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Extract images from this region.
|
|
2387
|
+
* @returns {any}
|
|
2388
|
+
*/
|
|
2389
|
+
extractImages() {
|
|
2390
|
+
try {
|
|
2391
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2392
|
+
wasm.wasmpdfpageregion_extractImages(retptr, this.__wbg_ptr);
|
|
2393
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2394
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2395
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2396
|
+
if (r2) {
|
|
2397
|
+
throw takeObject(r1);
|
|
2398
|
+
}
|
|
2399
|
+
return takeObject(r0);
|
|
2400
|
+
} finally {
|
|
2401
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Extract straight lines from this region.
|
|
2406
|
+
* @returns {any}
|
|
2407
|
+
*/
|
|
2408
|
+
extractLines() {
|
|
2409
|
+
try {
|
|
2410
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2411
|
+
wasm.wasmpdfpageregion_extractLines(retptr, this.__wbg_ptr);
|
|
2412
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2413
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2414
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2415
|
+
if (r2) {
|
|
2416
|
+
throw takeObject(r1);
|
|
2417
|
+
}
|
|
2418
|
+
return takeObject(r0);
|
|
2419
|
+
} finally {
|
|
2420
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Extract vector paths from this region.
|
|
2425
|
+
* @returns {any}
|
|
2426
|
+
*/
|
|
2427
|
+
extractPaths() {
|
|
2428
|
+
try {
|
|
2429
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2430
|
+
wasm.wasmpdfpageregion_extractPaths(retptr, this.__wbg_ptr);
|
|
2431
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2432
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2433
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2434
|
+
if (r2) {
|
|
2435
|
+
throw takeObject(r1);
|
|
2436
|
+
}
|
|
2437
|
+
return takeObject(r0);
|
|
2438
|
+
} finally {
|
|
2439
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
/**
|
|
2443
|
+
* Extract rectangles from this region.
|
|
2444
|
+
* @returns {any}
|
|
2445
|
+
*/
|
|
2446
|
+
extractRects() {
|
|
2447
|
+
try {
|
|
2448
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2449
|
+
wasm.wasmpdfpageregion_extractRects(retptr, this.__wbg_ptr);
|
|
2450
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2451
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2452
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2453
|
+
if (r2) {
|
|
2454
|
+
throw takeObject(r1);
|
|
2455
|
+
}
|
|
2456
|
+
return takeObject(r0);
|
|
2457
|
+
} finally {
|
|
2458
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Extract tables from this region.
|
|
2463
|
+
* @returns {any}
|
|
2464
|
+
*/
|
|
2465
|
+
extractTables() {
|
|
2466
|
+
try {
|
|
2467
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2468
|
+
wasm.wasmpdfpageregion_extractTables(retptr, this.__wbg_ptr);
|
|
2469
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2470
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2471
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2472
|
+
if (r2) {
|
|
2473
|
+
throw takeObject(r1);
|
|
2474
|
+
}
|
|
2475
|
+
return takeObject(r0);
|
|
2476
|
+
} finally {
|
|
2477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* Extract text from this region.
|
|
2482
|
+
* @returns {string}
|
|
2483
|
+
*/
|
|
2484
|
+
extractText() {
|
|
2485
|
+
let deferred2_0;
|
|
2486
|
+
let deferred2_1;
|
|
2487
|
+
try {
|
|
2488
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2489
|
+
wasm.wasmpdfpageregion_extractText(retptr, this.__wbg_ptr);
|
|
2490
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2491
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2492
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2493
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2494
|
+
var ptr1 = r0;
|
|
2495
|
+
var len1 = r1;
|
|
2496
|
+
if (r3) {
|
|
2497
|
+
ptr1 = 0; len1 = 0;
|
|
2498
|
+
throw takeObject(r2);
|
|
2499
|
+
}
|
|
2500
|
+
deferred2_0 = ptr1;
|
|
2501
|
+
deferred2_1 = len1;
|
|
2502
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2503
|
+
} finally {
|
|
2504
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2505
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Extract text lines from this region.
|
|
2510
|
+
* @returns {any}
|
|
2511
|
+
*/
|
|
2512
|
+
extractTextLines() {
|
|
2513
|
+
try {
|
|
2514
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2515
|
+
wasm.wasmpdfpageregion_extractTextLines(retptr, this.__wbg_ptr);
|
|
2516
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2517
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2518
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2519
|
+
if (r2) {
|
|
2520
|
+
throw takeObject(r1);
|
|
2521
|
+
}
|
|
2522
|
+
return takeObject(r0);
|
|
2523
|
+
} finally {
|
|
2524
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Extract text using OCR from this region.
|
|
2529
|
+
* @param {WasmOcrEngine | null} [_engine]
|
|
2530
|
+
* @returns {string}
|
|
2531
|
+
*/
|
|
2532
|
+
extractTextOcr(_engine) {
|
|
2533
|
+
let deferred3_0;
|
|
2534
|
+
let deferred3_1;
|
|
2535
|
+
try {
|
|
2536
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2537
|
+
let ptr0 = 0;
|
|
2538
|
+
if (!isLikeNone(_engine)) {
|
|
2539
|
+
_assertClass(_engine, WasmOcrEngine);
|
|
2540
|
+
ptr0 = _engine.__destroy_into_raw();
|
|
2541
|
+
}
|
|
2542
|
+
wasm.wasmpdfpageregion_extractTextOcr(retptr, this.__wbg_ptr, ptr0);
|
|
2543
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2544
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2545
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2546
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2547
|
+
var ptr2 = r0;
|
|
2548
|
+
var len2 = r1;
|
|
2549
|
+
if (r3) {
|
|
2550
|
+
ptr2 = 0; len2 = 0;
|
|
2551
|
+
throw takeObject(r2);
|
|
2552
|
+
}
|
|
2553
|
+
deferred3_0 = ptr2;
|
|
2554
|
+
deferred3_1 = len2;
|
|
2555
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2556
|
+
} finally {
|
|
2557
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2558
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
/**
|
|
2562
|
+
* Extract words from this region.
|
|
2563
|
+
* @returns {any}
|
|
2564
|
+
*/
|
|
2565
|
+
extractWords() {
|
|
2566
|
+
try {
|
|
2567
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2568
|
+
wasm.wasmpdfpageregion_extractWords(retptr, this.__wbg_ptr);
|
|
2569
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2570
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2571
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2572
|
+
if (r2) {
|
|
2573
|
+
throw takeObject(r1);
|
|
2574
|
+
}
|
|
2575
|
+
return takeObject(r0);
|
|
2576
|
+
} finally {
|
|
2577
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
if (Symbol.dispose) WasmPdfPageRegion.prototype[Symbol.dispose] = WasmPdfPageRegion.prototype.free;
|
|
2582
|
+
exports.WasmPdfPageRegion = WasmPdfPageRegion;
|
|
2583
|
+
|
|
1579
2584
|
function __wbg_get_imports() {
|
|
1580
2585
|
const import0 = {
|
|
1581
2586
|
__proto__: null,
|
|
@@ -1637,9 +2642,17 @@ function __wbg_get_imports() {
|
|
|
1637
2642
|
const ret = Array.from(getObject(arg0));
|
|
1638
2643
|
return addHeapObject(ret);
|
|
1639
2644
|
},
|
|
1640
|
-
|
|
2645
|
+
__wbg_getRandomValues_a1cf2e70b003a59d: function() { return handleError(function (arg0, arg1) {
|
|
1641
2646
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1642
2647
|
}, arguments); },
|
|
2648
|
+
__wbg_getTime_1dad7b5386ddd2d9: function(arg0) {
|
|
2649
|
+
const ret = getObject(arg0).getTime();
|
|
2650
|
+
return ret;
|
|
2651
|
+
},
|
|
2652
|
+
__wbg_getTimezoneOffset_639bcf2dde21158b: function(arg0) {
|
|
2653
|
+
const ret = getObject(arg0).getTimezoneOffset();
|
|
2654
|
+
return ret;
|
|
2655
|
+
},
|
|
1643
2656
|
__wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
|
|
1644
2657
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1645
2658
|
return addHeapObject(ret);
|
|
@@ -1656,6 +2669,10 @@ function __wbg_get_imports() {
|
|
|
1656
2669
|
const ret = getObject(arg0).length;
|
|
1657
2670
|
return ret;
|
|
1658
2671
|
},
|
|
2672
|
+
__wbg_new_0_1dcafdf5e786e876: function() {
|
|
2673
|
+
const ret = new Date();
|
|
2674
|
+
return addHeapObject(ret);
|
|
2675
|
+
},
|
|
1659
2676
|
__wbg_new_227d7c05414eb861: function() {
|
|
1660
2677
|
const ret = new Error();
|
|
1661
2678
|
return addHeapObject(ret);
|
|
@@ -1676,6 +2693,10 @@ function __wbg_get_imports() {
|
|
|
1676
2693
|
const ret = new Object();
|
|
1677
2694
|
return addHeapObject(ret);
|
|
1678
2695
|
},
|
|
2696
|
+
__wbg_new_fd94ca5c9639abd2: function(arg0) {
|
|
2697
|
+
const ret = new Date(getObject(arg0));
|
|
2698
|
+
return addHeapObject(ret);
|
|
2699
|
+
},
|
|
1679
2700
|
__wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
|
|
1680
2701
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1681
2702
|
return addHeapObject(ret);
|
|
@@ -1742,12 +2763,36 @@ function __wbg_get_imports() {
|
|
|
1742
2763
|
};
|
|
1743
2764
|
}
|
|
1744
2765
|
|
|
2766
|
+
const WasmArtifactFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2767
|
+
? { register: () => {}, unregister: () => {} }
|
|
2768
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmartifact_free(ptr >>> 0, 1));
|
|
2769
|
+
const ArtifactStyleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2770
|
+
? { register: () => {}, unregister: () => {} }
|
|
2771
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_artifactstyle_free(ptr >>> 0, 1));
|
|
2772
|
+
const WasmFooterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2773
|
+
? { register: () => {}, unregister: () => {} }
|
|
2774
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfooter_free(ptr >>> 0, 1));
|
|
2775
|
+
const WasmHeaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2776
|
+
? { register: () => {}, unregister: () => {} }
|
|
2777
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmheader_free(ptr >>> 0, 1));
|
|
2778
|
+
const WasmOcrConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2779
|
+
? { register: () => {}, unregister: () => {} }
|
|
2780
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmocrconfig_free(ptr >>> 0, 1));
|
|
2781
|
+
const WasmOcrEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2782
|
+
? { register: () => {}, unregister: () => {} }
|
|
2783
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmocrengine_free(ptr >>> 0, 1));
|
|
2784
|
+
const WasmPageTemplateFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2785
|
+
? { register: () => {}, unregister: () => {} }
|
|
2786
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpagetemplate_free(ptr >>> 0, 1));
|
|
1745
2787
|
const WasmPdfFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1746
2788
|
? { register: () => {}, unregister: () => {} }
|
|
1747
2789
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdf_free(ptr >>> 0, 1));
|
|
1748
2790
|
const WasmPdfDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1749
2791
|
? { register: () => {}, unregister: () => {} }
|
|
1750
2792
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfdocument_free(ptr >>> 0, 1));
|
|
2793
|
+
const WasmPdfPageRegionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2794
|
+
? { register: () => {}, unregister: () => {} }
|
|
2795
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfpageregion_free(ptr >>> 0, 1));
|
|
1751
2796
|
|
|
1752
2797
|
function addHeapObject(obj) {
|
|
1753
2798
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
@@ -1758,6 +2803,12 @@ function addHeapObject(obj) {
|
|
|
1758
2803
|
return idx;
|
|
1759
2804
|
}
|
|
1760
2805
|
|
|
2806
|
+
function _assertClass(instance, klass) {
|
|
2807
|
+
if (!(instance instanceof klass)) {
|
|
2808
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
|
|
1761
2812
|
function dropObject(idx) {
|
|
1762
2813
|
if (idx < 1028) return;
|
|
1763
2814
|
heap[idx] = heap_next;
|