pdf-oxide-wasm 0.3.14 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pdf_oxide.d.ts +111 -0
- package/pdf_oxide.js +491 -1
- package/pdf_oxide_bg.wasm +0 -0
- package/pdf_oxide_bg.wasm.d.ts +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-oxide-wasm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "Fast, zero-dependency PDF toolkit for Node.js, browsers, and edge runtimes — text extraction, markdown/HTML conversion, search, form filling, creation, and editing. Rust core compiled to WebAssembly.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
package/pdf_oxide.d.ts
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Style configuration for header/footer text.
|
|
6
|
+
*/
|
|
7
|
+
export class ArtifactStyle {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
bold(): ArtifactStyle;
|
|
11
|
+
color(r: number, g: number, b: number): ArtifactStyle;
|
|
12
|
+
font(name: string, size: number): ArtifactStyle;
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A header or footer artifact definition.
|
|
18
|
+
*/
|
|
19
|
+
export class WasmArtifact {
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
static center(text: string): WasmArtifact;
|
|
23
|
+
static left(text: string): WasmArtifact;
|
|
24
|
+
constructor();
|
|
25
|
+
static right(text: string): WasmArtifact;
|
|
26
|
+
withOffset(offset: number): WasmArtifact;
|
|
27
|
+
withStyle(style: ArtifactStyle): WasmArtifact;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A footer definition.
|
|
32
|
+
*/
|
|
33
|
+
export class WasmFooter {
|
|
34
|
+
free(): void;
|
|
35
|
+
[Symbol.dispose](): void;
|
|
36
|
+
static center(text: string): WasmFooter;
|
|
37
|
+
static left(text: string): WasmFooter;
|
|
38
|
+
constructor();
|
|
39
|
+
static right(text: string): WasmFooter;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A header definition.
|
|
44
|
+
*/
|
|
45
|
+
export class WasmHeader {
|
|
46
|
+
free(): void;
|
|
47
|
+
[Symbol.dispose](): void;
|
|
48
|
+
static center(text: string): WasmHeader;
|
|
49
|
+
static left(text: string): WasmHeader;
|
|
50
|
+
constructor();
|
|
51
|
+
static right(text: string): WasmHeader;
|
|
52
|
+
}
|
|
53
|
+
|
|
4
54
|
/**
|
|
5
55
|
* OCR configuration for WebAssembly.
|
|
6
56
|
*/
|
|
@@ -19,6 +69,18 @@ export class WasmOcrEngine {
|
|
|
19
69
|
constructor(_det_model_path: string, _rec_model_path: string, _dict_path: string, _config?: WasmOcrConfig | null);
|
|
20
70
|
}
|
|
21
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A complete page template with header and footer.
|
|
74
|
+
*/
|
|
75
|
+
export class WasmPageTemplate {
|
|
76
|
+
free(): void;
|
|
77
|
+
[Symbol.dispose](): void;
|
|
78
|
+
footer(footer: WasmArtifact): WasmPageTemplate;
|
|
79
|
+
header(header: WasmArtifact): WasmPageTemplate;
|
|
80
|
+
constructor();
|
|
81
|
+
skipFirstPage(): WasmPageTemplate;
|
|
82
|
+
}
|
|
83
|
+
|
|
22
84
|
/**
|
|
23
85
|
* Create new PDF documents from Markdown, HTML, or plain text.
|
|
24
86
|
*
|
|
@@ -119,6 +181,28 @@ export class WasmPdfDocument {
|
|
|
119
181
|
* @param data - File contents as a Uint8Array
|
|
120
182
|
*/
|
|
121
183
|
embedFile(name: string, data: Uint8Array): void;
|
|
184
|
+
/**
|
|
185
|
+
* Erase both header and footer content.
|
|
186
|
+
*
|
|
187
|
+
* @param page_index - Zero-based page number
|
|
188
|
+
*/
|
|
189
|
+
eraseArtifacts(page_index: number): void;
|
|
190
|
+
/**
|
|
191
|
+
* Erase existing footer content.
|
|
192
|
+
*
|
|
193
|
+
* Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
|
|
194
|
+
*
|
|
195
|
+
* @param page_index - Zero-based page number
|
|
196
|
+
*/
|
|
197
|
+
eraseFooter(page_index: number): void;
|
|
198
|
+
/**
|
|
199
|
+
* Erase existing header content.
|
|
200
|
+
*
|
|
201
|
+
* Identifies existing text in the header area (top 15%) and marks it for erasure.
|
|
202
|
+
*
|
|
203
|
+
* @param page_index - Zero-based page number
|
|
204
|
+
*/
|
|
205
|
+
eraseHeader(page_index: number): void;
|
|
122
206
|
/**
|
|
123
207
|
* Erase (whiteout) a rectangular region on a page.
|
|
124
208
|
*/
|
|
@@ -344,6 +428,33 @@ export class WasmPdfDocument {
|
|
|
344
428
|
* Get the rotation of a page in degrees (0, 90, 180, 270).
|
|
345
429
|
*/
|
|
346
430
|
pageRotation(page_index: number): number;
|
|
431
|
+
/**
|
|
432
|
+
* Identify and remove both headers and footers.
|
|
433
|
+
*
|
|
434
|
+
* Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
|
|
435
|
+
* fallback for untagged PDFs.
|
|
436
|
+
*
|
|
437
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
438
|
+
*/
|
|
439
|
+
removeArtifacts(threshold: number): number;
|
|
440
|
+
/**
|
|
441
|
+
* Identify and remove footers.
|
|
442
|
+
*
|
|
443
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
444
|
+
* falls back to heuristic analysis of the bottom 15% of pages.
|
|
445
|
+
*
|
|
446
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
447
|
+
*/
|
|
448
|
+
removeFooters(threshold: number): number;
|
|
449
|
+
/**
|
|
450
|
+
* Identify and remove headers.
|
|
451
|
+
*
|
|
452
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
453
|
+
* falls back to heuristic analysis of the top 15% of pages.
|
|
454
|
+
*
|
|
455
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
456
|
+
*/
|
|
457
|
+
removeHeaders(threshold: number): number;
|
|
347
458
|
/**
|
|
348
459
|
* Reposition an image on a page.
|
|
349
460
|
*/
|
package/pdf_oxide.js
CHANGED
|
@@ -1,5 +1,269 @@
|
|
|
1
1
|
/* @ts-self-types="./pdf_oxide.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Style configuration for header/footer text.
|
|
5
|
+
*/
|
|
6
|
+
class ArtifactStyle {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
ptr = ptr >>> 0;
|
|
9
|
+
const obj = Object.create(ArtifactStyle.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
ArtifactStyleFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
ArtifactStyleFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_artifactstyle_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @returns {ArtifactStyle}
|
|
26
|
+
*/
|
|
27
|
+
bold() {
|
|
28
|
+
const ptr = this.__destroy_into_raw();
|
|
29
|
+
const ret = wasm.wasmartifactstyle_bold(ptr);
|
|
30
|
+
return ArtifactStyle.__wrap(ret);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} r
|
|
34
|
+
* @param {number} g
|
|
35
|
+
* @param {number} b
|
|
36
|
+
* @returns {ArtifactStyle}
|
|
37
|
+
*/
|
|
38
|
+
color(r, g, b) {
|
|
39
|
+
const ptr = this.__destroy_into_raw();
|
|
40
|
+
const ret = wasm.wasmartifactstyle_color(ptr, r, g, b);
|
|
41
|
+
return ArtifactStyle.__wrap(ret);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} name
|
|
45
|
+
* @param {number} size
|
|
46
|
+
* @returns {ArtifactStyle}
|
|
47
|
+
*/
|
|
48
|
+
font(name, size) {
|
|
49
|
+
const ptr = this.__destroy_into_raw();
|
|
50
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.wasmartifactstyle_font(ptr, ptr0, len0, size);
|
|
53
|
+
return ArtifactStyle.__wrap(ret);
|
|
54
|
+
}
|
|
55
|
+
constructor() {
|
|
56
|
+
const ret = wasm.wasmartifactstyle_new();
|
|
57
|
+
this.__wbg_ptr = ret >>> 0;
|
|
58
|
+
ArtifactStyleFinalization.register(this, this.__wbg_ptr, this);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (Symbol.dispose) ArtifactStyle.prototype[Symbol.dispose] = ArtifactStyle.prototype.free;
|
|
63
|
+
exports.ArtifactStyle = ArtifactStyle;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A header or footer artifact definition.
|
|
67
|
+
*/
|
|
68
|
+
class WasmArtifact {
|
|
69
|
+
static __wrap(ptr) {
|
|
70
|
+
ptr = ptr >>> 0;
|
|
71
|
+
const obj = Object.create(WasmArtifact.prototype);
|
|
72
|
+
obj.__wbg_ptr = ptr;
|
|
73
|
+
WasmArtifactFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
__destroy_into_raw() {
|
|
77
|
+
const ptr = this.__wbg_ptr;
|
|
78
|
+
this.__wbg_ptr = 0;
|
|
79
|
+
WasmArtifactFinalization.unregister(this);
|
|
80
|
+
return ptr;
|
|
81
|
+
}
|
|
82
|
+
free() {
|
|
83
|
+
const ptr = this.__destroy_into_raw();
|
|
84
|
+
wasm.__wbg_wasmartifact_free(ptr, 0);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @param {string} text
|
|
88
|
+
* @returns {WasmArtifact}
|
|
89
|
+
*/
|
|
90
|
+
static center(text) {
|
|
91
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
92
|
+
const len0 = WASM_VECTOR_LEN;
|
|
93
|
+
const ret = wasm.wasmartifact_center(ptr0, len0);
|
|
94
|
+
return WasmArtifact.__wrap(ret);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} text
|
|
98
|
+
* @returns {WasmArtifact}
|
|
99
|
+
*/
|
|
100
|
+
static left(text) {
|
|
101
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ret = wasm.wasmartifact_left(ptr0, len0);
|
|
104
|
+
return WasmArtifact.__wrap(ret);
|
|
105
|
+
}
|
|
106
|
+
constructor() {
|
|
107
|
+
const ret = wasm.wasmartifact_new();
|
|
108
|
+
this.__wbg_ptr = ret >>> 0;
|
|
109
|
+
WasmArtifactFinalization.register(this, this.__wbg_ptr, this);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} text
|
|
114
|
+
* @returns {WasmArtifact}
|
|
115
|
+
*/
|
|
116
|
+
static right(text) {
|
|
117
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.wasmartifact_right(ptr0, len0);
|
|
120
|
+
return WasmArtifact.__wrap(ret);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {number} offset
|
|
124
|
+
* @returns {WasmArtifact}
|
|
125
|
+
*/
|
|
126
|
+
withOffset(offset) {
|
|
127
|
+
const ptr = this.__destroy_into_raw();
|
|
128
|
+
const ret = wasm.wasmartifact_withOffset(ptr, offset);
|
|
129
|
+
return WasmArtifact.__wrap(ret);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {ArtifactStyle} style
|
|
133
|
+
* @returns {WasmArtifact}
|
|
134
|
+
*/
|
|
135
|
+
withStyle(style) {
|
|
136
|
+
const ptr = this.__destroy_into_raw();
|
|
137
|
+
_assertClass(style, ArtifactStyle);
|
|
138
|
+
const ret = wasm.wasmartifact_withStyle(ptr, style.__wbg_ptr);
|
|
139
|
+
return WasmArtifact.__wrap(ret);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (Symbol.dispose) WasmArtifact.prototype[Symbol.dispose] = WasmArtifact.prototype.free;
|
|
143
|
+
exports.WasmArtifact = WasmArtifact;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A footer definition.
|
|
147
|
+
*/
|
|
148
|
+
class WasmFooter {
|
|
149
|
+
static __wrap(ptr) {
|
|
150
|
+
ptr = ptr >>> 0;
|
|
151
|
+
const obj = Object.create(WasmFooter.prototype);
|
|
152
|
+
obj.__wbg_ptr = ptr;
|
|
153
|
+
WasmFooterFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
154
|
+
return obj;
|
|
155
|
+
}
|
|
156
|
+
__destroy_into_raw() {
|
|
157
|
+
const ptr = this.__wbg_ptr;
|
|
158
|
+
this.__wbg_ptr = 0;
|
|
159
|
+
WasmFooterFinalization.unregister(this);
|
|
160
|
+
return ptr;
|
|
161
|
+
}
|
|
162
|
+
free() {
|
|
163
|
+
const ptr = this.__destroy_into_raw();
|
|
164
|
+
wasm.__wbg_wasmfooter_free(ptr, 0);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @param {string} text
|
|
168
|
+
* @returns {WasmFooter}
|
|
169
|
+
*/
|
|
170
|
+
static center(text) {
|
|
171
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ret = wasm.wasmfooter_center(ptr0, len0);
|
|
174
|
+
return WasmFooter.__wrap(ret);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {string} text
|
|
178
|
+
* @returns {WasmFooter}
|
|
179
|
+
*/
|
|
180
|
+
static left(text) {
|
|
181
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
182
|
+
const len0 = WASM_VECTOR_LEN;
|
|
183
|
+
const ret = wasm.wasmfooter_left(ptr0, len0);
|
|
184
|
+
return WasmFooter.__wrap(ret);
|
|
185
|
+
}
|
|
186
|
+
constructor() {
|
|
187
|
+
const ret = wasm.wasmfooter_new();
|
|
188
|
+
this.__wbg_ptr = ret >>> 0;
|
|
189
|
+
WasmFooterFinalization.register(this, this.__wbg_ptr, this);
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @param {string} text
|
|
194
|
+
* @returns {WasmFooter}
|
|
195
|
+
*/
|
|
196
|
+
static right(text) {
|
|
197
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
198
|
+
const len0 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.wasmfooter_right(ptr0, len0);
|
|
200
|
+
return WasmFooter.__wrap(ret);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (Symbol.dispose) WasmFooter.prototype[Symbol.dispose] = WasmFooter.prototype.free;
|
|
204
|
+
exports.WasmFooter = WasmFooter;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* A header definition.
|
|
208
|
+
*/
|
|
209
|
+
class WasmHeader {
|
|
210
|
+
static __wrap(ptr) {
|
|
211
|
+
ptr = ptr >>> 0;
|
|
212
|
+
const obj = Object.create(WasmHeader.prototype);
|
|
213
|
+
obj.__wbg_ptr = ptr;
|
|
214
|
+
WasmHeaderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
215
|
+
return obj;
|
|
216
|
+
}
|
|
217
|
+
__destroy_into_raw() {
|
|
218
|
+
const ptr = this.__wbg_ptr;
|
|
219
|
+
this.__wbg_ptr = 0;
|
|
220
|
+
WasmHeaderFinalization.unregister(this);
|
|
221
|
+
return ptr;
|
|
222
|
+
}
|
|
223
|
+
free() {
|
|
224
|
+
const ptr = this.__destroy_into_raw();
|
|
225
|
+
wasm.__wbg_wasmheader_free(ptr, 0);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @param {string} text
|
|
229
|
+
* @returns {WasmHeader}
|
|
230
|
+
*/
|
|
231
|
+
static center(text) {
|
|
232
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
233
|
+
const len0 = WASM_VECTOR_LEN;
|
|
234
|
+
const ret = wasm.wasmheader_center(ptr0, len0);
|
|
235
|
+
return WasmHeader.__wrap(ret);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @param {string} text
|
|
239
|
+
* @returns {WasmHeader}
|
|
240
|
+
*/
|
|
241
|
+
static left(text) {
|
|
242
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
244
|
+
const ret = wasm.wasmheader_left(ptr0, len0);
|
|
245
|
+
return WasmHeader.__wrap(ret);
|
|
246
|
+
}
|
|
247
|
+
constructor() {
|
|
248
|
+
const ret = wasm.wasmheader_new();
|
|
249
|
+
this.__wbg_ptr = ret >>> 0;
|
|
250
|
+
WasmHeaderFinalization.register(this, this.__wbg_ptr, this);
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @param {string} text
|
|
255
|
+
* @returns {WasmHeader}
|
|
256
|
+
*/
|
|
257
|
+
static right(text) {
|
|
258
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.wasmheader_right(ptr0, len0);
|
|
261
|
+
return WasmHeader.__wrap(ret);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (Symbol.dispose) WasmHeader.prototype[Symbol.dispose] = WasmHeader.prototype.free;
|
|
265
|
+
exports.WasmHeader = WasmHeader;
|
|
266
|
+
|
|
3
267
|
/**
|
|
4
268
|
* OCR configuration for WebAssembly.
|
|
5
269
|
*/
|
|
@@ -76,6 +340,65 @@ class WasmOcrEngine {
|
|
|
76
340
|
if (Symbol.dispose) WasmOcrEngine.prototype[Symbol.dispose] = WasmOcrEngine.prototype.free;
|
|
77
341
|
exports.WasmOcrEngine = WasmOcrEngine;
|
|
78
342
|
|
|
343
|
+
/**
|
|
344
|
+
* A complete page template with header and footer.
|
|
345
|
+
*/
|
|
346
|
+
class WasmPageTemplate {
|
|
347
|
+
static __wrap(ptr) {
|
|
348
|
+
ptr = ptr >>> 0;
|
|
349
|
+
const obj = Object.create(WasmPageTemplate.prototype);
|
|
350
|
+
obj.__wbg_ptr = ptr;
|
|
351
|
+
WasmPageTemplateFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
352
|
+
return obj;
|
|
353
|
+
}
|
|
354
|
+
__destroy_into_raw() {
|
|
355
|
+
const ptr = this.__wbg_ptr;
|
|
356
|
+
this.__wbg_ptr = 0;
|
|
357
|
+
WasmPageTemplateFinalization.unregister(this);
|
|
358
|
+
return ptr;
|
|
359
|
+
}
|
|
360
|
+
free() {
|
|
361
|
+
const ptr = this.__destroy_into_raw();
|
|
362
|
+
wasm.__wbg_wasmpagetemplate_free(ptr, 0);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @param {WasmArtifact} footer
|
|
366
|
+
* @returns {WasmPageTemplate}
|
|
367
|
+
*/
|
|
368
|
+
footer(footer) {
|
|
369
|
+
const ptr = this.__destroy_into_raw();
|
|
370
|
+
_assertClass(footer, WasmArtifact);
|
|
371
|
+
const ret = wasm.wasmpagetemplate_footer(ptr, footer.__wbg_ptr);
|
|
372
|
+
return WasmPageTemplate.__wrap(ret);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @param {WasmArtifact} header
|
|
376
|
+
* @returns {WasmPageTemplate}
|
|
377
|
+
*/
|
|
378
|
+
header(header) {
|
|
379
|
+
const ptr = this.__destroy_into_raw();
|
|
380
|
+
_assertClass(header, WasmArtifact);
|
|
381
|
+
const ret = wasm.wasmpagetemplate_header(ptr, header.__wbg_ptr);
|
|
382
|
+
return WasmPageTemplate.__wrap(ret);
|
|
383
|
+
}
|
|
384
|
+
constructor() {
|
|
385
|
+
const ret = wasm.wasmpagetemplate_new();
|
|
386
|
+
this.__wbg_ptr = ret >>> 0;
|
|
387
|
+
WasmPageTemplateFinalization.register(this, this.__wbg_ptr, this);
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* @returns {WasmPageTemplate}
|
|
392
|
+
*/
|
|
393
|
+
skipFirstPage() {
|
|
394
|
+
const ptr = this.__destroy_into_raw();
|
|
395
|
+
const ret = wasm.wasmpagetemplate_skipFirstPage(ptr);
|
|
396
|
+
return WasmPageTemplate.__wrap(ret);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (Symbol.dispose) WasmPageTemplate.prototype[Symbol.dispose] = WasmPageTemplate.prototype.free;
|
|
400
|
+
exports.WasmPageTemplate = WasmPageTemplate;
|
|
401
|
+
|
|
79
402
|
/**
|
|
80
403
|
* Create new PDF documents from Markdown, HTML, or plain text.
|
|
81
404
|
*
|
|
@@ -413,6 +736,67 @@ class WasmPdfDocument {
|
|
|
413
736
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
414
737
|
}
|
|
415
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* Erase both header and footer content.
|
|
741
|
+
*
|
|
742
|
+
* @param page_index - Zero-based page number
|
|
743
|
+
* @param {number} page_index
|
|
744
|
+
*/
|
|
745
|
+
eraseArtifacts(page_index) {
|
|
746
|
+
try {
|
|
747
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
748
|
+
wasm.wasmpdfdocument_eraseArtifacts(retptr, this.__wbg_ptr, page_index);
|
|
749
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
750
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
751
|
+
if (r1) {
|
|
752
|
+
throw takeObject(r0);
|
|
753
|
+
}
|
|
754
|
+
} finally {
|
|
755
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Erase existing footer content.
|
|
760
|
+
*
|
|
761
|
+
* Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
|
|
762
|
+
*
|
|
763
|
+
* @param page_index - Zero-based page number
|
|
764
|
+
* @param {number} page_index
|
|
765
|
+
*/
|
|
766
|
+
eraseFooter(page_index) {
|
|
767
|
+
try {
|
|
768
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
769
|
+
wasm.wasmpdfdocument_eraseFooter(retptr, this.__wbg_ptr, page_index);
|
|
770
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
771
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
772
|
+
if (r1) {
|
|
773
|
+
throw takeObject(r0);
|
|
774
|
+
}
|
|
775
|
+
} finally {
|
|
776
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Erase existing header content.
|
|
781
|
+
*
|
|
782
|
+
* Identifies existing text in the header area (top 15%) and marks it for erasure.
|
|
783
|
+
*
|
|
784
|
+
* @param page_index - Zero-based page number
|
|
785
|
+
* @param {number} page_index
|
|
786
|
+
*/
|
|
787
|
+
eraseHeader(page_index) {
|
|
788
|
+
try {
|
|
789
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
790
|
+
wasm.wasmpdfdocument_eraseHeader(retptr, this.__wbg_ptr, page_index);
|
|
791
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
792
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
793
|
+
if (r1) {
|
|
794
|
+
throw takeObject(r0);
|
|
795
|
+
}
|
|
796
|
+
} finally {
|
|
797
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
416
800
|
/**
|
|
417
801
|
* Erase (whiteout) a rectangular region on a page.
|
|
418
802
|
* @param {number} page_index
|
|
@@ -1240,6 +1624,81 @@ class WasmPdfDocument {
|
|
|
1240
1624
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1241
1625
|
}
|
|
1242
1626
|
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Identify and remove both headers and footers.
|
|
1629
|
+
*
|
|
1630
|
+
* Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
|
|
1631
|
+
* fallback for untagged PDFs.
|
|
1632
|
+
*
|
|
1633
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1634
|
+
* @param {number} threshold
|
|
1635
|
+
* @returns {number}
|
|
1636
|
+
*/
|
|
1637
|
+
removeArtifacts(threshold) {
|
|
1638
|
+
try {
|
|
1639
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1640
|
+
wasm.wasmpdfdocument_removeArtifacts(retptr, this.__wbg_ptr, threshold);
|
|
1641
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1642
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1643
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1644
|
+
if (r2) {
|
|
1645
|
+
throw takeObject(r1);
|
|
1646
|
+
}
|
|
1647
|
+
return r0 >>> 0;
|
|
1648
|
+
} finally {
|
|
1649
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Identify and remove footers.
|
|
1654
|
+
*
|
|
1655
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1656
|
+
* falls back to heuristic analysis of the bottom 15% of pages.
|
|
1657
|
+
*
|
|
1658
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1659
|
+
* @param {number} threshold
|
|
1660
|
+
* @returns {number}
|
|
1661
|
+
*/
|
|
1662
|
+
removeFooters(threshold) {
|
|
1663
|
+
try {
|
|
1664
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1665
|
+
wasm.wasmpdfdocument_removeFooters(retptr, this.__wbg_ptr, threshold);
|
|
1666
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1667
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1668
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1669
|
+
if (r2) {
|
|
1670
|
+
throw takeObject(r1);
|
|
1671
|
+
}
|
|
1672
|
+
return r0 >>> 0;
|
|
1673
|
+
} finally {
|
|
1674
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Identify and remove headers.
|
|
1679
|
+
*
|
|
1680
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1681
|
+
* falls back to heuristic analysis of the top 15% of pages.
|
|
1682
|
+
*
|
|
1683
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1684
|
+
* @param {number} threshold
|
|
1685
|
+
* @returns {number}
|
|
1686
|
+
*/
|
|
1687
|
+
removeHeaders(threshold) {
|
|
1688
|
+
try {
|
|
1689
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1690
|
+
wasm.wasmpdfdocument_removeHeaders(retptr, this.__wbg_ptr, threshold);
|
|
1691
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1692
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1693
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1694
|
+
if (r2) {
|
|
1695
|
+
throw takeObject(r1);
|
|
1696
|
+
}
|
|
1697
|
+
return r0 >>> 0;
|
|
1698
|
+
} finally {
|
|
1699
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1243
1702
|
/**
|
|
1244
1703
|
* Reposition an image on a page.
|
|
1245
1704
|
* @param {number} page_index
|
|
@@ -2183,9 +2642,17 @@ function __wbg_get_imports() {
|
|
|
2183
2642
|
const ret = Array.from(getObject(arg0));
|
|
2184
2643
|
return addHeapObject(ret);
|
|
2185
2644
|
},
|
|
2186
|
-
|
|
2645
|
+
__wbg_getRandomValues_a1cf2e70b003a59d: function() { return handleError(function (arg0, arg1) {
|
|
2187
2646
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
2188
2647
|
}, arguments); },
|
|
2648
|
+
__wbg_getTime_1dad7b5386ddd2d9: function(arg0) {
|
|
2649
|
+
const ret = getObject(arg0).getTime();
|
|
2650
|
+
return ret;
|
|
2651
|
+
},
|
|
2652
|
+
__wbg_getTimezoneOffset_639bcf2dde21158b: function(arg0) {
|
|
2653
|
+
const ret = getObject(arg0).getTimezoneOffset();
|
|
2654
|
+
return ret;
|
|
2655
|
+
},
|
|
2189
2656
|
__wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
|
|
2190
2657
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
2191
2658
|
return addHeapObject(ret);
|
|
@@ -2202,6 +2669,10 @@ function __wbg_get_imports() {
|
|
|
2202
2669
|
const ret = getObject(arg0).length;
|
|
2203
2670
|
return ret;
|
|
2204
2671
|
},
|
|
2672
|
+
__wbg_new_0_1dcafdf5e786e876: function() {
|
|
2673
|
+
const ret = new Date();
|
|
2674
|
+
return addHeapObject(ret);
|
|
2675
|
+
},
|
|
2205
2676
|
__wbg_new_227d7c05414eb861: function() {
|
|
2206
2677
|
const ret = new Error();
|
|
2207
2678
|
return addHeapObject(ret);
|
|
@@ -2222,6 +2693,10 @@ function __wbg_get_imports() {
|
|
|
2222
2693
|
const ret = new Object();
|
|
2223
2694
|
return addHeapObject(ret);
|
|
2224
2695
|
},
|
|
2696
|
+
__wbg_new_fd94ca5c9639abd2: function(arg0) {
|
|
2697
|
+
const ret = new Date(getObject(arg0));
|
|
2698
|
+
return addHeapObject(ret);
|
|
2699
|
+
},
|
|
2225
2700
|
__wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
|
|
2226
2701
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
2227
2702
|
return addHeapObject(ret);
|
|
@@ -2288,12 +2763,27 @@ function __wbg_get_imports() {
|
|
|
2288
2763
|
};
|
|
2289
2764
|
}
|
|
2290
2765
|
|
|
2766
|
+
const WasmArtifactFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2767
|
+
? { register: () => {}, unregister: () => {} }
|
|
2768
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmartifact_free(ptr >>> 0, 1));
|
|
2769
|
+
const ArtifactStyleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2770
|
+
? { register: () => {}, unregister: () => {} }
|
|
2771
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_artifactstyle_free(ptr >>> 0, 1));
|
|
2772
|
+
const WasmFooterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2773
|
+
? { register: () => {}, unregister: () => {} }
|
|
2774
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfooter_free(ptr >>> 0, 1));
|
|
2775
|
+
const WasmHeaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2776
|
+
? { register: () => {}, unregister: () => {} }
|
|
2777
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmheader_free(ptr >>> 0, 1));
|
|
2291
2778
|
const WasmOcrConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2292
2779
|
? { register: () => {}, unregister: () => {} }
|
|
2293
2780
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmocrconfig_free(ptr >>> 0, 1));
|
|
2294
2781
|
const WasmOcrEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2295
2782
|
? { register: () => {}, unregister: () => {} }
|
|
2296
2783
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmocrengine_free(ptr >>> 0, 1));
|
|
2784
|
+
const WasmPageTemplateFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2785
|
+
? { register: () => {}, unregister: () => {} }
|
|
2786
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpagetemplate_free(ptr >>> 0, 1));
|
|
2297
2787
|
const WasmPdfFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2298
2788
|
? { register: () => {}, unregister: () => {} }
|
|
2299
2789
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpdf_free(ptr >>> 0, 1));
|
package/pdf_oxide_bg.wasm
CHANGED
|
Binary file
|
package/pdf_oxide_bg.wasm.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_artifactstyle_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmartifact_free: (a: number, b: number) => void;
|
|
4
6
|
export const __wbg_wasmocrconfig_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_wasmpagetemplate_free: (a: number, b: number) => void;
|
|
5
8
|
export const __wbg_wasmpdf_free: (a: number, b: number) => void;
|
|
6
9
|
export const __wbg_wasmpdfdocument_free: (a: number, b: number) => void;
|
|
7
10
|
export const __wbg_wasmpdfpageregion_free: (a: number, b: number) => void;
|
|
11
|
+
export const wasmartifact_center: (a: number, b: number) => number;
|
|
12
|
+
export const wasmartifact_left: (a: number, b: number) => number;
|
|
13
|
+
export const wasmartifact_new: () => number;
|
|
14
|
+
export const wasmartifact_right: (a: number, b: number) => number;
|
|
15
|
+
export const wasmartifact_withOffset: (a: number, b: number) => number;
|
|
16
|
+
export const wasmartifact_withStyle: (a: number, b: number) => number;
|
|
17
|
+
export const wasmartifactstyle_bold: (a: number) => number;
|
|
18
|
+
export const wasmartifactstyle_color: (a: number, b: number, c: number, d: number) => number;
|
|
19
|
+
export const wasmartifactstyle_font: (a: number, b: number, c: number, d: number) => number;
|
|
20
|
+
export const wasmartifactstyle_new: () => number;
|
|
8
21
|
export const wasmocrengine_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
22
|
+
export const wasmpagetemplate_footer: (a: number, b: number) => number;
|
|
23
|
+
export const wasmpagetemplate_header: (a: number, b: number) => number;
|
|
24
|
+
export const wasmpagetemplate_new: () => number;
|
|
25
|
+
export const wasmpagetemplate_skipFirstPage: (a: number) => number;
|
|
9
26
|
export const wasmpdf_fromHtml: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
10
27
|
export const wasmpdf_fromImageBytes: (a: number, b: number, c: number) => void;
|
|
11
28
|
export const wasmpdf_fromMarkdown: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
@@ -19,6 +36,9 @@ export const wasmpdfdocument_authenticate: (a: number, b: number, c: number, d:
|
|
|
19
36
|
export const wasmpdfdocument_clearEraseRegions: (a: number, b: number, c: number) => void;
|
|
20
37
|
export const wasmpdfdocument_cropMargins: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
21
38
|
export const wasmpdfdocument_embedFile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
39
|
+
export const wasmpdfdocument_eraseArtifacts: (a: number, b: number, c: number) => void;
|
|
40
|
+
export const wasmpdfdocument_eraseFooter: (a: number, b: number, c: number) => void;
|
|
41
|
+
export const wasmpdfdocument_eraseHeader: (a: number, b: number, c: number) => void;
|
|
22
42
|
export const wasmpdfdocument_eraseRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
23
43
|
export const wasmpdfdocument_eraseRegions: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
24
44
|
export const wasmpdfdocument_exportFormData: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -53,6 +73,9 @@ export const wasmpdfdocument_pageImages: (a: number, b: number, c: number) => vo
|
|
|
53
73
|
export const wasmpdfdocument_pageLabels: (a: number, b: number) => void;
|
|
54
74
|
export const wasmpdfdocument_pageMediaBox: (a: number, b: number, c: number) => void;
|
|
55
75
|
export const wasmpdfdocument_pageRotation: (a: number, b: number, c: number) => void;
|
|
76
|
+
export const wasmpdfdocument_removeArtifacts: (a: number, b: number, c: number) => void;
|
|
77
|
+
export const wasmpdfdocument_removeFooters: (a: number, b: number, c: number) => void;
|
|
78
|
+
export const wasmpdfdocument_removeHeaders: (a: number, b: number, c: number) => void;
|
|
56
79
|
export const wasmpdfdocument_repositionImage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
57
80
|
export const wasmpdfdocument_resizeImage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
58
81
|
export const wasmpdfdocument_rotateAllPages: (a: number, b: number, c: number) => void;
|
|
@@ -89,8 +112,18 @@ export const wasmpdfpageregion_extractText: (a: number, b: number) => void;
|
|
|
89
112
|
export const wasmpdfpageregion_extractTextLines: (a: number, b: number) => void;
|
|
90
113
|
export const wasmpdfpageregion_extractTextOcr: (a: number, b: number, c: number) => void;
|
|
91
114
|
export const wasmpdfpageregion_extractWords: (a: number, b: number) => void;
|
|
115
|
+
export const wasmfooter_center: (a: number, b: number) => number;
|
|
116
|
+
export const wasmfooter_left: (a: number, b: number) => number;
|
|
117
|
+
export const wasmfooter_right: (a: number, b: number) => number;
|
|
118
|
+
export const wasmheader_center: (a: number, b: number) => number;
|
|
119
|
+
export const wasmheader_left: (a: number, b: number) => number;
|
|
120
|
+
export const wasmheader_right: (a: number, b: number) => number;
|
|
121
|
+
export const wasmfooter_new: () => number;
|
|
122
|
+
export const wasmheader_new: () => number;
|
|
92
123
|
export const __wbg_wasmocrengine_free: (a: number, b: number) => void;
|
|
93
124
|
export const wasmocrconfig_new: () => number;
|
|
125
|
+
export const __wbg_wasmheader_free: (a: number, b: number) => void;
|
|
126
|
+
export const __wbg_wasmfooter_free: (a: number, b: number) => void;
|
|
94
127
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
95
128
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
96
129
|
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|