pdf-oxide-wasm 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/package.json +27 -0
- package/pdf_oxide.d.ts +404 -0
- package/pdf_oxide.js +1906 -0
- package/pdf_oxide_bg.wasm +0 -0
- package/pdf_oxide_bg.wasm.d.ts +76 -0
package/pdf_oxide.js
ADDED
|
@@ -0,0 +1,1906 @@
|
|
|
1
|
+
/* @ts-self-types="./pdf_oxide.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create new PDF documents from Markdown, HTML, or plain text.
|
|
5
|
+
*
|
|
6
|
+
* ```javascript
|
|
7
|
+
* const pdf = WasmPdf.fromMarkdown("# Hello\n\nWorld");
|
|
8
|
+
* const bytes = pdf.toBytes(); // Uint8Array
|
|
9
|
+
* console.log(`PDF size: ${pdf.size} bytes`);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
class WasmPdf {
|
|
13
|
+
static __wrap(ptr) {
|
|
14
|
+
ptr = ptr >>> 0;
|
|
15
|
+
const obj = Object.create(WasmPdf.prototype);
|
|
16
|
+
obj.__wbg_ptr = ptr;
|
|
17
|
+
WasmPdfFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
__destroy_into_raw() {
|
|
21
|
+
const ptr = this.__wbg_ptr;
|
|
22
|
+
this.__wbg_ptr = 0;
|
|
23
|
+
WasmPdfFinalization.unregister(this);
|
|
24
|
+
return ptr;
|
|
25
|
+
}
|
|
26
|
+
free() {
|
|
27
|
+
const ptr = this.__destroy_into_raw();
|
|
28
|
+
wasm.__wbg_wasmpdf_free(ptr, 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a PDF from HTML content.
|
|
32
|
+
*
|
|
33
|
+
* @param content - HTML string
|
|
34
|
+
* @param title - Optional document title
|
|
35
|
+
* @param author - Optional document author
|
|
36
|
+
* @param {string} content
|
|
37
|
+
* @param {string | null} [title]
|
|
38
|
+
* @param {string | null} [author]
|
|
39
|
+
* @returns {WasmPdf}
|
|
40
|
+
*/
|
|
41
|
+
static fromHtml(content, title, author) {
|
|
42
|
+
try {
|
|
43
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
45
|
+
const len0 = WASM_VECTOR_LEN;
|
|
46
|
+
var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
47
|
+
var len1 = WASM_VECTOR_LEN;
|
|
48
|
+
var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
49
|
+
var len2 = WASM_VECTOR_LEN;
|
|
50
|
+
wasm.wasmpdf_fromHtml(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
51
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
52
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
53
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
54
|
+
if (r2) {
|
|
55
|
+
throw takeObject(r1);
|
|
56
|
+
}
|
|
57
|
+
return WasmPdf.__wrap(r0);
|
|
58
|
+
} finally {
|
|
59
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a PDF from image bytes (PNG, JPEG, etc.).
|
|
64
|
+
*
|
|
65
|
+
* @param data - Image file contents as a Uint8Array
|
|
66
|
+
* @param {Uint8Array} data
|
|
67
|
+
* @returns {WasmPdf}
|
|
68
|
+
*/
|
|
69
|
+
static fromImageBytes(data) {
|
|
70
|
+
try {
|
|
71
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
72
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
73
|
+
const len0 = WASM_VECTOR_LEN;
|
|
74
|
+
wasm.wasmpdf_fromImageBytes(retptr, ptr0, len0);
|
|
75
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
76
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
77
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
78
|
+
if (r2) {
|
|
79
|
+
throw takeObject(r1);
|
|
80
|
+
}
|
|
81
|
+
return WasmPdf.__wrap(r0);
|
|
82
|
+
} finally {
|
|
83
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a PDF from Markdown content.
|
|
88
|
+
*
|
|
89
|
+
* @param content - Markdown string
|
|
90
|
+
* @param title - Optional document title
|
|
91
|
+
* @param author - Optional document author
|
|
92
|
+
* @param {string} content
|
|
93
|
+
* @param {string | null} [title]
|
|
94
|
+
* @param {string | null} [author]
|
|
95
|
+
* @returns {WasmPdf}
|
|
96
|
+
*/
|
|
97
|
+
static fromMarkdown(content, title, author) {
|
|
98
|
+
try {
|
|
99
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
100
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
101
|
+
const len0 = WASM_VECTOR_LEN;
|
|
102
|
+
var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
103
|
+
var len1 = WASM_VECTOR_LEN;
|
|
104
|
+
var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
105
|
+
var len2 = WASM_VECTOR_LEN;
|
|
106
|
+
wasm.wasmpdf_fromMarkdown(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
107
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
108
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
109
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
110
|
+
if (r2) {
|
|
111
|
+
throw takeObject(r1);
|
|
112
|
+
}
|
|
113
|
+
return WasmPdf.__wrap(r0);
|
|
114
|
+
} finally {
|
|
115
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a PDF from multiple image byte arrays.
|
|
120
|
+
*
|
|
121
|
+
* Each image becomes a separate page. Pass an array of Uint8Arrays.
|
|
122
|
+
*
|
|
123
|
+
* @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
|
|
124
|
+
* @param {any} images_array
|
|
125
|
+
* @returns {WasmPdf}
|
|
126
|
+
*/
|
|
127
|
+
static fromMultipleImageBytes(images_array) {
|
|
128
|
+
try {
|
|
129
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
130
|
+
wasm.wasmpdf_fromMultipleImageBytes(retptr, addHeapObject(images_array));
|
|
131
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
132
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
133
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
134
|
+
if (r2) {
|
|
135
|
+
throw takeObject(r1);
|
|
136
|
+
}
|
|
137
|
+
return WasmPdf.__wrap(r0);
|
|
138
|
+
} finally {
|
|
139
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a PDF from plain text.
|
|
144
|
+
*
|
|
145
|
+
* @param content - Plain text string
|
|
146
|
+
* @param title - Optional document title
|
|
147
|
+
* @param author - Optional document author
|
|
148
|
+
* @param {string} content
|
|
149
|
+
* @param {string | null} [title]
|
|
150
|
+
* @param {string | null} [author]
|
|
151
|
+
* @returns {WasmPdf}
|
|
152
|
+
*/
|
|
153
|
+
static fromText(content, title, author) {
|
|
154
|
+
try {
|
|
155
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
156
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
var ptr1 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
159
|
+
var len1 = WASM_VECTOR_LEN;
|
|
160
|
+
var ptr2 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
161
|
+
var len2 = WASM_VECTOR_LEN;
|
|
162
|
+
wasm.wasmpdf_fromText(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
163
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
164
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
165
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
166
|
+
if (r2) {
|
|
167
|
+
throw takeObject(r1);
|
|
168
|
+
}
|
|
169
|
+
return WasmPdf.__wrap(r0);
|
|
170
|
+
} finally {
|
|
171
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the size of the PDF in bytes.
|
|
176
|
+
* @returns {number}
|
|
177
|
+
*/
|
|
178
|
+
get size() {
|
|
179
|
+
const ret = wasm.wasmpdf_size(this.__wbg_ptr);
|
|
180
|
+
return ret >>> 0;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the PDF as a Uint8Array.
|
|
184
|
+
* @returns {Uint8Array}
|
|
185
|
+
*/
|
|
186
|
+
toBytes() {
|
|
187
|
+
try {
|
|
188
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
189
|
+
wasm.wasmpdf_toBytes(retptr, this.__wbg_ptr);
|
|
190
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
191
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
192
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
193
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
194
|
+
return v1;
|
|
195
|
+
} finally {
|
|
196
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (Symbol.dispose) WasmPdf.prototype[Symbol.dispose] = WasmPdf.prototype.free;
|
|
201
|
+
exports.WasmPdf = WasmPdf;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A PDF document loaded from bytes for use in WebAssembly.
|
|
205
|
+
*
|
|
206
|
+
* Create an instance by passing PDF file bytes to the constructor.
|
|
207
|
+
* Call `.free()` when done to release memory.
|
|
208
|
+
*/
|
|
209
|
+
class WasmPdfDocument {
|
|
210
|
+
__destroy_into_raw() {
|
|
211
|
+
const ptr = this.__wbg_ptr;
|
|
212
|
+
this.__wbg_ptr = 0;
|
|
213
|
+
WasmPdfDocumentFinalization.unregister(this);
|
|
214
|
+
return ptr;
|
|
215
|
+
}
|
|
216
|
+
free() {
|
|
217
|
+
const ptr = this.__destroy_into_raw();
|
|
218
|
+
wasm.__wbg_wasmpdfdocument_free(ptr, 0);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Apply all redactions in the document.
|
|
222
|
+
*/
|
|
223
|
+
applyAllRedactions() {
|
|
224
|
+
try {
|
|
225
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
226
|
+
wasm.wasmpdfdocument_applyAllRedactions(retptr, this.__wbg_ptr);
|
|
227
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
228
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
229
|
+
if (r1) {
|
|
230
|
+
throw takeObject(r0);
|
|
231
|
+
}
|
|
232
|
+
} finally {
|
|
233
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Apply redactions on a page (removes redacted content permanently).
|
|
238
|
+
* @param {number} page_index
|
|
239
|
+
*/
|
|
240
|
+
applyPageRedactions(page_index) {
|
|
241
|
+
try {
|
|
242
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
243
|
+
wasm.wasmpdfdocument_applyPageRedactions(retptr, this.__wbg_ptr, page_index);
|
|
244
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
245
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
246
|
+
if (r1) {
|
|
247
|
+
throw takeObject(r0);
|
|
248
|
+
}
|
|
249
|
+
} finally {
|
|
250
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Authenticate with a password to decrypt an encrypted PDF.
|
|
255
|
+
*
|
|
256
|
+
* @param password - The password string
|
|
257
|
+
* @returns true if authentication succeeded
|
|
258
|
+
* @param {string} password
|
|
259
|
+
* @returns {boolean}
|
|
260
|
+
*/
|
|
261
|
+
authenticate(password) {
|
|
262
|
+
try {
|
|
263
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
264
|
+
const ptr0 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
265
|
+
const len0 = WASM_VECTOR_LEN;
|
|
266
|
+
wasm.wasmpdfdocument_authenticate(retptr, this.__wbg_ptr, ptr0, len0);
|
|
267
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
268
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
269
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
270
|
+
if (r2) {
|
|
271
|
+
throw takeObject(r1);
|
|
272
|
+
}
|
|
273
|
+
return r0 !== 0;
|
|
274
|
+
} finally {
|
|
275
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Clear all pending erase operations for a page.
|
|
280
|
+
* @param {number} page_index
|
|
281
|
+
*/
|
|
282
|
+
clearEraseRegions(page_index) {
|
|
283
|
+
try {
|
|
284
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
285
|
+
wasm.wasmpdfdocument_clearEraseRegions(retptr, this.__wbg_ptr, page_index);
|
|
286
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
287
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
288
|
+
if (r1) {
|
|
289
|
+
throw takeObject(r0);
|
|
290
|
+
}
|
|
291
|
+
} finally {
|
|
292
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Crop margins from all pages.
|
|
297
|
+
* @param {number} left
|
|
298
|
+
* @param {number} right
|
|
299
|
+
* @param {number} top
|
|
300
|
+
* @param {number} bottom
|
|
301
|
+
*/
|
|
302
|
+
cropMargins(left, right, top, bottom) {
|
|
303
|
+
try {
|
|
304
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
305
|
+
wasm.wasmpdfdocument_cropMargins(retptr, this.__wbg_ptr, left, right, top, bottom);
|
|
306
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
307
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
308
|
+
if (r1) {
|
|
309
|
+
throw takeObject(r0);
|
|
310
|
+
}
|
|
311
|
+
} finally {
|
|
312
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Embed a file into the PDF document.
|
|
317
|
+
*
|
|
318
|
+
* @param name - Display name for the embedded file
|
|
319
|
+
* @param data - File contents as a Uint8Array
|
|
320
|
+
* @param {string} name
|
|
321
|
+
* @param {Uint8Array} data
|
|
322
|
+
*/
|
|
323
|
+
embedFile(name, data) {
|
|
324
|
+
try {
|
|
325
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
326
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
327
|
+
const len0 = WASM_VECTOR_LEN;
|
|
328
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
329
|
+
const len1 = WASM_VECTOR_LEN;
|
|
330
|
+
wasm.wasmpdfdocument_embedFile(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
331
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
332
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
333
|
+
if (r1) {
|
|
334
|
+
throw takeObject(r0);
|
|
335
|
+
}
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Erase (whiteout) a rectangular region on a page.
|
|
342
|
+
* @param {number} page_index
|
|
343
|
+
* @param {number} llx
|
|
344
|
+
* @param {number} lly
|
|
345
|
+
* @param {number} urx
|
|
346
|
+
* @param {number} ury
|
|
347
|
+
*/
|
|
348
|
+
eraseRegion(page_index, llx, lly, urx, ury) {
|
|
349
|
+
try {
|
|
350
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
351
|
+
wasm.wasmpdfdocument_eraseRegion(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
|
|
352
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
353
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
354
|
+
if (r1) {
|
|
355
|
+
throw takeObject(r0);
|
|
356
|
+
}
|
|
357
|
+
} finally {
|
|
358
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Erase multiple rectangular regions on a page.
|
|
363
|
+
*
|
|
364
|
+
* @param page_index - Zero-based page number
|
|
365
|
+
* @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
|
|
366
|
+
* @param {number} page_index
|
|
367
|
+
* @param {Float32Array} rects
|
|
368
|
+
*/
|
|
369
|
+
eraseRegions(page_index, rects) {
|
|
370
|
+
try {
|
|
371
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
372
|
+
const ptr0 = passArrayF32ToWasm0(rects, wasm.__wbindgen_export);
|
|
373
|
+
const len0 = WASM_VECTOR_LEN;
|
|
374
|
+
wasm.wasmpdfdocument_eraseRegions(retptr, this.__wbg_ptr, page_index, ptr0, len0);
|
|
375
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
376
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
377
|
+
if (r1) {
|
|
378
|
+
throw takeObject(r0);
|
|
379
|
+
}
|
|
380
|
+
} finally {
|
|
381
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Export form field data as FDF or XFDF bytes.
|
|
386
|
+
*
|
|
387
|
+
* @param format - "fdf" or "xfdf" (default: "fdf")
|
|
388
|
+
* @returns Uint8Array containing the exported form data
|
|
389
|
+
* @param {string | null} [format]
|
|
390
|
+
* @returns {Uint8Array}
|
|
391
|
+
*/
|
|
392
|
+
exportFormData(format) {
|
|
393
|
+
try {
|
|
394
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
395
|
+
var ptr0 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
396
|
+
var len0 = WASM_VECTOR_LEN;
|
|
397
|
+
wasm.wasmpdfdocument_exportFormData(retptr, this.__wbg_ptr, ptr0, len0);
|
|
398
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
399
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
400
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
401
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
402
|
+
if (r3) {
|
|
403
|
+
throw takeObject(r2);
|
|
404
|
+
}
|
|
405
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
406
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
407
|
+
return v2;
|
|
408
|
+
} finally {
|
|
409
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Extract plain text from all pages, separated by form feed characters.
|
|
414
|
+
* @returns {string}
|
|
415
|
+
*/
|
|
416
|
+
extractAllText() {
|
|
417
|
+
let deferred2_0;
|
|
418
|
+
let deferred2_1;
|
|
419
|
+
try {
|
|
420
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
421
|
+
wasm.wasmpdfdocument_extractAllText(retptr, this.__wbg_ptr);
|
|
422
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
423
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
424
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
425
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
426
|
+
var ptr1 = r0;
|
|
427
|
+
var len1 = r1;
|
|
428
|
+
if (r3) {
|
|
429
|
+
ptr1 = 0; len1 = 0;
|
|
430
|
+
throw takeObject(r2);
|
|
431
|
+
}
|
|
432
|
+
deferred2_0 = ptr1;
|
|
433
|
+
deferred2_1 = len1;
|
|
434
|
+
return getStringFromWasm0(ptr1, len1);
|
|
435
|
+
} finally {
|
|
436
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
437
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Extract character-level data from a page.
|
|
442
|
+
*
|
|
443
|
+
* Returns an array of objects with: char, bbox {x, y, width, height},
|
|
444
|
+
* font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
|
|
445
|
+
* @param {number} page_index
|
|
446
|
+
* @returns {any}
|
|
447
|
+
*/
|
|
448
|
+
extractChars(page_index) {
|
|
449
|
+
try {
|
|
450
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
451
|
+
wasm.wasmpdfdocument_extractChars(retptr, this.__wbg_ptr, page_index);
|
|
452
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
453
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
454
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
455
|
+
if (r2) {
|
|
456
|
+
throw takeObject(r1);
|
|
457
|
+
}
|
|
458
|
+
return takeObject(r0);
|
|
459
|
+
} finally {
|
|
460
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Extract image bytes from a page as PNG data.
|
|
465
|
+
*
|
|
466
|
+
* Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
|
|
467
|
+
* @param {number} page_index
|
|
468
|
+
* @returns {any}
|
|
469
|
+
*/
|
|
470
|
+
extractImageBytes(page_index) {
|
|
471
|
+
try {
|
|
472
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
473
|
+
wasm.wasmpdfdocument_extractImageBytes(retptr, this.__wbg_ptr, page_index);
|
|
474
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
475
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
476
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
477
|
+
if (r2) {
|
|
478
|
+
throw takeObject(r1);
|
|
479
|
+
}
|
|
480
|
+
return takeObject(r0);
|
|
481
|
+
} finally {
|
|
482
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Extract image metadata from a page.
|
|
487
|
+
*
|
|
488
|
+
* Returns an array of objects with: width, height, color_space,
|
|
489
|
+
* bits_per_component, bbox (if available). Does NOT return raw image bytes.
|
|
490
|
+
* @param {number} page_index
|
|
491
|
+
* @returns {any}
|
|
492
|
+
*/
|
|
493
|
+
extractImages(page_index) {
|
|
494
|
+
try {
|
|
495
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
496
|
+
wasm.wasmpdfdocument_extractImages(retptr, this.__wbg_ptr, page_index);
|
|
497
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
498
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
499
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
500
|
+
if (r2) {
|
|
501
|
+
throw takeObject(r1);
|
|
502
|
+
}
|
|
503
|
+
return takeObject(r0);
|
|
504
|
+
} finally {
|
|
505
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Extract vector paths (lines, curves, shapes) from a page.
|
|
510
|
+
*
|
|
511
|
+
* @param page_index - Zero-based page number
|
|
512
|
+
* @returns Array of path objects with bbox, stroke_color, fill_color, etc.
|
|
513
|
+
* @param {number} page_index
|
|
514
|
+
* @returns {any}
|
|
515
|
+
*/
|
|
516
|
+
extractPaths(page_index) {
|
|
517
|
+
try {
|
|
518
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
519
|
+
wasm.wasmpdfdocument_extractPaths(retptr, this.__wbg_ptr, page_index);
|
|
520
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
521
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
522
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
523
|
+
if (r2) {
|
|
524
|
+
throw takeObject(r1);
|
|
525
|
+
}
|
|
526
|
+
return takeObject(r0);
|
|
527
|
+
} finally {
|
|
528
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Extract span-level data from a page.
|
|
533
|
+
*
|
|
534
|
+
* Returns an array of objects with: text, bbox, font_name, font_size,
|
|
535
|
+
* font_weight, is_italic, color, etc.
|
|
536
|
+
* @param {number} page_index
|
|
537
|
+
* @returns {any}
|
|
538
|
+
*/
|
|
539
|
+
extractSpans(page_index) {
|
|
540
|
+
try {
|
|
541
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
542
|
+
wasm.wasmpdfdocument_extractSpans(retptr, this.__wbg_ptr, page_index);
|
|
543
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
544
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
545
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
546
|
+
if (r2) {
|
|
547
|
+
throw takeObject(r1);
|
|
548
|
+
}
|
|
549
|
+
return takeObject(r0);
|
|
550
|
+
} finally {
|
|
551
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Extract plain text from a single page.
|
|
556
|
+
*
|
|
557
|
+
* @param page_index - Zero-based page number
|
|
558
|
+
* @param {number} page_index
|
|
559
|
+
* @returns {string}
|
|
560
|
+
*/
|
|
561
|
+
extractText(page_index) {
|
|
562
|
+
let deferred2_0;
|
|
563
|
+
let deferred2_1;
|
|
564
|
+
try {
|
|
565
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
566
|
+
wasm.wasmpdfdocument_extractText(retptr, this.__wbg_ptr, page_index);
|
|
567
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
568
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
569
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
570
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
571
|
+
var ptr1 = r0;
|
|
572
|
+
var len1 = r1;
|
|
573
|
+
if (r3) {
|
|
574
|
+
ptr1 = 0; len1 = 0;
|
|
575
|
+
throw takeObject(r2);
|
|
576
|
+
}
|
|
577
|
+
deferred2_0 = ptr1;
|
|
578
|
+
deferred2_1 = len1;
|
|
579
|
+
return getStringFromWasm0(ptr1, len1);
|
|
580
|
+
} finally {
|
|
581
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
582
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Flatten all annotations in the document into page content.
|
|
587
|
+
*/
|
|
588
|
+
flattenAllAnnotations() {
|
|
589
|
+
try {
|
|
590
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
591
|
+
wasm.wasmpdfdocument_flattenAllAnnotations(retptr, this.__wbg_ptr);
|
|
592
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
593
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
594
|
+
if (r1) {
|
|
595
|
+
throw takeObject(r0);
|
|
596
|
+
}
|
|
597
|
+
} finally {
|
|
598
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Flatten all form fields into page content.
|
|
603
|
+
*
|
|
604
|
+
* After flattening, form field values become static text and are no longer editable.
|
|
605
|
+
*/
|
|
606
|
+
flattenForms() {
|
|
607
|
+
try {
|
|
608
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
609
|
+
wasm.wasmpdfdocument_flattenForms(retptr, this.__wbg_ptr);
|
|
610
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
611
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
612
|
+
if (r1) {
|
|
613
|
+
throw takeObject(r0);
|
|
614
|
+
}
|
|
615
|
+
} finally {
|
|
616
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Flatten form fields on a specific page.
|
|
621
|
+
*
|
|
622
|
+
* @param page_index - Zero-based page number
|
|
623
|
+
* @param {number} page_index
|
|
624
|
+
*/
|
|
625
|
+
flattenFormsOnPage(page_index) {
|
|
626
|
+
try {
|
|
627
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
628
|
+
wasm.wasmpdfdocument_flattenFormsOnPage(retptr, this.__wbg_ptr, page_index);
|
|
629
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
630
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
631
|
+
if (r1) {
|
|
632
|
+
throw takeObject(r0);
|
|
633
|
+
}
|
|
634
|
+
} finally {
|
|
635
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Flatten annotations on a page into the page content.
|
|
640
|
+
* @param {number} page_index
|
|
641
|
+
*/
|
|
642
|
+
flattenPageAnnotations(page_index) {
|
|
643
|
+
try {
|
|
644
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
645
|
+
wasm.wasmpdfdocument_flattenPageAnnotations(retptr, this.__wbg_ptr, page_index);
|
|
646
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
647
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
648
|
+
if (r1) {
|
|
649
|
+
throw takeObject(r0);
|
|
650
|
+
}
|
|
651
|
+
} finally {
|
|
652
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Get annotations from a page.
|
|
657
|
+
*
|
|
658
|
+
* @param page_index - Zero-based page number
|
|
659
|
+
* @returns Array of annotation objects with fields like subtype, rect, contents, etc.
|
|
660
|
+
* @param {number} page_index
|
|
661
|
+
* @returns {any}
|
|
662
|
+
*/
|
|
663
|
+
getAnnotations(page_index) {
|
|
664
|
+
try {
|
|
665
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
666
|
+
wasm.wasmpdfdocument_getAnnotations(retptr, this.__wbg_ptr, page_index);
|
|
667
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
668
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
669
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
670
|
+
if (r2) {
|
|
671
|
+
throw takeObject(r1);
|
|
672
|
+
}
|
|
673
|
+
return takeObject(r0);
|
|
674
|
+
} finally {
|
|
675
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Get the value of a specific form field by name.
|
|
680
|
+
*
|
|
681
|
+
* @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
|
|
682
|
+
* @returns The field value: string for text, boolean for checkbox, null if not found
|
|
683
|
+
* @param {string} name
|
|
684
|
+
* @returns {any}
|
|
685
|
+
*/
|
|
686
|
+
getFormFieldValue(name) {
|
|
687
|
+
try {
|
|
688
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
689
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
690
|
+
const len0 = WASM_VECTOR_LEN;
|
|
691
|
+
wasm.wasmpdfdocument_getFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0);
|
|
692
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
693
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
694
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
695
|
+
if (r2) {
|
|
696
|
+
throw takeObject(r1);
|
|
697
|
+
}
|
|
698
|
+
return takeObject(r0);
|
|
699
|
+
} finally {
|
|
700
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Get all form fields from the document.
|
|
705
|
+
*
|
|
706
|
+
* Returns an array of form field objects, each with:
|
|
707
|
+
* - name: Full qualified field name
|
|
708
|
+
* - field_type: "text", "button", "choice", "signature", or "unknown"
|
|
709
|
+
* - value: string, boolean, array of strings, or null
|
|
710
|
+
* - tooltip: string or null
|
|
711
|
+
* - bounds: [x1, y1, x2, y2] or null
|
|
712
|
+
* - flags: number or null
|
|
713
|
+
* - max_length: number or null
|
|
714
|
+
* - is_readonly: boolean
|
|
715
|
+
* - is_required: boolean
|
|
716
|
+
* @returns {any}
|
|
717
|
+
*/
|
|
718
|
+
getFormFields() {
|
|
719
|
+
try {
|
|
720
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
721
|
+
wasm.wasmpdfdocument_getFormFields(retptr, this.__wbg_ptr);
|
|
722
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
723
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
724
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
725
|
+
if (r2) {
|
|
726
|
+
throw takeObject(r1);
|
|
727
|
+
}
|
|
728
|
+
return takeObject(r0);
|
|
729
|
+
} finally {
|
|
730
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Get the document outline (bookmarks / table of contents).
|
|
735
|
+
*
|
|
736
|
+
* @returns Array of outline items or null if no outline exists.
|
|
737
|
+
* Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
|
|
738
|
+
* @returns {any}
|
|
739
|
+
*/
|
|
740
|
+
getOutline() {
|
|
741
|
+
try {
|
|
742
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
743
|
+
wasm.wasmpdfdocument_getOutline(retptr, this.__wbg_ptr);
|
|
744
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
745
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
746
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
747
|
+
if (r2) {
|
|
748
|
+
throw takeObject(r1);
|
|
749
|
+
}
|
|
750
|
+
return takeObject(r0);
|
|
751
|
+
} finally {
|
|
752
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Check if the document has a structure tree (Tagged PDF).
|
|
757
|
+
* @returns {boolean}
|
|
758
|
+
*/
|
|
759
|
+
hasStructureTree() {
|
|
760
|
+
const ret = wasm.wasmpdfdocument_hasStructureTree(this.__wbg_ptr);
|
|
761
|
+
return ret !== 0;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Check if the document contains XFA form data.
|
|
765
|
+
*
|
|
766
|
+
* @returns true if the document has XFA form data
|
|
767
|
+
* @returns {boolean}
|
|
768
|
+
*/
|
|
769
|
+
hasXfa() {
|
|
770
|
+
try {
|
|
771
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
772
|
+
wasm.wasmpdfdocument_hasXfa(retptr, this.__wbg_ptr);
|
|
773
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
774
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
775
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
776
|
+
if (r2) {
|
|
777
|
+
throw takeObject(r1);
|
|
778
|
+
}
|
|
779
|
+
return r0 !== 0;
|
|
780
|
+
} finally {
|
|
781
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Merge another PDF (provided as bytes) into this document.
|
|
786
|
+
*
|
|
787
|
+
* @param data - The PDF file contents to merge as a Uint8Array
|
|
788
|
+
* @returns Number of pages merged
|
|
789
|
+
* @param {Uint8Array} data
|
|
790
|
+
* @returns {number}
|
|
791
|
+
*/
|
|
792
|
+
mergeFrom(data) {
|
|
793
|
+
try {
|
|
794
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
795
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
796
|
+
const len0 = WASM_VECTOR_LEN;
|
|
797
|
+
wasm.wasmpdfdocument_mergeFrom(retptr, this.__wbg_ptr, ptr0, len0);
|
|
798
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
799
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
800
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
801
|
+
if (r2) {
|
|
802
|
+
throw takeObject(r1);
|
|
803
|
+
}
|
|
804
|
+
return r0 >>> 0;
|
|
805
|
+
} finally {
|
|
806
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Load a PDF document from raw bytes.
|
|
811
|
+
*
|
|
812
|
+
* @param data - The PDF file contents as a Uint8Array
|
|
813
|
+
* @throws Error if the PDF is invalid or cannot be parsed
|
|
814
|
+
* @param {Uint8Array} data
|
|
815
|
+
*/
|
|
816
|
+
constructor(data) {
|
|
817
|
+
try {
|
|
818
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
819
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
820
|
+
const len0 = WASM_VECTOR_LEN;
|
|
821
|
+
wasm.wasmpdfdocument_new(retptr, ptr0, len0);
|
|
822
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
823
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
824
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
825
|
+
if (r2) {
|
|
826
|
+
throw takeObject(r1);
|
|
827
|
+
}
|
|
828
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
829
|
+
WasmPdfDocumentFinalization.register(this, this.__wbg_ptr, this);
|
|
830
|
+
return this;
|
|
831
|
+
} finally {
|
|
832
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Get the number of pages in the document.
|
|
837
|
+
* @returns {number}
|
|
838
|
+
*/
|
|
839
|
+
pageCount() {
|
|
840
|
+
try {
|
|
841
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
842
|
+
wasm.wasmpdfdocument_pageCount(retptr, this.__wbg_ptr);
|
|
843
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
844
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
845
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
846
|
+
if (r2) {
|
|
847
|
+
throw takeObject(r1);
|
|
848
|
+
}
|
|
849
|
+
return r0 >>> 0;
|
|
850
|
+
} finally {
|
|
851
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
|
|
856
|
+
* @param {number} page_index
|
|
857
|
+
* @returns {any}
|
|
858
|
+
*/
|
|
859
|
+
pageCropBox(page_index) {
|
|
860
|
+
try {
|
|
861
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
862
|
+
wasm.wasmpdfdocument_pageCropBox(retptr, this.__wbg_ptr, page_index);
|
|
863
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
864
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
865
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
866
|
+
if (r2) {
|
|
867
|
+
throw takeObject(r1);
|
|
868
|
+
}
|
|
869
|
+
return takeObject(r0);
|
|
870
|
+
} finally {
|
|
871
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Get information about images on a page.
|
|
876
|
+
*
|
|
877
|
+
* Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
|
|
878
|
+
* @param {number} page_index
|
|
879
|
+
* @returns {any}
|
|
880
|
+
*/
|
|
881
|
+
pageImages(page_index) {
|
|
882
|
+
try {
|
|
883
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
884
|
+
wasm.wasmpdfdocument_pageImages(retptr, this.__wbg_ptr, page_index);
|
|
885
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
886
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
887
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
888
|
+
if (r2) {
|
|
889
|
+
throw takeObject(r1);
|
|
890
|
+
}
|
|
891
|
+
return takeObject(r0);
|
|
892
|
+
} finally {
|
|
893
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Get page label ranges from the document.
|
|
898
|
+
*
|
|
899
|
+
* @returns Array of {start_page, style, prefix, start_value} objects, or empty array
|
|
900
|
+
* @returns {any}
|
|
901
|
+
*/
|
|
902
|
+
pageLabels() {
|
|
903
|
+
try {
|
|
904
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
905
|
+
wasm.wasmpdfdocument_pageLabels(retptr, this.__wbg_ptr);
|
|
906
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
907
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
908
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
909
|
+
if (r2) {
|
|
910
|
+
throw takeObject(r1);
|
|
911
|
+
}
|
|
912
|
+
return takeObject(r0);
|
|
913
|
+
} finally {
|
|
914
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Get the MediaBox of a page as [llx, lly, urx, ury].
|
|
919
|
+
* @param {number} page_index
|
|
920
|
+
* @returns {Float32Array}
|
|
921
|
+
*/
|
|
922
|
+
pageMediaBox(page_index) {
|
|
923
|
+
try {
|
|
924
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
925
|
+
wasm.wasmpdfdocument_pageMediaBox(retptr, this.__wbg_ptr, page_index);
|
|
926
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
927
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
928
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
929
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
930
|
+
if (r3) {
|
|
931
|
+
throw takeObject(r2);
|
|
932
|
+
}
|
|
933
|
+
var v1 = getArrayF32FromWasm0(r0, r1).slice();
|
|
934
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
935
|
+
return v1;
|
|
936
|
+
} finally {
|
|
937
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Get the rotation of a page in degrees (0, 90, 180, 270).
|
|
942
|
+
* @param {number} page_index
|
|
943
|
+
* @returns {number}
|
|
944
|
+
*/
|
|
945
|
+
pageRotation(page_index) {
|
|
946
|
+
try {
|
|
947
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
948
|
+
wasm.wasmpdfdocument_pageRotation(retptr, this.__wbg_ptr, page_index);
|
|
949
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
950
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
951
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
952
|
+
if (r2) {
|
|
953
|
+
throw takeObject(r1);
|
|
954
|
+
}
|
|
955
|
+
return r0;
|
|
956
|
+
} finally {
|
|
957
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Reposition an image on a page.
|
|
962
|
+
* @param {number} page_index
|
|
963
|
+
* @param {string} name
|
|
964
|
+
* @param {number} x
|
|
965
|
+
* @param {number} y
|
|
966
|
+
*/
|
|
967
|
+
repositionImage(page_index, name, x, y) {
|
|
968
|
+
try {
|
|
969
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
970
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
971
|
+
const len0 = WASM_VECTOR_LEN;
|
|
972
|
+
wasm.wasmpdfdocument_repositionImage(retptr, this.__wbg_ptr, page_index, ptr0, len0, x, y);
|
|
973
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
974
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
975
|
+
if (r1) {
|
|
976
|
+
throw takeObject(r0);
|
|
977
|
+
}
|
|
978
|
+
} finally {
|
|
979
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Resize an image on a page.
|
|
984
|
+
* @param {number} page_index
|
|
985
|
+
* @param {string} name
|
|
986
|
+
* @param {number} width
|
|
987
|
+
* @param {number} height
|
|
988
|
+
*/
|
|
989
|
+
resizeImage(page_index, name, width, height) {
|
|
990
|
+
try {
|
|
991
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
992
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
993
|
+
const len0 = WASM_VECTOR_LEN;
|
|
994
|
+
wasm.wasmpdfdocument_resizeImage(retptr, this.__wbg_ptr, page_index, ptr0, len0, width, height);
|
|
995
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
996
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
997
|
+
if (r1) {
|
|
998
|
+
throw takeObject(r0);
|
|
999
|
+
}
|
|
1000
|
+
} finally {
|
|
1001
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Rotate all pages by the given degrees.
|
|
1006
|
+
* @param {number} degrees
|
|
1007
|
+
*/
|
|
1008
|
+
rotateAllPages(degrees) {
|
|
1009
|
+
try {
|
|
1010
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1011
|
+
wasm.wasmpdfdocument_rotateAllPages(retptr, this.__wbg_ptr, degrees);
|
|
1012
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1013
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1014
|
+
if (r1) {
|
|
1015
|
+
throw takeObject(r0);
|
|
1016
|
+
}
|
|
1017
|
+
} finally {
|
|
1018
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Rotate a page by the given degrees (adds to current rotation).
|
|
1023
|
+
* @param {number} page_index
|
|
1024
|
+
* @param {number} degrees
|
|
1025
|
+
*/
|
|
1026
|
+
rotatePage(page_index, degrees) {
|
|
1027
|
+
try {
|
|
1028
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1029
|
+
wasm.wasmpdfdocument_rotatePage(retptr, this.__wbg_ptr, page_index, degrees);
|
|
1030
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1031
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1032
|
+
if (r1) {
|
|
1033
|
+
throw takeObject(r0);
|
|
1034
|
+
}
|
|
1035
|
+
} finally {
|
|
1036
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* 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
|
+
* @param {string} user_password
|
|
1049
|
+
* @param {string | null} [owner_password]
|
|
1050
|
+
* @param {boolean | null} [allow_print]
|
|
1051
|
+
* @param {boolean | null} [allow_copy]
|
|
1052
|
+
* @param {boolean | null} [allow_modify]
|
|
1053
|
+
* @param {boolean | null} [allow_annotate]
|
|
1054
|
+
* @returns {Uint8Array}
|
|
1055
|
+
*/
|
|
1056
|
+
saveEncryptedToBytes(user_password, owner_password, allow_print, allow_copy, allow_modify, allow_annotate) {
|
|
1057
|
+
try {
|
|
1058
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1059
|
+
const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1060
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1061
|
+
var ptr1 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1062
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1063
|
+
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);
|
|
1064
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1065
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1066
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1067
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1068
|
+
if (r3) {
|
|
1069
|
+
throw takeObject(r2);
|
|
1070
|
+
}
|
|
1071
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1072
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1073
|
+
return v3;
|
|
1074
|
+
} finally {
|
|
1075
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Save all edits and return the resulting PDF as bytes.
|
|
1080
|
+
*
|
|
1081
|
+
* @returns Uint8Array containing the modified PDF
|
|
1082
|
+
* @returns {Uint8Array}
|
|
1083
|
+
*/
|
|
1084
|
+
saveToBytes() {
|
|
1085
|
+
try {
|
|
1086
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1087
|
+
wasm.wasmpdfdocument_saveToBytes(retptr, this.__wbg_ptr);
|
|
1088
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1089
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1090
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1091
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1092
|
+
if (r3) {
|
|
1093
|
+
throw takeObject(r2);
|
|
1094
|
+
}
|
|
1095
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1096
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1097
|
+
return v1;
|
|
1098
|
+
} finally {
|
|
1099
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Search for text across all pages.
|
|
1104
|
+
*
|
|
1105
|
+
* @param pattern - Regex pattern or literal text to search for
|
|
1106
|
+
* @param case_insensitive - Case insensitive search (default: false)
|
|
1107
|
+
* @param literal - Treat pattern as literal text, not regex (default: false)
|
|
1108
|
+
* @param whole_word - Match whole words only (default: false)
|
|
1109
|
+
* @param max_results - Maximum results to return, 0 = unlimited (default: 0)
|
|
1110
|
+
*
|
|
1111
|
+
* Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
|
|
1112
|
+
* @param {string} pattern
|
|
1113
|
+
* @param {boolean | null} [case_insensitive]
|
|
1114
|
+
* @param {boolean | null} [literal]
|
|
1115
|
+
* @param {boolean | null} [whole_word]
|
|
1116
|
+
* @param {number | null} [max_results]
|
|
1117
|
+
* @returns {any}
|
|
1118
|
+
*/
|
|
1119
|
+
search(pattern, case_insensitive, literal, whole_word, max_results) {
|
|
1120
|
+
try {
|
|
1121
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1122
|
+
const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1124
|
+
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);
|
|
1125
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1126
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1127
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1128
|
+
if (r2) {
|
|
1129
|
+
throw takeObject(r1);
|
|
1130
|
+
}
|
|
1131
|
+
return takeObject(r0);
|
|
1132
|
+
} finally {
|
|
1133
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Search for text on a specific page.
|
|
1138
|
+
* @param {number} page_index
|
|
1139
|
+
* @param {string} pattern
|
|
1140
|
+
* @param {boolean | null} [case_insensitive]
|
|
1141
|
+
* @param {boolean | null} [literal]
|
|
1142
|
+
* @param {boolean | null} [whole_word]
|
|
1143
|
+
* @param {number | null} [max_results]
|
|
1144
|
+
* @returns {any}
|
|
1145
|
+
*/
|
|
1146
|
+
searchPage(page_index, pattern, case_insensitive, literal, whole_word, max_results) {
|
|
1147
|
+
try {
|
|
1148
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1149
|
+
const ptr0 = passStringToWasm0(pattern, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1151
|
+
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);
|
|
1152
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1153
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1154
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1155
|
+
if (r2) {
|
|
1156
|
+
throw takeObject(r1);
|
|
1157
|
+
}
|
|
1158
|
+
return takeObject(r0);
|
|
1159
|
+
} finally {
|
|
1160
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Set the document author.
|
|
1165
|
+
* @param {string} author
|
|
1166
|
+
*/
|
|
1167
|
+
setAuthor(author) {
|
|
1168
|
+
try {
|
|
1169
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1170
|
+
const ptr0 = passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1171
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1172
|
+
wasm.wasmpdfdocument_setAuthor(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1173
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1174
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1175
|
+
if (r1) {
|
|
1176
|
+
throw takeObject(r0);
|
|
1177
|
+
}
|
|
1178
|
+
} finally {
|
|
1179
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Set the value of a form field.
|
|
1184
|
+
*
|
|
1185
|
+
* @param name - Full qualified field name
|
|
1186
|
+
* @param value - New value: string for text fields, boolean for checkboxes
|
|
1187
|
+
* @param {string} name
|
|
1188
|
+
* @param {any} value
|
|
1189
|
+
*/
|
|
1190
|
+
setFormFieldValue(name, value) {
|
|
1191
|
+
try {
|
|
1192
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1193
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1195
|
+
wasm.wasmpdfdocument_setFormFieldValue(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
|
|
1196
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1197
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1198
|
+
if (r1) {
|
|
1199
|
+
throw takeObject(r0);
|
|
1200
|
+
}
|
|
1201
|
+
} finally {
|
|
1202
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Set the complete bounds of an image on a page.
|
|
1207
|
+
* @param {number} page_index
|
|
1208
|
+
* @param {string} name
|
|
1209
|
+
* @param {number} x
|
|
1210
|
+
* @param {number} y
|
|
1211
|
+
* @param {number} width
|
|
1212
|
+
* @param {number} height
|
|
1213
|
+
*/
|
|
1214
|
+
setImageBounds(page_index, name, x, y, width, height) {
|
|
1215
|
+
try {
|
|
1216
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1217
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1219
|
+
wasm.wasmpdfdocument_setImageBounds(retptr, this.__wbg_ptr, page_index, ptr0, len0, x, y, width, height);
|
|
1220
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1221
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1222
|
+
if (r1) {
|
|
1223
|
+
throw takeObject(r0);
|
|
1224
|
+
}
|
|
1225
|
+
} finally {
|
|
1226
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Set the document keywords.
|
|
1231
|
+
* @param {string} keywords
|
|
1232
|
+
*/
|
|
1233
|
+
setKeywords(keywords) {
|
|
1234
|
+
try {
|
|
1235
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1236
|
+
const ptr0 = passStringToWasm0(keywords, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1237
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1238
|
+
wasm.wasmpdfdocument_setKeywords(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1239
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1240
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1241
|
+
if (r1) {
|
|
1242
|
+
throw takeObject(r0);
|
|
1243
|
+
}
|
|
1244
|
+
} finally {
|
|
1245
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Set the CropBox of a page.
|
|
1250
|
+
* @param {number} page_index
|
|
1251
|
+
* @param {number} llx
|
|
1252
|
+
* @param {number} lly
|
|
1253
|
+
* @param {number} urx
|
|
1254
|
+
* @param {number} ury
|
|
1255
|
+
*/
|
|
1256
|
+
setPageCropBox(page_index, llx, lly, urx, ury) {
|
|
1257
|
+
try {
|
|
1258
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1259
|
+
wasm.wasmpdfdocument_setPageCropBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
|
|
1260
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1261
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1262
|
+
if (r1) {
|
|
1263
|
+
throw takeObject(r0);
|
|
1264
|
+
}
|
|
1265
|
+
} finally {
|
|
1266
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Set the MediaBox of a page.
|
|
1271
|
+
* @param {number} page_index
|
|
1272
|
+
* @param {number} llx
|
|
1273
|
+
* @param {number} lly
|
|
1274
|
+
* @param {number} urx
|
|
1275
|
+
* @param {number} ury
|
|
1276
|
+
*/
|
|
1277
|
+
setPageMediaBox(page_index, llx, lly, urx, ury) {
|
|
1278
|
+
try {
|
|
1279
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1280
|
+
wasm.wasmpdfdocument_setPageMediaBox(retptr, this.__wbg_ptr, page_index, llx, lly, urx, ury);
|
|
1281
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1282
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1283
|
+
if (r1) {
|
|
1284
|
+
throw takeObject(r0);
|
|
1285
|
+
}
|
|
1286
|
+
} finally {
|
|
1287
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Set the rotation of a page (0, 90, 180, or 270 degrees).
|
|
1292
|
+
* @param {number} page_index
|
|
1293
|
+
* @param {number} degrees
|
|
1294
|
+
*/
|
|
1295
|
+
setPageRotation(page_index, degrees) {
|
|
1296
|
+
try {
|
|
1297
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1298
|
+
wasm.wasmpdfdocument_setPageRotation(retptr, this.__wbg_ptr, page_index, degrees);
|
|
1299
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1300
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1301
|
+
if (r1) {
|
|
1302
|
+
throw takeObject(r0);
|
|
1303
|
+
}
|
|
1304
|
+
} finally {
|
|
1305
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Set the document subject.
|
|
1310
|
+
* @param {string} subject
|
|
1311
|
+
*/
|
|
1312
|
+
setSubject(subject) {
|
|
1313
|
+
try {
|
|
1314
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1315
|
+
const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1317
|
+
wasm.wasmpdfdocument_setSubject(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1318
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1319
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1320
|
+
if (r1) {
|
|
1321
|
+
throw takeObject(r0);
|
|
1322
|
+
}
|
|
1323
|
+
} finally {
|
|
1324
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Set the document title.
|
|
1329
|
+
* @param {string} title
|
|
1330
|
+
*/
|
|
1331
|
+
setTitle(title) {
|
|
1332
|
+
try {
|
|
1333
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1334
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1336
|
+
wasm.wasmpdfdocument_setTitle(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1337
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1338
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1339
|
+
if (r1) {
|
|
1340
|
+
throw takeObject(r0);
|
|
1341
|
+
}
|
|
1342
|
+
} finally {
|
|
1343
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Convert a single page to HTML.
|
|
1348
|
+
*
|
|
1349
|
+
* @param page_index - Zero-based page number
|
|
1350
|
+
* @param preserve_layout - Use CSS positioning to preserve layout (default: false)
|
|
1351
|
+
* @param detect_headings - Whether to detect headings (default: true)
|
|
1352
|
+
* @param {number} page_index
|
|
1353
|
+
* @param {boolean | null} [preserve_layout]
|
|
1354
|
+
* @param {boolean | null} [detect_headings]
|
|
1355
|
+
* @param {boolean | null} [include_form_fields]
|
|
1356
|
+
* @returns {string}
|
|
1357
|
+
*/
|
|
1358
|
+
toHtml(page_index, preserve_layout, detect_headings, include_form_fields) {
|
|
1359
|
+
let deferred2_0;
|
|
1360
|
+
let deferred2_1;
|
|
1361
|
+
try {
|
|
1362
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1363
|
+
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);
|
|
1364
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1365
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1366
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1367
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1368
|
+
var ptr1 = r0;
|
|
1369
|
+
var len1 = r1;
|
|
1370
|
+
if (r3) {
|
|
1371
|
+
ptr1 = 0; len1 = 0;
|
|
1372
|
+
throw takeObject(r2);
|
|
1373
|
+
}
|
|
1374
|
+
deferred2_0 = ptr1;
|
|
1375
|
+
deferred2_1 = len1;
|
|
1376
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1377
|
+
} finally {
|
|
1378
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1379
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Convert all pages to HTML.
|
|
1384
|
+
* @param {boolean | null} [preserve_layout]
|
|
1385
|
+
* @param {boolean | null} [detect_headings]
|
|
1386
|
+
* @param {boolean | null} [include_form_fields]
|
|
1387
|
+
* @returns {string}
|
|
1388
|
+
*/
|
|
1389
|
+
toHtmlAll(preserve_layout, detect_headings, include_form_fields) {
|
|
1390
|
+
let deferred2_0;
|
|
1391
|
+
let deferred2_1;
|
|
1392
|
+
try {
|
|
1393
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1394
|
+
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);
|
|
1395
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1396
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1397
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1398
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1399
|
+
var ptr1 = r0;
|
|
1400
|
+
var len1 = r1;
|
|
1401
|
+
if (r3) {
|
|
1402
|
+
ptr1 = 0; len1 = 0;
|
|
1403
|
+
throw takeObject(r2);
|
|
1404
|
+
}
|
|
1405
|
+
deferred2_0 = ptr1;
|
|
1406
|
+
deferred2_1 = len1;
|
|
1407
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1408
|
+
} finally {
|
|
1409
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1410
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Convert a single page to Markdown.
|
|
1415
|
+
*
|
|
1416
|
+
* @param page_index - Zero-based page number
|
|
1417
|
+
* @param detect_headings - Whether to detect headings (default: true)
|
|
1418
|
+
* @param include_images - Whether to include images (default: true)
|
|
1419
|
+
* @param {number} page_index
|
|
1420
|
+
* @param {boolean | null} [detect_headings]
|
|
1421
|
+
* @param {boolean | null} [include_images]
|
|
1422
|
+
* @param {boolean | null} [include_form_fields]
|
|
1423
|
+
* @returns {string}
|
|
1424
|
+
*/
|
|
1425
|
+
toMarkdown(page_index, detect_headings, include_images, include_form_fields) {
|
|
1426
|
+
let deferred2_0;
|
|
1427
|
+
let deferred2_1;
|
|
1428
|
+
try {
|
|
1429
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1430
|
+
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);
|
|
1431
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1432
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1433
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1434
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1435
|
+
var ptr1 = r0;
|
|
1436
|
+
var len1 = r1;
|
|
1437
|
+
if (r3) {
|
|
1438
|
+
ptr1 = 0; len1 = 0;
|
|
1439
|
+
throw takeObject(r2);
|
|
1440
|
+
}
|
|
1441
|
+
deferred2_0 = ptr1;
|
|
1442
|
+
deferred2_1 = len1;
|
|
1443
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1444
|
+
} finally {
|
|
1445
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1446
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Convert all pages to Markdown.
|
|
1451
|
+
* @param {boolean | null} [detect_headings]
|
|
1452
|
+
* @param {boolean | null} [include_images]
|
|
1453
|
+
* @param {boolean | null} [include_form_fields]
|
|
1454
|
+
* @returns {string}
|
|
1455
|
+
*/
|
|
1456
|
+
toMarkdownAll(detect_headings, include_images, include_form_fields) {
|
|
1457
|
+
let deferred2_0;
|
|
1458
|
+
let deferred2_1;
|
|
1459
|
+
try {
|
|
1460
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1461
|
+
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);
|
|
1462
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1463
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1464
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1465
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1466
|
+
var ptr1 = r0;
|
|
1467
|
+
var len1 = r1;
|
|
1468
|
+
if (r3) {
|
|
1469
|
+
ptr1 = 0; len1 = 0;
|
|
1470
|
+
throw takeObject(r2);
|
|
1471
|
+
}
|
|
1472
|
+
deferred2_0 = ptr1;
|
|
1473
|
+
deferred2_1 = len1;
|
|
1474
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1475
|
+
} finally {
|
|
1476
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1477
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Convert a single page to plain text (with layout preservation options).
|
|
1482
|
+
* @param {number} page_index
|
|
1483
|
+
* @returns {string}
|
|
1484
|
+
*/
|
|
1485
|
+
toPlainText(page_index) {
|
|
1486
|
+
let deferred2_0;
|
|
1487
|
+
let deferred2_1;
|
|
1488
|
+
try {
|
|
1489
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1490
|
+
wasm.wasmpdfdocument_toPlainText(retptr, this.__wbg_ptr, page_index);
|
|
1491
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1492
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1493
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1494
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1495
|
+
var ptr1 = r0;
|
|
1496
|
+
var len1 = r1;
|
|
1497
|
+
if (r3) {
|
|
1498
|
+
ptr1 = 0; len1 = 0;
|
|
1499
|
+
throw takeObject(r2);
|
|
1500
|
+
}
|
|
1501
|
+
deferred2_0 = ptr1;
|
|
1502
|
+
deferred2_1 = len1;
|
|
1503
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1504
|
+
} finally {
|
|
1505
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1506
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Convert all pages to plain text.
|
|
1511
|
+
* @returns {string}
|
|
1512
|
+
*/
|
|
1513
|
+
toPlainTextAll() {
|
|
1514
|
+
let deferred2_0;
|
|
1515
|
+
let deferred2_1;
|
|
1516
|
+
try {
|
|
1517
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1518
|
+
wasm.wasmpdfdocument_toPlainTextAll(retptr, this.__wbg_ptr);
|
|
1519
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1520
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1521
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1522
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1523
|
+
var ptr1 = r0;
|
|
1524
|
+
var len1 = r1;
|
|
1525
|
+
if (r3) {
|
|
1526
|
+
ptr1 = 0; len1 = 0;
|
|
1527
|
+
throw takeObject(r2);
|
|
1528
|
+
}
|
|
1529
|
+
deferred2_0 = ptr1;
|
|
1530
|
+
deferred2_1 = len1;
|
|
1531
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1532
|
+
} finally {
|
|
1533
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1534
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Get the PDF version as [major, minor].
|
|
1539
|
+
* @returns {Uint8Array}
|
|
1540
|
+
*/
|
|
1541
|
+
version() {
|
|
1542
|
+
try {
|
|
1543
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1544
|
+
wasm.wasmpdfdocument_version(retptr, this.__wbg_ptr);
|
|
1545
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1546
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1547
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1548
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1549
|
+
return v1;
|
|
1550
|
+
} finally {
|
|
1551
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Get XMP metadata from the document.
|
|
1556
|
+
*
|
|
1557
|
+
* @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
|
|
1558
|
+
* @returns {any}
|
|
1559
|
+
*/
|
|
1560
|
+
xmpMetadata() {
|
|
1561
|
+
try {
|
|
1562
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1563
|
+
wasm.wasmpdfdocument_xmpMetadata(retptr, this.__wbg_ptr);
|
|
1564
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1565
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1566
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1567
|
+
if (r2) {
|
|
1568
|
+
throw takeObject(r1);
|
|
1569
|
+
}
|
|
1570
|
+
return takeObject(r0);
|
|
1571
|
+
} finally {
|
|
1572
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
if (Symbol.dispose) WasmPdfDocument.prototype[Symbol.dispose] = WasmPdfDocument.prototype.free;
|
|
1577
|
+
exports.WasmPdfDocument = WasmPdfDocument;
|
|
1578
|
+
|
|
1579
|
+
function __wbg_get_imports() {
|
|
1580
|
+
const import0 = {
|
|
1581
|
+
__proto__: null,
|
|
1582
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
1583
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1584
|
+
return addHeapObject(ret);
|
|
1585
|
+
},
|
|
1586
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
1587
|
+
const ret = String(getObject(arg1));
|
|
1588
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1589
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1590
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1591
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1592
|
+
},
|
|
1593
|
+
__wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
|
|
1594
|
+
const v = getObject(arg0);
|
|
1595
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
1596
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
1597
|
+
},
|
|
1598
|
+
__wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
|
|
1599
|
+
const ret = getObject(arg0) === null;
|
|
1600
|
+
return ret;
|
|
1601
|
+
},
|
|
1602
|
+
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
|
1603
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
1604
|
+
return ret;
|
|
1605
|
+
},
|
|
1606
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
1607
|
+
const ret = getObject(arg0) === undefined;
|
|
1608
|
+
return ret;
|
|
1609
|
+
},
|
|
1610
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
1611
|
+
const obj = getObject(arg1);
|
|
1612
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1613
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1614
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1615
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1616
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1617
|
+
},
|
|
1618
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
1619
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1620
|
+
},
|
|
1621
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
1622
|
+
let deferred0_0;
|
|
1623
|
+
let deferred0_1;
|
|
1624
|
+
try {
|
|
1625
|
+
deferred0_0 = arg0;
|
|
1626
|
+
deferred0_1 = arg1;
|
|
1627
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1628
|
+
} finally {
|
|
1629
|
+
wasm.__wbindgen_export3(deferred0_0, deferred0_1, 1);
|
|
1630
|
+
}
|
|
1631
|
+
},
|
|
1632
|
+
__wbg_fromCodePoint_4a02c6dcced1d233: function() { return handleError(function (arg0) {
|
|
1633
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
1634
|
+
return addHeapObject(ret);
|
|
1635
|
+
}, arguments); },
|
|
1636
|
+
__wbg_from_4bdf88943703fd48: function(arg0) {
|
|
1637
|
+
const ret = Array.from(getObject(arg0));
|
|
1638
|
+
return addHeapObject(ret);
|
|
1639
|
+
},
|
|
1640
|
+
__wbg_getRandomValues_3dda8830c2565714: function() { return handleError(function (arg0, arg1) {
|
|
1641
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1642
|
+
}, arguments); },
|
|
1643
|
+
__wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
|
|
1644
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1645
|
+
return addHeapObject(ret);
|
|
1646
|
+
},
|
|
1647
|
+
__wbg_isArray_33b91feb269ff46e: function(arg0) {
|
|
1648
|
+
const ret = Array.isArray(getObject(arg0));
|
|
1649
|
+
return ret;
|
|
1650
|
+
},
|
|
1651
|
+
__wbg_length_b3416cf66a5452c8: function(arg0) {
|
|
1652
|
+
const ret = getObject(arg0).length;
|
|
1653
|
+
return ret;
|
|
1654
|
+
},
|
|
1655
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
1656
|
+
const ret = getObject(arg0).length;
|
|
1657
|
+
return ret;
|
|
1658
|
+
},
|
|
1659
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
1660
|
+
const ret = new Error();
|
|
1661
|
+
return addHeapObject(ret);
|
|
1662
|
+
},
|
|
1663
|
+
__wbg_new_49d5571bd3f0c4d4: function() {
|
|
1664
|
+
const ret = new Map();
|
|
1665
|
+
return addHeapObject(ret);
|
|
1666
|
+
},
|
|
1667
|
+
__wbg_new_5f486cdf45a04d78: function(arg0) {
|
|
1668
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
1669
|
+
return addHeapObject(ret);
|
|
1670
|
+
},
|
|
1671
|
+
__wbg_new_a70fbab9066b301f: function() {
|
|
1672
|
+
const ret = new Array();
|
|
1673
|
+
return addHeapObject(ret);
|
|
1674
|
+
},
|
|
1675
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
1676
|
+
const ret = new Object();
|
|
1677
|
+
return addHeapObject(ret);
|
|
1678
|
+
},
|
|
1679
|
+
__wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
|
|
1680
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1681
|
+
return addHeapObject(ret);
|
|
1682
|
+
},
|
|
1683
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
1684
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
1685
|
+
},
|
|
1686
|
+
__wbg_push_e87b0e732085a946: function(arg0, arg1) {
|
|
1687
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
1688
|
+
return ret;
|
|
1689
|
+
},
|
|
1690
|
+
__wbg_set_282384002438957f: function(arg0, arg1, arg2) {
|
|
1691
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
1692
|
+
},
|
|
1693
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
1694
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
1695
|
+
},
|
|
1696
|
+
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1697
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
1698
|
+
return ret;
|
|
1699
|
+
}, arguments); },
|
|
1700
|
+
__wbg_set_bf7251625df30a02: function(arg0, arg1, arg2) {
|
|
1701
|
+
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
|
1702
|
+
return addHeapObject(ret);
|
|
1703
|
+
},
|
|
1704
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
1705
|
+
const ret = getObject(arg1).stack;
|
|
1706
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1707
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1708
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1709
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1710
|
+
},
|
|
1711
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1712
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1713
|
+
const ret = arg0;
|
|
1714
|
+
return addHeapObject(ret);
|
|
1715
|
+
},
|
|
1716
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
1717
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
1718
|
+
const ret = arg0;
|
|
1719
|
+
return addHeapObject(ret);
|
|
1720
|
+
},
|
|
1721
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1722
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1723
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1724
|
+
return addHeapObject(ret);
|
|
1725
|
+
},
|
|
1726
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
1727
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
1728
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1729
|
+
return addHeapObject(ret);
|
|
1730
|
+
},
|
|
1731
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
1732
|
+
const ret = getObject(arg0);
|
|
1733
|
+
return addHeapObject(ret);
|
|
1734
|
+
},
|
|
1735
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
1736
|
+
takeObject(arg0);
|
|
1737
|
+
},
|
|
1738
|
+
};
|
|
1739
|
+
return {
|
|
1740
|
+
__proto__: null,
|
|
1741
|
+
"./pdf_oxide_bg.js": import0,
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
const WasmPdfFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1746
|
+
? { register: () => {}, unregister: () => {} }
|
|
1747
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdf_free(ptr >>> 0, 1));
|
|
1748
|
+
const WasmPdfDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1749
|
+
? { register: () => {}, unregister: () => {} }
|
|
1750
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfdocument_free(ptr >>> 0, 1));
|
|
1751
|
+
|
|
1752
|
+
function addHeapObject(obj) {
|
|
1753
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
1754
|
+
const idx = heap_next;
|
|
1755
|
+
heap_next = heap[idx];
|
|
1756
|
+
|
|
1757
|
+
heap[idx] = obj;
|
|
1758
|
+
return idx;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
function dropObject(idx) {
|
|
1762
|
+
if (idx < 1028) return;
|
|
1763
|
+
heap[idx] = heap_next;
|
|
1764
|
+
heap_next = idx;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
1768
|
+
ptr = ptr >>> 0;
|
|
1769
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1773
|
+
ptr = ptr >>> 0;
|
|
1774
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
let cachedDataViewMemory0 = null;
|
|
1778
|
+
function getDataViewMemory0() {
|
|
1779
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1780
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1781
|
+
}
|
|
1782
|
+
return cachedDataViewMemory0;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
1786
|
+
function getFloat32ArrayMemory0() {
|
|
1787
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
1788
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
1789
|
+
}
|
|
1790
|
+
return cachedFloat32ArrayMemory0;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
function getStringFromWasm0(ptr, len) {
|
|
1794
|
+
ptr = ptr >>> 0;
|
|
1795
|
+
return decodeText(ptr, len);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1799
|
+
function getUint8ArrayMemory0() {
|
|
1800
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1801
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1802
|
+
}
|
|
1803
|
+
return cachedUint8ArrayMemory0;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
function getObject(idx) { return heap[idx]; }
|
|
1807
|
+
|
|
1808
|
+
function handleError(f, args) {
|
|
1809
|
+
try {
|
|
1810
|
+
return f.apply(this, args);
|
|
1811
|
+
} catch (e) {
|
|
1812
|
+
wasm.__wbindgen_export4(addHeapObject(e));
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
let heap = new Array(1024).fill(undefined);
|
|
1817
|
+
heap.push(undefined, null, true, false);
|
|
1818
|
+
|
|
1819
|
+
let heap_next = heap.length;
|
|
1820
|
+
|
|
1821
|
+
function isLikeNone(x) {
|
|
1822
|
+
return x === undefined || x === null;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1826
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1827
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1828
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1829
|
+
return ptr;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
1833
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1834
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
1835
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1836
|
+
return ptr;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1840
|
+
if (realloc === undefined) {
|
|
1841
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1842
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1843
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1844
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1845
|
+
return ptr;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
let len = arg.length;
|
|
1849
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1850
|
+
|
|
1851
|
+
const mem = getUint8ArrayMemory0();
|
|
1852
|
+
|
|
1853
|
+
let offset = 0;
|
|
1854
|
+
|
|
1855
|
+
for (; offset < len; offset++) {
|
|
1856
|
+
const code = arg.charCodeAt(offset);
|
|
1857
|
+
if (code > 0x7F) break;
|
|
1858
|
+
mem[ptr + offset] = code;
|
|
1859
|
+
}
|
|
1860
|
+
if (offset !== len) {
|
|
1861
|
+
if (offset !== 0) {
|
|
1862
|
+
arg = arg.slice(offset);
|
|
1863
|
+
}
|
|
1864
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1865
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1866
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1867
|
+
|
|
1868
|
+
offset += ret.written;
|
|
1869
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
WASM_VECTOR_LEN = offset;
|
|
1873
|
+
return ptr;
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
function takeObject(idx) {
|
|
1877
|
+
const ret = getObject(idx);
|
|
1878
|
+
dropObject(idx);
|
|
1879
|
+
return ret;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1883
|
+
cachedTextDecoder.decode();
|
|
1884
|
+
function decodeText(ptr, len) {
|
|
1885
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1889
|
+
|
|
1890
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1891
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1892
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1893
|
+
view.set(buf);
|
|
1894
|
+
return {
|
|
1895
|
+
read: arg.length,
|
|
1896
|
+
written: buf.length
|
|
1897
|
+
};
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
let WASM_VECTOR_LEN = 0;
|
|
1902
|
+
|
|
1903
|
+
const wasmPath = `${__dirname}/pdf_oxide_bg.wasm`;
|
|
1904
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
1905
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
1906
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|