pdf-oxide-wasm 0.3.18 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/pdf_oxide.d.ts CHANGED
@@ -1,690 +1,811 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Style configuration for header/footer text.
6
+ */
4
7
  export class ArtifactStyle {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Set bold font for the artifact.
12
+ */
13
+ bold(): ArtifactStyle;
14
+ /**
15
+ * Set color for the artifact.
16
+ */
17
+ color(r: number, g: number, b: number): ArtifactStyle;
18
+ /**
19
+ * Set font for the artifact.
20
+ */
21
+ font(name: string, size: number): ArtifactStyle;
22
+ /**
23
+ * Create a new artifact style.
24
+ */
25
+ constructor();
8
26
  }
9
27
 
28
+ /**
29
+ * Chroma subsampling format
30
+ */
31
+ export enum ChromaSampling {
32
+ /**
33
+ * Both vertically and horizontally subsampled.
34
+ */
35
+ Cs420 = 0,
36
+ /**
37
+ * Horizontally subsampled.
38
+ */
39
+ Cs422 = 1,
40
+ /**
41
+ * Not subsampled.
42
+ */
43
+ Cs444 = 2,
44
+ /**
45
+ * Monochrome.
46
+ */
47
+ Cs400 = 3,
48
+ }
49
+
50
+ /**
51
+ * A header or footer artifact definition.
52
+ */
10
53
  export class WasmArtifact {
11
- free(): void;
12
- [Symbol.dispose](): void;
13
- /**
14
- * Set style for the artifact.
15
- */
16
- withStyle(style: ArtifactStyle): WasmArtifact;
17
- /**
18
- * Set vertical offset for the artifact.
19
- */
20
- withOffset(offset: number): WasmArtifact;
21
- /**
22
- * Create a new artifact.
23
- */
24
- constructor();
25
- /**
26
- * Create a left-aligned artifact.
27
- */
28
- static left(text: string): WasmArtifact;
29
- /**
30
- * Create a right-aligned artifact.
31
- */
32
- static right(text: string): WasmArtifact;
33
- /**
34
- * Create a center-aligned artifact.
35
- */
36
- static center(text: string): WasmArtifact;
54
+ free(): void;
55
+ [Symbol.dispose](): void;
56
+ /**
57
+ * Create a center-aligned artifact.
58
+ */
59
+ static center(text: string): WasmArtifact;
60
+ /**
61
+ * Create a left-aligned artifact.
62
+ */
63
+ static left(text: string): WasmArtifact;
64
+ /**
65
+ * Create a new artifact.
66
+ */
67
+ constructor();
68
+ /**
69
+ * Create a right-aligned artifact.
70
+ */
71
+ static right(text: string): WasmArtifact;
72
+ /**
73
+ * Set vertical offset for the artifact.
74
+ */
75
+ withOffset(offset: number): WasmArtifact;
76
+ /**
77
+ * Set style for the artifact.
78
+ */
79
+ withStyle(style: ArtifactStyle): WasmArtifact;
37
80
  }
38
81
 
82
+ /**
83
+ * A footer definition.
84
+ */
39
85
  export class WasmFooter {
40
- free(): void;
41
- [Symbol.dispose](): void;
42
- /**
43
- * Create a new empty footer.
44
- */
45
- constructor();
46
- /**
47
- * Create a left-aligned footer.
48
- */
49
- static left(text: string): WasmFooter;
50
- /**
51
- * Create a right-aligned footer.
52
- */
53
- static right(text: string): WasmFooter;
54
- /**
55
- * Create a center-aligned footer.
56
- */
57
- static center(text: string): WasmFooter;
86
+ free(): void;
87
+ [Symbol.dispose](): void;
88
+ /**
89
+ * Create a center-aligned footer.
90
+ */
91
+ static center(text: string): WasmFooter;
92
+ /**
93
+ * Create a left-aligned footer.
94
+ */
95
+ static left(text: string): WasmFooter;
96
+ /**
97
+ * Create a new empty footer.
98
+ */
99
+ constructor();
100
+ /**
101
+ * Create a right-aligned footer.
102
+ */
103
+ static right(text: string): WasmFooter;
58
104
  }
59
105
 
106
+ /**
107
+ * A header definition.
108
+ */
60
109
  export class WasmHeader {
61
- free(): void;
62
- [Symbol.dispose](): void;
63
- /**
64
- * Create a new empty header.
65
- */
66
- constructor();
67
- /**
68
- * Create a left-aligned header.
69
- */
70
- static left(text: string): WasmHeader;
71
- /**
72
- * Create a right-aligned header.
73
- */
74
- static right(text: string): WasmHeader;
75
- /**
76
- * Create a center-aligned header.
77
- */
78
- static center(text: string): WasmHeader;
110
+ free(): void;
111
+ [Symbol.dispose](): void;
112
+ /**
113
+ * Create a center-aligned header.
114
+ */
115
+ static center(text: string): WasmHeader;
116
+ /**
117
+ * Create a left-aligned header.
118
+ */
119
+ static left(text: string): WasmHeader;
120
+ /**
121
+ * Create a new empty header.
122
+ */
123
+ constructor();
124
+ /**
125
+ * Create a right-aligned header.
126
+ */
127
+ static right(text: string): WasmHeader;
79
128
  }
80
129
 
130
+ /**
131
+ * OCR configuration for WebAssembly.
132
+ */
81
133
  export class WasmOcrConfig {
82
- free(): void;
83
- [Symbol.dispose](): void;
84
- /**
85
- * Create a new OCR configuration.
86
- */
87
- constructor();
134
+ free(): void;
135
+ [Symbol.dispose](): void;
136
+ /**
137
+ * Create a new OCR configuration.
138
+ */
139
+ constructor();
88
140
  }
89
141
 
142
+ /**
143
+ * OCR engine for WebAssembly.
144
+ */
90
145
  export class WasmOcrEngine {
91
- free(): void;
92
- [Symbol.dispose](): void;
93
- /**
94
- * Create a new OCR engine.
95
- */
96
- constructor(_det_model_path: string, _rec_model_path: string, _dict_path: string, _config?: WasmOcrConfig | null);
146
+ free(): void;
147
+ [Symbol.dispose](): void;
148
+ /**
149
+ * Create a new OCR engine.
150
+ */
151
+ constructor(_det_model_path: string, _rec_model_path: string, _dict_path: string, _config?: WasmOcrConfig | null);
97
152
  }
98
153
 
154
+ /**
155
+ * A complete page template with header and footer.
156
+ */
99
157
  export class WasmPageTemplate {
100
- free(): void;
101
- [Symbol.dispose](): void;
102
- /**
103
- * Skip rendering template on the first page.
104
- */
105
- skipFirstPage(): WasmPageTemplate;
106
- /**
107
- * Create a new page template.
108
- */
109
- constructor();
110
- /**
111
- * Set footer artifact.
112
- */
113
- footer(footer: WasmArtifact): WasmPageTemplate;
114
- /**
115
- * Set header artifact.
116
- */
117
- header(header: WasmArtifact): WasmPageTemplate;
158
+ free(): void;
159
+ [Symbol.dispose](): void;
160
+ /**
161
+ * Set footer artifact.
162
+ */
163
+ footer(footer: WasmArtifact): WasmPageTemplate;
164
+ /**
165
+ * Set header artifact.
166
+ */
167
+ header(header: WasmArtifact): WasmPageTemplate;
168
+ /**
169
+ * Create a new page template.
170
+ */
171
+ constructor();
172
+ /**
173
+ * Skip rendering template on the first page.
174
+ */
175
+ skipFirstPage(): WasmPageTemplate;
118
176
  }
119
177
 
178
+ /**
179
+ * Create new PDF documents from Markdown, HTML, or plain text.
180
+ *
181
+ * ```javascript
182
+ * const pdf = WasmPdf.fromMarkdown("# Hello\n\nWorld");
183
+ * const bytes = pdf.toBytes(); // Uint8Array
184
+ * console.log(`PDF size: ${pdf.size} bytes`);
185
+ * ```
186
+ */
120
187
  export class WasmPdf {
121
- private constructor();
122
- free(): void;
123
- [Symbol.dispose](): void;
124
- /**
125
- * Create a PDF from Markdown content.
126
- *
127
- * @param content - Markdown string
128
- * @param title - Optional document title
129
- * @param author - Optional document author
130
- */
131
- static fromMarkdown(content: string, title?: string | null, author?: string | null): WasmPdf;
132
- /**
133
- * Create a PDF from image bytes (PNG, JPEG, etc.).
134
- *
135
- * @param data - Image file contents as a Uint8Array
136
- */
137
- static fromImageBytes(data: Uint8Array): WasmPdf;
138
- /**
139
- * Create a PDF from multiple image byte arrays.
140
- *
141
- * Each image becomes a separate page. Pass an array of Uint8Arrays.
142
- *
143
- * @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
144
- */
145
- static fromMultipleImageBytes(images_array: any): WasmPdf;
146
- /**
147
- * Merge multiple PDF byte arrays into a single PDF.
148
- *
149
- * @param pdfs - Array of Uint8Array, each containing a PDF
150
- * @returns WasmPdf containing all pages
151
- */
152
- static merge(pdfs: Uint8Array[]): WasmPdf;
153
- /**
154
- * Get the PDF as a Uint8Array.
155
- */
156
- toBytes(): Uint8Array;
157
- /**
158
- * Create a PDF from HTML content.
159
- *
160
- * @param content - HTML string
161
- * @param title - Optional document title
162
- * @param author - Optional document author
163
- */
164
- static fromHtml(content: string, title?: string | null, author?: string | null): WasmPdf;
165
- /**
166
- * Create a PDF from plain text.
167
- *
168
- * @param content - Plain text string
169
- * @param title - Optional document title
170
- * @param author - Optional document author
171
- */
172
- static fromText(content: string, title?: string | null, author?: string | null): WasmPdf;
173
- /**
174
- * Get the size of the PDF in bytes.
175
- */
176
- readonly size: number;
188
+ private constructor();
189
+ free(): void;
190
+ [Symbol.dispose](): void;
191
+ /**
192
+ * Open an existing PDF from bytes for editing.
193
+ *
194
+ * @param data - PDF file contents as Uint8Array
195
+ * @returns WasmPdf for editing
196
+ */
197
+ static fromBytes(data: Uint8Array): WasmPdf;
198
+ /**
199
+ * Create a PDF from HTML content.
200
+ *
201
+ * @param content - HTML string
202
+ * @param title - Optional document title
203
+ * @param author - Optional document author
204
+ */
205
+ static fromHtml(content: string, title?: string | null, author?: string | null): WasmPdf;
206
+ /**
207
+ * Create a PDF from image bytes (PNG, JPEG, etc.).
208
+ *
209
+ * @param data - Image file contents as a Uint8Array
210
+ */
211
+ static fromImageBytes(data: Uint8Array): WasmPdf;
212
+ /**
213
+ * Create a PDF from Markdown content.
214
+ *
215
+ * @param content - Markdown string
216
+ * @param title - Optional document title
217
+ * @param author - Optional document author
218
+ */
219
+ static fromMarkdown(content: string, title?: string | null, author?: string | null): WasmPdf;
220
+ /**
221
+ * Create a PDF from multiple image byte arrays.
222
+ *
223
+ * Each image becomes a separate page. Pass an array of Uint8Arrays.
224
+ *
225
+ * @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
226
+ */
227
+ static fromMultipleImageBytes(images_array: any): WasmPdf;
228
+ /**
229
+ * Create a PDF from plain text.
230
+ *
231
+ * @param content - Plain text string
232
+ * @param title - Optional document title
233
+ * @param author - Optional document author
234
+ */
235
+ static fromText(content: string, title?: string | null, author?: string | null): WasmPdf;
236
+ /**
237
+ * Merge multiple PDF byte arrays into a single PDF.
238
+ *
239
+ * @param pdfs - Array of Uint8Array, each containing a PDF
240
+ * @returns WasmPdf containing all pages
241
+ */
242
+ static merge(pdfs: Uint8Array[]): WasmPdf;
243
+ /**
244
+ * Get the PDF as a Uint8Array.
245
+ */
246
+ toBytes(): Uint8Array;
247
+ /**
248
+ * Get the size of the PDF in bytes.
249
+ */
250
+ readonly size: number;
177
251
  }
178
252
 
253
+ /**
254
+ * A PDF document loaded from bytes for use in WebAssembly.
255
+ *
256
+ * Create an instance by passing PDF file bytes to the constructor.
257
+ * Call `.free()` when done to release memory.
258
+ */
179
259
  export class WasmPdfDocument {
180
- free(): void;
181
- [Symbol.dispose](): void;
182
- /**
183
- * Embed a file into the PDF document.
184
- *
185
- * @param name - Display name for the embedded file
186
- * @param data - File contents as a Uint8Array
187
- */
188
- embedFile(name: string, data: Uint8Array): void;
189
- /**
190
- * Merge another PDF (provided as bytes) into this document.
191
- *
192
- * @param data - The PDF file contents to merge as a Uint8Array
193
- * @returns Number of pages merged
194
- */
195
- mergeFrom(data: Uint8Array): number;
196
- /**
197
- * Get the number of pages in the document.
198
- */
199
- pageCount(): number;
200
- /**
201
- * Set the document author.
202
- */
203
- setAuthor(author: string): void;
204
- /**
205
- * Delete a page by index (0-based).
206
- */
207
- deletePage(index: number): void;
208
- /**
209
- * Deprecated: Use eraseFooter instead.
210
- */
211
- editFooter(page_index: number): void;
212
- /**
213
- * Deprecated: Use eraseHeader instead.
214
- */
215
- editHeader(page_index: number): void;
216
- /**
217
- * Get the document outline (bookmarks / table of contents).
218
- *
219
- * @returns Array of outline items or null if no outline exists.
220
- * Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
221
- */
222
- getOutline(): any;
223
- /**
224
- * Get information about images on a page.
225
- *
226
- * Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
227
- */
228
- pageImages(page_index: number): any;
229
- /**
230
- * Get page label ranges from the document.
231
- *
232
- * @returns Array of {start_page, style, prefix, start_value} objects, or empty array
233
- */
234
- pageLabels(): any;
235
- /**
236
- * Rotate a page by the given degrees (adds to current rotation).
237
- */
238
- rotatePage(page_index: number, degrees: number): void;
239
- /**
240
- * Search for text on a specific page.
241
- */
242
- searchPage(page_index: number, pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
243
- /**
244
- * Set the document subject.
245
- */
246
- setSubject(subject: string): void;
247
- /**
248
- * Convert all pages to HTML.
249
- */
250
- toHtmlAll(preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
251
- /**
252
- * Convert a single page to Markdown.
253
- *
254
- * @param page_index - Zero-based page number
255
- * @param detect_headings - Whether to detect headings (default: true)
256
- * @param include_images - Whether to include images (default: true)
257
- */
258
- toMarkdown(page_index: number, detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
259
- /**
260
- * Authenticate with a password to decrypt an encrypted PDF.
261
- *
262
- * @param password - The password string
263
- * @returns true if authentication succeeded
264
- */
265
- authenticate(password: string): boolean;
266
- /**
267
- * Crop margins from all pages.
268
- */
269
- cropMargins(left: number, right: number, top: number, bottom: number): void;
270
- /**
271
- * Erase existing footer content.
272
- *
273
- * Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
274
- *
275
- * @param page_index - Zero-based page number
276
- */
277
- eraseFooter(page_index: number): void;
278
- /**
279
- * Erase existing header content.
280
- *
281
- * Identifies existing text in the header area (top 15%) and marks it for erasure.
282
- *
283
- * @param page_index - Zero-based page number
284
- */
285
- eraseHeader(page_index: number): void;
286
- /**
287
- * Erase (whiteout) a rectangular region on a page.
288
- */
289
- eraseRegion(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
290
- /**
291
- * Extract plain text from a single page.
292
- *
293
- * @param page_index - Zero-based page number
294
- * @param region - Optional [x, y, width, height] to filter by
295
- */
296
- extractText(page_index: number, region: any): string;
297
- /**
298
- * Resize an image on a page.
299
- */
300
- resizeImage(page_index: number, name: string, width: number, height: number): void;
301
- /**
302
- * Set the document keywords.
303
- */
304
- setKeywords(keywords: string): void;
305
- /**
306
- * Get XMP metadata from the document.
307
- *
308
- * @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
309
- */
310
- xmpMetadata(): any;
311
- /**
312
- * Erase multiple rectangular regions on a page.
313
- *
314
- * @param page_index - Zero-based page number
315
- * @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
316
- */
317
- eraseRegions(page_index: number, rects: Float32Array): void;
318
- /**
319
- * Extract character-level data from a page.
320
- *
321
- * Returns an array of objects with: char, bbox {x, y, width, height},
322
- * font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
323
- *
324
- * @param page_index - Zero-based page number
325
- * @param region - Optional [x, y, width, height] to filter by
326
- */
327
- extractChars(page_index: number, region?: Float32Array | null): any;
328
- /**
329
- * Extract only straight lines from a page (v0.3.14).
330
- *
331
- * Identifies paths that form a single straight line segment.
332
- *
333
- * @param page_index - Zero-based page number
334
- * @param region - Optional [x, y, width, height] to filter by
335
- * @returns Array of path objects
336
- */
337
- extractLines(page_index: number, region?: Float32Array | null): any;
338
- /**
339
- * Extract specific pages to a new PDF (returns bytes).
340
- */
341
- extractPages(pages: Uint32Array): Uint8Array;
342
- /**
343
- * Extract vector paths (lines, curves, shapes) from a page.
344
- *
345
- * @param page_index - Zero-based page number
346
- * @param region - Optional [x, y, width, height] to filter by
347
- * @returns Array of path objects with bbox, stroke_color, fill_color, etc.
348
- */
349
- extractPaths(page_index: number, region?: Float32Array | null): any;
350
- /**
351
- * Extract only rectangles from a page (v0.3.14).
352
- *
353
- * Identifies paths that form axis-aligned rectangles.
354
- *
355
- * @param page_index - Zero-based page number
356
- * @param region - Optional [x, y, width, height] to filter by
357
- * @returns Array of path objects
358
- */
359
- extractRects(page_index: number, region?: Float32Array | null): any;
360
- /**
361
- * Extract span-level data from a page.
362
- *
363
- * Returns an array of objects with: text, bbox, font_name, font_size,
364
- * font_weight, is_italic, color, etc.
365
- */
366
- extractSpans(page_index: number, region?: Float32Array | null): any;
367
- /**
368
- * Extract word-level data from a page.
369
- *
370
- * Returns an array of objects with: text, bbox, font_name, font_size,
371
- * font_weight, is_italic, is_bold.
372
- */
373
- extractWords(page_index: number, region?: Float32Array | null): any;
374
- /**
375
- * Flatten all form fields into page content.
376
- *
377
- * After flattening, form field values become static text and are no longer editable.
378
- */
379
- flattenForms(): void;
380
- /**
381
- * Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
382
- */
383
- pageCropBox(page_index: number): any;
384
- /**
385
- * Get the rotation of a page in degrees (0, 90, 180, 270).
386
- */
387
- pageRotation(page_index: number): number;
388
- /**
389
- * Save the modified PDF and return as bytes.
390
- * `saveToBytes()` is the original method; `save()` is a convenience alias.
391
- *
392
- * @returns Uint8Array containing the modified PDF
393
- */
394
- saveToBytes(): Uint8Array;
395
- /**
396
- * Convert a single page to plain text (with layout preservation options).
397
- */
398
- toPlainText(page_index: number): string;
399
- /**
400
- * Extract image metadata from a page.
401
- *
402
- * Returns an array of objects with: width, height, color_space,
403
- * bits_per_component, bbox (if available). Does NOT return raw image bytes.
404
- *
405
- * @param page_index - Zero-based page number
406
- * @param region - Optional [x, y, width, height] to filter by
407
- */
408
- extractImages(page_index: number, region?: Float32Array | null): any;
409
- /**
410
- * Extract tables from a page (v0.3.14).
411
- *
412
- * @param page_index - Zero-based page number
413
- * @param region - Optional [x, y, width, height] to filter by
414
- */
415
- extractTables(page_index: number, region?: Float32Array | null): any;
416
- /**
417
- * Get the MediaBox of a page as [llx, lly, urx, ury].
418
- */
419
- pageMediaBox(page_index: number): Float32Array;
420
- /**
421
- * Identify and remove footers.
422
- *
423
- * Uses spec-compliant /Artifact tags when available (100% accuracy), or
424
- * falls back to heuristic analysis of the bottom 15% of pages.
425
- *
426
- * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
427
- */
428
- removeFooters(threshold: number): number;
429
- /**
430
- * Identify and remove headers.
431
- *
432
- * Uses spec-compliant /Artifact tags when available (100% accuracy), or
433
- * falls back to heuristic analysis of the top 15% of pages.
434
- *
435
- * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
436
- */
437
- removeHeaders(threshold: number): number;
438
- /**
439
- * Validate PDF/A compliance. Level: "1b", "2b", etc.
440
- */
441
- validatePdfA(level: string): any;
442
- /**
443
- * Erase both header and footer content.
444
- *
445
- * @param page_index - Zero-based page number
446
- */
447
- eraseArtifacts(page_index: number): void;
448
- /**
449
- * Get annotations from a page.
450
- *
451
- * @param page_index - Zero-based page number
452
- * @returns Array of annotation objects with fields like subtype, rect, contents, etc.
453
- */
454
- getAnnotations(page_index: number): any;
455
- /**
456
- * Get all form fields from the document.
457
- *
458
- * Returns an array of form field objects, each with:
459
- * - name: Full qualified field name
460
- * - field_type: "text", "button", "choice", "signature", or "unknown"
461
- * - value: string, boolean, array of strings, or null
462
- * - tooltip: string or null
463
- * - bounds: [x1, y1, x2, y2] or null
464
- * - flags: number or null
465
- * - max_length: number or null
466
- * - is_readonly: boolean
467
- * - is_required: boolean
468
- */
469
- getFormFields(): any;
470
- /**
471
- * Convert all pages to Markdown.
472
- */
473
- toMarkdownAll(detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
474
- /**
475
- * Export form field data as FDF or XFDF bytes.
476
- *
477
- * @param format - "fdf" or "xfdf" (default: "fdf")
478
- * @returns Uint8Array containing the exported form data
479
- */
480
- exportFormData(format?: string | null): Uint8Array;
481
- /**
482
- * Extract plain text from all pages, separated by form feed characters.
483
- */
484
- extractAllText(): string;
485
- /**
486
- * Extract text using OCR (optical character recognition).
487
- *
488
- * NOTE: OCR is not yet supported in the WebAssembly build due to missing
489
- * ONNX Runtime support for the web backend in the current implementation.
490
- */
491
- extractTextOcr(_page_index: number, _engine?: WasmOcrEngine | null): string;
492
- /**
493
- * Identify and remove both headers and footers.
494
- *
495
- * Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
496
- * fallback for untagged PDFs.
497
- *
498
- * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
499
- */
500
- removeArtifacts(threshold: number): number;
501
- /**
502
- * Reposition an image on a page.
503
- */
504
- repositionImage(page_index: number, name: string, x: number, y: number): void;
505
- /**
506
- * Rotate all pages by the given degrees.
507
- */
508
- rotateAllPages(degrees: number): void;
509
- /**
510
- * Set the complete bounds of an image on a page.
511
- */
512
- setImageBounds(page_index: number, name: string, x: number, y: number, width: number, height: number): void;
513
- /**
514
- * Set the CropBox of a page.
515
- */
516
- setPageCropBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
517
- /**
518
- * Set the rotation of a page (0, 90, 180, or 270 degrees).
519
- */
520
- setPageRotation(page_index: number, degrees: number): void;
521
- /**
522
- * Convert all pages to plain text.
523
- */
524
- toPlainTextAll(): string;
525
- /**
526
- * Extract text lines from a page.
527
- *
528
- * Returns an array of objects with: text, bbox, words (array of Word objects).
529
- */
530
- extractTextLines(page_index: number, region?: Float32Array | null): any;
531
- /**
532
- * Check if the document has a structure tree (Tagged PDF).
533
- */
534
- hasStructureTree(): boolean;
535
- /**
536
- * Set the MediaBox of a page.
537
- */
538
- setPageMediaBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
539
- /**
540
- * Clear all pending erase operations for a page.
541
- */
542
- clearEraseRegions(page_index: number): void;
543
- /**
544
- * Extract image bytes from a page as PNG data.
545
- *
546
- * Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
547
- */
548
- extractImageBytes(page_index: number): any;
549
- /**
550
- * Apply all redactions in the document.
551
- */
552
- applyAllRedactions(): void;
553
- /**
554
- * Get the value of a specific form field by name.
555
- *
556
- * @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
557
- * @returns The field value: string for text, boolean for checkbox, null if not found
558
- */
559
- getFormFieldValue(name: string): any;
560
- /**
561
- * Set the value of a form field.
562
- *
563
- * @param name - Full qualified field name
564
- * @param value - New value: string for text fields, boolean for checkboxes
565
- */
566
- setFormFieldValue(name: string, value: any): void;
567
- /**
568
- * Apply redactions on a page (removes redacted content permanently).
569
- */
570
- applyPageRedactions(page_index: number): void;
571
- /**
572
- * Flatten form fields on a specific page.
573
- *
574
- * @param page_index - Zero-based page number
575
- */
576
- flattenFormsOnPage(page_index: number): void;
577
- /**
578
- * Flatten all annotations in the document into page content.
579
- */
580
- flattenAllAnnotations(): void;
581
- /**
582
- * Save with encryption and return the resulting PDF as bytes.
583
- */
584
- saveEncryptedToBytes(user_password: string, owner_password?: string | null, allow_print?: boolean | null, allow_copy?: boolean | null, allow_modify?: boolean | null, allow_annotate?: boolean | null): Uint8Array;
585
- /**
586
- * Flatten annotations on a page into the page content.
587
- */
588
- flattenPageAnnotations(page_index: number): void;
589
- /**
590
- * Load a PDF document from raw bytes.
591
- *
592
- * @param data - PDF file contents as Uint8Array
593
- * @param password - Optional password for encrypted PDFs
594
- * @throws Error if the PDF is invalid or cannot be parsed
595
- */
596
- constructor(data: Uint8Array, password?: string | null);
597
- /**
598
- * Save all edits and return the resulting PDF as bytes.
599
- *
600
- * @returns Uint8Array containing the modified PDF
601
- */
602
- save(): Uint8Array;
603
- /**
604
- * Search for text across all pages.
605
- *
606
- * @param pattern - Regex pattern or literal text to search for
607
- * @param case_insensitive - Case insensitive search (default: false)
608
- * @param literal - Treat pattern as literal text, not regex (default: false)
609
- * @param whole_word - Match whole words only (default: false)
610
- * @param max_results - Maximum results to return, 0 = unlimited (default: 0)
611
- *
612
- * Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
613
- */
614
- search(pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
615
- /**
616
- * Focus extraction on a specific rectangular region of a page (v0.3.14).
617
- *
618
- * @param page_index - Zero-based page number
619
- * @param region - [x, y, width, height] in points
620
- */
621
- within(page_index: number, region: Float32Array): WasmPdfPageRegion;
622
- /**
623
- * Check if the document contains XFA form data.
624
- *
625
- * @returns true if the document has XFA form data
626
- */
627
- hasXfa(): boolean;
628
- /**
629
- * Convert a single page to HTML.
630
- *
631
- * @param page_index - Zero-based page number
632
- * @param preserve_layout - Use CSS positioning to preserve layout (default: false)
633
- * @param detect_headings - Whether to detect headings (default: true)
634
- */
635
- toHtml(page_index: number, preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
636
- /**
637
- * Get the PDF version as [major, minor].
638
- */
639
- version(): Uint8Array;
640
- /**
641
- * Set the document title.
642
- */
643
- setTitle(title: string): void;
260
+ free(): void;
261
+ [Symbol.dispose](): void;
262
+ /**
263
+ * Apply all redactions in the document.
264
+ */
265
+ applyAllRedactions(): void;
266
+ /**
267
+ * Apply redactions on a page (removes redacted content permanently).
268
+ */
269
+ applyPageRedactions(page_index: number): void;
270
+ /**
271
+ * Authenticate with a password to decrypt an encrypted PDF.
272
+ *
273
+ * @param password - The password string
274
+ * @returns true if authentication succeeded
275
+ */
276
+ authenticate(password: string): boolean;
277
+ /**
278
+ * Clear all pending erase operations for a page.
279
+ */
280
+ clearEraseRegions(page_index: number): void;
281
+ /**
282
+ * Crop margins from all pages.
283
+ */
284
+ cropMargins(left: number, right: number, top: number, bottom: number): void;
285
+ /**
286
+ * Delete a page by index (0-based).
287
+ */
288
+ deletePage(index: number): void;
289
+ /**
290
+ * Deprecated: Use eraseFooter instead.
291
+ */
292
+ editFooter(page_index: number): void;
293
+ /**
294
+ * Deprecated: Use eraseHeader instead.
295
+ */
296
+ editHeader(page_index: number): void;
297
+ /**
298
+ * Embed a file into the PDF document.
299
+ *
300
+ * @param name - Display name for the embedded file
301
+ * @param data - File contents as a Uint8Array
302
+ */
303
+ embedFile(name: string, data: Uint8Array): void;
304
+ /**
305
+ * Erase both header and footer content.
306
+ *
307
+ * @param page_index - Zero-based page number
308
+ */
309
+ eraseArtifacts(page_index: number): void;
310
+ /**
311
+ * Erase existing footer content.
312
+ *
313
+ * Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
314
+ *
315
+ * @param page_index - Zero-based page number
316
+ */
317
+ eraseFooter(page_index: number): void;
318
+ /**
319
+ * Erase existing header content.
320
+ *
321
+ * Identifies existing text in the header area (top 15%) and marks it for erasure.
322
+ *
323
+ * @param page_index - Zero-based page number
324
+ */
325
+ eraseHeader(page_index: number): void;
326
+ /**
327
+ * Erase (whiteout) a rectangular region on a page.
328
+ */
329
+ eraseRegion(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
330
+ /**
331
+ * Erase multiple rectangular regions on a page.
332
+ *
333
+ * @param page_index - Zero-based page number
334
+ * @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
335
+ */
336
+ eraseRegions(page_index: number, rects: Float32Array): void;
337
+ /**
338
+ * Export form field data as FDF or XFDF bytes.
339
+ *
340
+ * @param format - "fdf" or "xfdf" (default: "fdf")
341
+ * @returns Uint8Array containing the exported form data
342
+ */
343
+ exportFormData(format?: string | null): Uint8Array;
344
+ /**
345
+ * Extract plain text from all pages, separated by form feed characters.
346
+ */
347
+ extractAllText(): string;
348
+ /**
349
+ * Extract character-level data from a page.
350
+ *
351
+ * Returns an array of objects with: char, bbox {x, y, width, height},
352
+ * font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
353
+ *
354
+ * @param page_index - Zero-based page number
355
+ * @param region - Optional [x, y, width, height] to filter by
356
+ */
357
+ extractChars(page_index: number, region?: Float32Array | null): any;
358
+ /**
359
+ * Extract image bytes from a page as PNG data.
360
+ *
361
+ * Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
362
+ */
363
+ extractImageBytes(page_index: number): any;
364
+ /**
365
+ * Extract image metadata from a page.
366
+ *
367
+ * Returns an array of objects with: width, height, color_space,
368
+ * bits_per_component, bbox (if available). Does NOT return raw image bytes.
369
+ *
370
+ * @param page_index - Zero-based page number
371
+ * @param region - Optional [x, y, width, height] to filter by
372
+ */
373
+ extractImages(page_index: number, region?: Float32Array | null): any;
374
+ /**
375
+ * Extract only straight lines from a page (v0.3.14).
376
+ *
377
+ * Identifies paths that form a single straight line segment.
378
+ *
379
+ * @param page_index - Zero-based page number
380
+ * @param region - Optional [x, y, width, height] to filter by
381
+ * @returns Array of path objects
382
+ */
383
+ extractLines(page_index: number, region?: Float32Array | null): any;
384
+ /**
385
+ * Extract complete page text data in a single call.
386
+ *
387
+ * Returns `{ spans, chars, page_width, page_height }`.
388
+ * The `chars` are derived from spans using font-metric widths when available.
389
+ *
390
+ * Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
391
+ * or `"top_to_bottom"` (default).
392
+ */
393
+ extractPageText(page_index: number, reading_order?: string | null): any;
394
+ /**
395
+ * Extract specific pages to a new PDF (returns bytes).
396
+ */
397
+ extractPages(pages: Uint32Array): Uint8Array;
398
+ /**
399
+ * Extract vector paths (lines, curves, shapes) from a page.
400
+ *
401
+ * @param page_index - Zero-based page number
402
+ * @param region - Optional [x, y, width, height] to filter by
403
+ * @returns Array of path objects with bbox, stroke_color, fill_color, etc.
404
+ */
405
+ extractPaths(page_index: number, region?: Float32Array | null): any;
406
+ /**
407
+ * Extract only rectangles from a page (v0.3.14).
408
+ *
409
+ * Identifies paths that form axis-aligned rectangles.
410
+ *
411
+ * @param page_index - Zero-based page number
412
+ * @param region - Optional [x, y, width, height] to filter by
413
+ * @returns Array of path objects
414
+ */
415
+ extractRects(page_index: number, region?: Float32Array | null): any;
416
+ /**
417
+ * Extract span-level data from a page.
418
+ *
419
+ * Returns an array of objects with: text, bbox, font_name, font_size,
420
+ * font_weight, is_italic, color, etc.
421
+ *
422
+ * Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
423
+ * or `"top_to_bottom"` (default).
424
+ */
425
+ extractSpans(page_index: number, region?: Float32Array | null, reading_order?: string | null): any;
426
+ /**
427
+ * Extract tables from a page (v0.3.14).
428
+ *
429
+ * @param page_index - Zero-based page number
430
+ * @param region - Optional [x, y, width, height] to filter by
431
+ */
432
+ extractTables(page_index: number, region?: Float32Array | null): any;
433
+ /**
434
+ * Extract plain text from a single page.
435
+ *
436
+ * @param page_index - Zero-based page number
437
+ * @param region - Optional [x, y, width, height] to filter by
438
+ */
439
+ extractText(page_index: number, region: any): string;
440
+ /**
441
+ * Extract text lines from a page.
442
+ *
443
+ * Returns an array of objects with: text, bbox, words (array of Word objects).
444
+ */
445
+ extractTextLines(page_index: number, region?: Float32Array | null): any;
446
+ /**
447
+ * Extract text using OCR (optical character recognition).
448
+ *
449
+ * NOTE: OCR is not yet supported in the WebAssembly build due to missing
450
+ * ONNX Runtime support for the web backend in the current implementation.
451
+ */
452
+ extractTextOcr(_page_index: number, _engine?: WasmOcrEngine | null): string;
453
+ /**
454
+ * Extract word-level data from a page.
455
+ *
456
+ * Returns an array of objects with: text, bbox, font_name, font_size,
457
+ * font_weight, is_italic, is_bold.
458
+ */
459
+ extractWords(page_index: number, region?: Float32Array | null): any;
460
+ /**
461
+ * Flatten all annotations in the document into page content.
462
+ */
463
+ flattenAllAnnotations(): void;
464
+ /**
465
+ * Flatten all form fields into page content.
466
+ *
467
+ * After flattening, form field values become static text and are no longer editable.
468
+ */
469
+ flattenForms(): void;
470
+ /**
471
+ * Flatten form fields on a specific page.
472
+ *
473
+ * @param page_index - Zero-based page number
474
+ */
475
+ flattenFormsOnPage(page_index: number): void;
476
+ /**
477
+ * Flatten annotations on a page into the page content.
478
+ */
479
+ flattenPageAnnotations(page_index: number): void;
480
+ /**
481
+ * Get annotations from a page.
482
+ *
483
+ * @param page_index - Zero-based page number
484
+ * @returns Array of annotation objects with fields like subtype, rect, contents, etc.
485
+ */
486
+ getAnnotations(page_index: number): any;
487
+ /**
488
+ * Get the value of a specific form field by name.
489
+ *
490
+ * @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
491
+ * @returns The field value: string for text, boolean for checkbox, null if not found
492
+ */
493
+ getFormFieldValue(name: string): any;
494
+ /**
495
+ * Get all form fields from the document.
496
+ *
497
+ * Returns an array of form field objects, each with:
498
+ * - name: Full qualified field name
499
+ * - field_type: "text", "button", "choice", "signature", or "unknown"
500
+ * - value: string, boolean, array of strings, or null
501
+ * - tooltip: string or null
502
+ * - bounds: [x1, y1, x2, y2] or null
503
+ * - flags: number or null
504
+ * - max_length: number or null
505
+ * - is_readonly: boolean
506
+ * - is_required: boolean
507
+ */
508
+ getFormFields(): any;
509
+ /**
510
+ * Get the document outline (bookmarks / table of contents).
511
+ *
512
+ * @returns Array of outline items or null if no outline exists.
513
+ * Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
514
+ */
515
+ getOutline(): any;
516
+ /**
517
+ * Check if the document has a structure tree (Tagged PDF).
518
+ */
519
+ hasStructureTree(): boolean;
520
+ /**
521
+ * Check if the document contains XFA form data.
522
+ *
523
+ * @returns true if the document has XFA form data
524
+ */
525
+ hasXfa(): boolean;
526
+ /**
527
+ * Merge another PDF (provided as bytes) into this document.
528
+ *
529
+ * @param data - The PDF file contents to merge as a Uint8Array
530
+ * @returns Number of pages merged
531
+ */
532
+ mergeFrom(data: Uint8Array): number;
533
+ /**
534
+ * Load a PDF document from raw bytes.
535
+ *
536
+ * @param data - PDF file contents as Uint8Array
537
+ * @param password - Optional password for encrypted PDFs
538
+ * @throws Error if the PDF is invalid or cannot be parsed
539
+ */
540
+ constructor(data: Uint8Array, password?: string | null);
541
+ /**
542
+ * Get the number of pages in the document.
543
+ */
544
+ pageCount(): number;
545
+ /**
546
+ * Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
547
+ */
548
+ pageCropBox(page_index: number): any;
549
+ /**
550
+ * Get information about images on a page.
551
+ *
552
+ * Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
553
+ */
554
+ pageImages(page_index: number): any;
555
+ /**
556
+ * Get page label ranges from the document.
557
+ *
558
+ * @returns Array of {start_page, style, prefix, start_value} objects, or empty array
559
+ */
560
+ pageLabels(): any;
561
+ /**
562
+ * Get the MediaBox of a page as [llx, lly, urx, ury].
563
+ */
564
+ pageMediaBox(page_index: number): Float32Array;
565
+ /**
566
+ * Get the rotation of a page in degrees (0, 90, 180, 270).
567
+ */
568
+ pageRotation(page_index: number): number;
569
+ /**
570
+ * Identify and remove both headers and footers.
571
+ *
572
+ * Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
573
+ * fallback for untagged PDFs.
574
+ *
575
+ * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
576
+ */
577
+ removeArtifacts(threshold: number): number;
578
+ /**
579
+ * Identify and remove footers.
580
+ *
581
+ * Uses spec-compliant /Artifact tags when available (100% accuracy), or
582
+ * falls back to heuristic analysis of the bottom 15% of pages.
583
+ *
584
+ * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
585
+ */
586
+ removeFooters(threshold: number): number;
587
+ /**
588
+ * Identify and remove headers.
589
+ *
590
+ * Uses spec-compliant /Artifact tags when available (100% accuracy), or
591
+ * falls back to heuristic analysis of the top 15% of pages.
592
+ *
593
+ * @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
594
+ */
595
+ removeHeaders(threshold: number): number;
596
+ /**
597
+ * Reposition an image on a page.
598
+ */
599
+ repositionImage(page_index: number, name: string, x: number, y: number): void;
600
+ /**
601
+ * Resize an image on a page.
602
+ */
603
+ resizeImage(page_index: number, name: string, width: number, height: number): void;
604
+ /**
605
+ * Rotate all pages by the given degrees.
606
+ */
607
+ rotateAllPages(degrees: number): void;
608
+ /**
609
+ * Rotate a page by the given degrees (adds to current rotation).
610
+ */
611
+ rotatePage(page_index: number, degrees: number): void;
612
+ /**
613
+ * Save all edits and return the resulting PDF as bytes.
614
+ *
615
+ * @returns Uint8Array containing the modified PDF
616
+ */
617
+ save(): Uint8Array;
618
+ /**
619
+ * Save with encryption and return the resulting PDF as bytes.
620
+ */
621
+ saveEncryptedToBytes(user_password: string, owner_password?: string | null, allow_print?: boolean | null, allow_copy?: boolean | null, allow_modify?: boolean | null, allow_annotate?: boolean | null): Uint8Array;
622
+ /**
623
+ * Save the modified PDF and return as bytes.
624
+ * `saveToBytes()` is the original method; `save()` is a convenience alias.
625
+ *
626
+ * @returns Uint8Array containing the modified PDF
627
+ */
628
+ saveToBytes(): Uint8Array;
629
+ /**
630
+ * Search for text across all pages.
631
+ *
632
+ * @param pattern - Regex pattern or literal text to search for
633
+ * @param case_insensitive - Case insensitive search (default: false)
634
+ * @param literal - Treat pattern as literal text, not regex (default: false)
635
+ * @param whole_word - Match whole words only (default: false)
636
+ * @param max_results - Maximum results to return, 0 = unlimited (default: 0)
637
+ *
638
+ * Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
639
+ */
640
+ search(pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
641
+ /**
642
+ * Search for text on a specific page.
643
+ */
644
+ searchPage(page_index: number, pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
645
+ /**
646
+ * Set the document author.
647
+ */
648
+ setAuthor(author: string): void;
649
+ /**
650
+ * Set the value of a form field.
651
+ *
652
+ * @param name - Full qualified field name
653
+ * @param value - New value: string for text fields, boolean for checkboxes
654
+ */
655
+ setFormFieldValue(name: string, value: any): void;
656
+ /**
657
+ * Set the complete bounds of an image on a page.
658
+ */
659
+ setImageBounds(page_index: number, name: string, x: number, y: number, width: number, height: number): void;
660
+ /**
661
+ * Set the document keywords.
662
+ */
663
+ setKeywords(keywords: string): void;
664
+ /**
665
+ * Set the CropBox of a page.
666
+ */
667
+ setPageCropBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
668
+ /**
669
+ * Set the MediaBox of a page.
670
+ */
671
+ setPageMediaBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
672
+ /**
673
+ * Set the rotation of a page (0, 90, 180, or 270 degrees).
674
+ */
675
+ setPageRotation(page_index: number, degrees: number): void;
676
+ /**
677
+ * Set the document subject.
678
+ */
679
+ setSubject(subject: string): void;
680
+ /**
681
+ * Set the document title.
682
+ */
683
+ setTitle(title: string): void;
684
+ /**
685
+ * Convert a single page to HTML.
686
+ *
687
+ * @param page_index - Zero-based page number
688
+ * @param preserve_layout - Use CSS positioning to preserve layout (default: false)
689
+ * @param detect_headings - Whether to detect headings (default: true)
690
+ */
691
+ toHtml(page_index: number, preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
692
+ /**
693
+ * Convert all pages to HTML.
694
+ */
695
+ toHtmlAll(preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
696
+ /**
697
+ * Convert a single page to Markdown.
698
+ *
699
+ * @param page_index - Zero-based page number
700
+ * @param detect_headings - Whether to detect headings (default: true)
701
+ * @param include_images - Whether to include images (default: false)
702
+ */
703
+ toMarkdown(page_index: number, detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
704
+ /**
705
+ * Convert all pages to Markdown.
706
+ */
707
+ toMarkdownAll(detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
708
+ /**
709
+ * Convert a single page to plain text (with layout preservation options).
710
+ */
711
+ toPlainText(page_index: number): string;
712
+ /**
713
+ * Convert all pages to plain text.
714
+ */
715
+ toPlainTextAll(): string;
716
+ /**
717
+ * Validate PDF/A compliance. Level: "1b", "2b", etc.
718
+ */
719
+ validatePdfA(level: string): any;
720
+ /**
721
+ * Get the PDF version as [major, minor].
722
+ */
723
+ version(): Uint8Array;
724
+ /**
725
+ * Focus extraction on a specific rectangular region of a page (v0.3.14).
726
+ *
727
+ * @param page_index - Zero-based page number
728
+ * @param region - [x, y, width, height] in points
729
+ */
730
+ within(page_index: number, region: Float32Array): WasmPdfPageRegion;
731
+ /**
732
+ * Get XMP metadata from the document.
733
+ *
734
+ * @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
735
+ */
736
+ xmpMetadata(): any;
644
737
  }
645
738
 
739
+ /**
740
+ * A focused view of a PDF page region for scoped extraction (v0.3.14).
741
+ */
646
742
  export class WasmPdfPageRegion {
647
- private constructor();
648
- free(): void;
649
- [Symbol.dispose](): void;
650
- /**
651
- * Extract text from this region.
652
- */
653
- extractText(): string;
654
- /**
655
- * Extract character-level data from this region.
656
- */
657
- extractChars(): any;
658
- /**
659
- * Extract straight lines from this region.
660
- */
661
- extractLines(): any;
662
- /**
663
- * Extract vector paths from this region.
664
- */
665
- extractPaths(): any;
666
- /**
667
- * Extract rectangles from this region.
668
- */
669
- extractRects(): any;
670
- /**
671
- * Extract words from this region.
672
- */
673
- extractWords(): any;
674
- /**
675
- * Extract images from this region.
676
- */
677
- extractImages(): any;
678
- /**
679
- * Extract tables from this region.
680
- */
681
- extractTables(): any;
682
- /**
683
- * Extract text using OCR from this region.
684
- */
685
- extractTextOcr(_engine?: WasmOcrEngine | null): string;
686
- /**
687
- * Extract text lines from this region.
688
- */
689
- extractTextLines(): any;
743
+ private constructor();
744
+ free(): void;
745
+ [Symbol.dispose](): void;
746
+ /**
747
+ * Extract character-level data from this region.
748
+ */
749
+ extractChars(): any;
750
+ /**
751
+ * Extract images from this region.
752
+ */
753
+ extractImages(): any;
754
+ /**
755
+ * Extract straight lines from this region.
756
+ */
757
+ extractLines(): any;
758
+ /**
759
+ * Extract vector paths from this region.
760
+ */
761
+ extractPaths(): any;
762
+ /**
763
+ * Extract rectangles from this region.
764
+ */
765
+ extractRects(): any;
766
+ /**
767
+ * Extract tables from this region.
768
+ */
769
+ extractTables(): any;
770
+ /**
771
+ * Extract text from this region.
772
+ */
773
+ extractText(): string;
774
+ /**
775
+ * Extract text lines from this region.
776
+ */
777
+ extractTextLines(): any;
778
+ /**
779
+ * Extract text using OCR from this region.
780
+ */
781
+ extractTextOcr(_engine?: WasmOcrEngine | null): string;
782
+ /**
783
+ * Extract words from this region.
784
+ */
785
+ extractWords(): any;
690
786
  }
787
+
788
+ /**
789
+ * Disable all pdf_oxide log output — convenience wrapper for
790
+ * `setLogLevel("off")`.
791
+ */
792
+ export function disableLogging(): void;
793
+
794
+ /**
795
+ * Set the maximum log level for pdf_oxide messages.
796
+ *
797
+ * Accepts one of: `"off"`, `"error"`, `"warn"` / `"warning"`, `"info"`,
798
+ * `"debug"`, `"trace"`. Case-insensitive. Default is `"off"` — the library
799
+ * is silent unless explicitly enabled.
800
+ *
801
+ * Logs are forwarded to the browser console (`console.log`, `console.warn`,
802
+ * `console.error`, etc.). Fixes issue #280.
803
+ *
804
+ * @example
805
+ * ```javascript
806
+ * import init, { setLogLevel } from "pdf-oxide-wasm";
807
+ * await init();
808
+ * setLogLevel("warn");
809
+ * ```
810
+ */
811
+ export function setLogLevel(level: string): void;