pdf-oxide-wasm 0.3.37 → 0.3.39
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 +1 -1
- package/bundler/package.json +1 -0
- package/{pdf_oxide.d.ts → bundler/pdf_oxide.d.ts} +590 -10
- package/bundler/pdf_oxide.js +9 -0
- package/bundler/pdf_oxide_bg.js +6094 -0
- package/bundler/pdf_oxide_bg.wasm +0 -0
- package/{pdf_oxide_bg.wasm.d.ts → bundler/pdf_oxide_bg.wasm.d.ts} +119 -0
- package/nodejs/package.json +1 -0
- package/nodejs/pdf_oxide.d.ts +1399 -0
- package/{pdf_oxide.js → nodejs/pdf_oxide.js} +2796 -175
- package/nodejs/pdf_oxide_bg.wasm +0 -0
- package/nodejs/pdf_oxide_bg.wasm.d.ts +276 -0
- package/package.json +29 -7
- package/web/package.json +1 -0
- package/web/pdf_oxide.d.ts +1700 -0
- package/web/pdf_oxide.js +6195 -0
- package/web/pdf_oxide_bg.wasm +0 -0
- package/web/pdf_oxide_bg.wasm.d.ts +276 -0
- package/pdf_oxide_bg.wasm +0 -0
|
@@ -0,0 +1,1399 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Horizontal-alignment enum shared by `textInRect`, buffered `table`, and
|
|
6
|
+
* `streamingTable`. Maps 1:1 onto [`crate::writer::TextAlign`] /
|
|
7
|
+
* [`crate::writer::CellAlign`]. Exported to JS as `Align` via `js_name`.
|
|
8
|
+
*/
|
|
9
|
+
export enum Align {
|
|
10
|
+
/**
|
|
11
|
+
* Align to the left edge.
|
|
12
|
+
*/
|
|
13
|
+
Left = 0,
|
|
14
|
+
/**
|
|
15
|
+
* Center horizontally.
|
|
16
|
+
*/
|
|
17
|
+
Center = 1,
|
|
18
|
+
/**
|
|
19
|
+
* Align to the right edge.
|
|
20
|
+
*/
|
|
21
|
+
Right = 2,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Style configuration for header/footer text.
|
|
26
|
+
*/
|
|
27
|
+
export class ArtifactStyle {
|
|
28
|
+
free(): void;
|
|
29
|
+
[Symbol.dispose](): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set bold font for the artifact.
|
|
32
|
+
*/
|
|
33
|
+
bold(): ArtifactStyle;
|
|
34
|
+
/**
|
|
35
|
+
* Set color for the artifact.
|
|
36
|
+
*/
|
|
37
|
+
color(r: number, g: number, b: number): ArtifactStyle;
|
|
38
|
+
/**
|
|
39
|
+
* Set font for the artifact.
|
|
40
|
+
*/
|
|
41
|
+
font(name: string, size: number): ArtifactStyle;
|
|
42
|
+
/**
|
|
43
|
+
* Create a new artifact style.
|
|
44
|
+
*/
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* WASM handle to a streaming-table building session. Created by
|
|
50
|
+
* `FluentPageBuilder.streamingTable()`; rows are pushed via `pushRow`,
|
|
51
|
+
* and the session is sealed with `finish()`.
|
|
52
|
+
*
|
|
53
|
+
* Single-use: `finish()` twice throws, and `pushRow` after `finish()`
|
|
54
|
+
* throws. The rows are buffered and replayed against the real Rust
|
|
55
|
+
* `StreamingTable` at `WasmFluentPageBuilder.done()` commit time —
|
|
56
|
+
* preserving the FluentPageBuilder borrow-lifetime invariant that can't
|
|
57
|
+
* cross the wasm-bindgen boundary.
|
|
58
|
+
*/
|
|
59
|
+
export class StreamingTable {
|
|
60
|
+
private constructor();
|
|
61
|
+
free(): void;
|
|
62
|
+
[Symbol.dispose](): void;
|
|
63
|
+
/**
|
|
64
|
+
* Number of columns configured on this streaming table.
|
|
65
|
+
*/
|
|
66
|
+
columnCount(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Seal the streaming table — the buffered rows are flushed onto the
|
|
69
|
+
* parent page's op queue, to be replayed against the real Rust
|
|
70
|
+
* `StreamingTable` at `done()` commit time. Calling `finish()` twice
|
|
71
|
+
* throws.
|
|
72
|
+
*/
|
|
73
|
+
finish(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Push one row as an array of cell strings (all rowspan=1). Returns an
|
|
76
|
+
* error if the table has already been finished or if the row's cell count
|
|
77
|
+
* does not match the column count.
|
|
78
|
+
*/
|
|
79
|
+
pushRow(cells: string[]): void;
|
|
80
|
+
/**
|
|
81
|
+
* Push one row with per-cell rowspan values. `cells` is a JS array of
|
|
82
|
+
* `[text, rowspan]` two-element arrays. `rowspan == 1` is a normal cell.
|
|
83
|
+
*/
|
|
84
|
+
pushRowSpan(cells: any): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A header or footer artifact definition.
|
|
89
|
+
*/
|
|
90
|
+
export class WasmArtifact {
|
|
91
|
+
free(): void;
|
|
92
|
+
[Symbol.dispose](): void;
|
|
93
|
+
/**
|
|
94
|
+
* Create a center-aligned artifact.
|
|
95
|
+
*/
|
|
96
|
+
static center(text: string): WasmArtifact;
|
|
97
|
+
/**
|
|
98
|
+
* Create a left-aligned artifact.
|
|
99
|
+
*/
|
|
100
|
+
static left(text: string): WasmArtifact;
|
|
101
|
+
/**
|
|
102
|
+
* Create a new artifact.
|
|
103
|
+
*/
|
|
104
|
+
constructor();
|
|
105
|
+
/**
|
|
106
|
+
* Create a right-aligned artifact.
|
|
107
|
+
*/
|
|
108
|
+
static right(text: string): WasmArtifact;
|
|
109
|
+
/**
|
|
110
|
+
* Set vertical offset for the artifact.
|
|
111
|
+
*/
|
|
112
|
+
withOffset(offset: number): WasmArtifact;
|
|
113
|
+
/**
|
|
114
|
+
* Set style for the artifact.
|
|
115
|
+
*/
|
|
116
|
+
withStyle(style: ArtifactStyle): WasmArtifact;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* X.509 certificate parsed from a raw DER blob. Mirrors the C#,
|
|
121
|
+
* Node, Python, and Go `Certificate` surfaces — `subject` / `issuer`
|
|
122
|
+
* / `serial` / `validity` / `isValid` getters only.
|
|
123
|
+
*/
|
|
124
|
+
export class WasmCertificate {
|
|
125
|
+
private constructor();
|
|
126
|
+
free(): void;
|
|
127
|
+
[Symbol.dispose](): void;
|
|
128
|
+
/**
|
|
129
|
+
* Load a certificate from a DER-encoded X.509 blob. Throws if
|
|
130
|
+
* the DER doesn't parse.
|
|
131
|
+
*/
|
|
132
|
+
static load(data: Uint8Array): WasmCertificate;
|
|
133
|
+
/**
|
|
134
|
+
* Load a signer certificate + private key from PEM strings.
|
|
135
|
+
* `certPem` must begin `-----BEGIN CERTIFICATE-----`.
|
|
136
|
+
* `keyPem` must begin `-----BEGIN PRIVATE KEY-----` or `-----BEGIN RSA PRIVATE KEY-----`.
|
|
137
|
+
*/
|
|
138
|
+
static loadPem(cert_pem: string, key_pem: string): WasmCertificate;
|
|
139
|
+
/**
|
|
140
|
+
* Load a signer certificate + private key from a PKCS#12 (.p12/.pfx) blob.
|
|
141
|
+
* `password` is the passphrase protecting the key bag.
|
|
142
|
+
*/
|
|
143
|
+
static loadPkcs12(data: Uint8Array, password: string): WasmCertificate;
|
|
144
|
+
/**
|
|
145
|
+
* Whether the certificate is currently within its validity
|
|
146
|
+
* window. Does NOT verify chain, trust-root, or revocation.
|
|
147
|
+
*/
|
|
148
|
+
readonly isValid: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Issuer distinguished name.
|
|
151
|
+
*/
|
|
152
|
+
readonly issuer: string;
|
|
153
|
+
/**
|
|
154
|
+
* Serial number as a hex string (no `0x` prefix).
|
|
155
|
+
*/
|
|
156
|
+
readonly serial: string;
|
|
157
|
+
/**
|
|
158
|
+
* Subject distinguished name.
|
|
159
|
+
*/
|
|
160
|
+
readonly subject: string;
|
|
161
|
+
/**
|
|
162
|
+
* Validity window as `[notBefore, notAfter]` Unix epoch seconds.
|
|
163
|
+
* JavaScript: `new Date(notBefore * 1000)` for a Date.
|
|
164
|
+
*/
|
|
165
|
+
readonly validity: BigInt64Array;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* WASM wrapper for [`crate::writer::DocumentBuilder`]. Fluent API for
|
|
170
|
+
* programmatic multi-page PDF construction with embedded fonts and
|
|
171
|
+
* annotations.
|
|
172
|
+
*
|
|
173
|
+
* The terminal methods (`build`, `toBytesEncrypted`) **consume** the
|
|
174
|
+
* builder; subsequent calls throw `Error: DocumentBuilder already
|
|
175
|
+
* consumed`.
|
|
176
|
+
*/
|
|
177
|
+
export class WasmDocumentBuilder {
|
|
178
|
+
free(): void;
|
|
179
|
+
[Symbol.dispose](): void;
|
|
180
|
+
/**
|
|
181
|
+
* Start a new A4 page. Returns a `FluentPageBuilder` that must be
|
|
182
|
+
* committed with `.done()` before calling another page method or a
|
|
183
|
+
* terminal (`build`, etc.).
|
|
184
|
+
*/
|
|
185
|
+
a4Page(): WasmFluentPageBuilder;
|
|
186
|
+
/**
|
|
187
|
+
* Set document author.
|
|
188
|
+
*/
|
|
189
|
+
author(author: string): void;
|
|
190
|
+
/**
|
|
191
|
+
* Build the PDF and return it as a `Uint8Array`. **Consumes** the
|
|
192
|
+
* builder.
|
|
193
|
+
*/
|
|
194
|
+
build(): Uint8Array;
|
|
195
|
+
/**
|
|
196
|
+
* Commit a completed `FluentPageBuilder` back to this builder.
|
|
197
|
+
* Takes the place of the Rust `page.done()` re-parenting.
|
|
198
|
+
*
|
|
199
|
+
* JS users typically don't call this directly — the ergonomic
|
|
200
|
+
* pattern is `builder.a4Page();` for each page, then
|
|
201
|
+
* `builder.commitPage(page)` once ops are queued. For more fluent
|
|
202
|
+
* code, see the `FluentPageBuilder.done(builder)` helper which
|
|
203
|
+
* delegates to this method.
|
|
204
|
+
*/
|
|
205
|
+
commitPage(page: WasmFluentPageBuilder): void;
|
|
206
|
+
/**
|
|
207
|
+
* Set the creator application name recorded in the PDF.
|
|
208
|
+
*/
|
|
209
|
+
creator(creator: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Set document keywords (comma-separated per PDF convention).
|
|
212
|
+
*/
|
|
213
|
+
keywords(keywords: string): void;
|
|
214
|
+
/**
|
|
215
|
+
* Set the document's natural language tag (e.g. `"en-US"`).
|
|
216
|
+
*
|
|
217
|
+
* Emitted as `/Lang` in the catalog when `taggedPdfUa1()` is set.
|
|
218
|
+
*/
|
|
219
|
+
language(lang: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Start a new US Letter page.
|
|
222
|
+
*/
|
|
223
|
+
letterPage(): WasmFluentPageBuilder;
|
|
224
|
+
/**
|
|
225
|
+
* Create a new empty document builder. Equivalent to the Rust
|
|
226
|
+
* [`crate::writer::DocumentBuilder::new`] — every other method
|
|
227
|
+
* chains off the instance returned here.
|
|
228
|
+
*/
|
|
229
|
+
constructor();
|
|
230
|
+
/**
|
|
231
|
+
* Run a JavaScript script when the document is opened (`/OpenAction`).
|
|
232
|
+
*/
|
|
233
|
+
onOpen(script: string): void;
|
|
234
|
+
/**
|
|
235
|
+
* Start a new page with custom dimensions in PDF points
|
|
236
|
+
* (72 pt = 1 inch).
|
|
237
|
+
*/
|
|
238
|
+
page(width: number, height: number): WasmFluentPageBuilder;
|
|
239
|
+
/**
|
|
240
|
+
* Register a TTF / OTF font the pages can reference by name.
|
|
241
|
+
* **Consumes** `font` — reusing the `WasmEmbeddedFont` throws.
|
|
242
|
+
*/
|
|
243
|
+
registerEmbeddedFont(name: string, font: WasmEmbeddedFont): void;
|
|
244
|
+
/**
|
|
245
|
+
* Add a role-map entry: custom structure type → standard PDF structure type.
|
|
246
|
+
*
|
|
247
|
+
* Emitted in `/RoleMap` inside the StructTreeRoot when `taggedPdfUa1()`
|
|
248
|
+
* is set. Multiple calls accumulate entries.
|
|
249
|
+
*/
|
|
250
|
+
roleMap(custom: string, standard: string): void;
|
|
251
|
+
/**
|
|
252
|
+
* Set document subject.
|
|
253
|
+
*/
|
|
254
|
+
subject(subject: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Enable PDF/UA-1 tagged PDF mode.
|
|
257
|
+
*
|
|
258
|
+
* When enabled, `build()` emits `/MarkInfo`, `/StructTreeRoot`, `/Lang`,
|
|
259
|
+
* and `/ViewerPreferences` in the catalog. Opt-in — no effect unless called.
|
|
260
|
+
*/
|
|
261
|
+
taggedPdfUa1(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Set document title.
|
|
264
|
+
*/
|
|
265
|
+
title(title: string): void;
|
|
266
|
+
/**
|
|
267
|
+
* Build the PDF with AES-256 encryption and return it as a
|
|
268
|
+
* `Uint8Array`. Granted permissions default to all. **Consumes**
|
|
269
|
+
* the builder.
|
|
270
|
+
*/
|
|
271
|
+
toBytesEncrypted(user_password: string, owner_password: string): Uint8Array;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Embedded TTF/OTF font usable by `WasmDocumentBuilder`. Single-use: once
|
|
276
|
+
* passed to `registerEmbeddedFont`, the underlying Rust `EmbeddedFont` is
|
|
277
|
+
* moved into the builder and this handle becomes empty.
|
|
278
|
+
*/
|
|
279
|
+
export class WasmEmbeddedFont {
|
|
280
|
+
private constructor();
|
|
281
|
+
free(): void;
|
|
282
|
+
[Symbol.dispose](): void;
|
|
283
|
+
/**
|
|
284
|
+
* Load an embedded font from raw TTF/OTF bytes. Pass `name` to
|
|
285
|
+
* override the PostScript name baked into the font file.
|
|
286
|
+
*/
|
|
287
|
+
static fromBytes(data: Uint8Array, name?: string | null): WasmEmbeddedFont;
|
|
288
|
+
/**
|
|
289
|
+
* The font's PostScript name (or the override). Empty once consumed.
|
|
290
|
+
*/
|
|
291
|
+
readonly name: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Per-page fluent builder. Buffers operations until `done(builder)` is
|
|
296
|
+
* called, which commits them to the parent `WasmDocumentBuilder`. Each
|
|
297
|
+
* instance is single-use — `done()` twice throws.
|
|
298
|
+
*/
|
|
299
|
+
export class WasmFluentPageBuilder {
|
|
300
|
+
private constructor();
|
|
301
|
+
free(): void;
|
|
302
|
+
[Symbol.dispose](): void;
|
|
303
|
+
at(x: number, y: number): void;
|
|
304
|
+
/**
|
|
305
|
+
* Place a 1-D barcode image at `(x, y, w, h)` on the page.
|
|
306
|
+
* `barcodeType`: 0=Code128 1=Code39 2=EAN13 3=EAN8 4=UPCA 5=ITF
|
|
307
|
+
* 6=Code93 7=Codabar.
|
|
308
|
+
*/
|
|
309
|
+
barcode1d(barcode_type: number, data: string, x: number, y: number, w: number, h: number): void;
|
|
310
|
+
/**
|
|
311
|
+
* Place a QR-code image at `(x, y, size, size)` on the page.
|
|
312
|
+
*/
|
|
313
|
+
barcodeQr(data: string, x: number, y: number, size: number): void;
|
|
314
|
+
checkbox(name: string, x: number, y: number, w: number, h: number, checked: boolean): void;
|
|
315
|
+
/**
|
|
316
|
+
* Lay out `text` as balanced multi-column flow (`columnCount` columns,
|
|
317
|
+
* `gapPt` points between columns). Paragraphs in `text` are separated by `"\n\n"`.
|
|
318
|
+
*/
|
|
319
|
+
columns(column_count: number, gap_pt: number, text: string): void;
|
|
320
|
+
/**
|
|
321
|
+
* Add a dropdown combo-box.
|
|
322
|
+
*/
|
|
323
|
+
comboBox(name: string, x: number, y: number, w: number, h: number, options: string[], selected?: string | null): void;
|
|
324
|
+
/**
|
|
325
|
+
* Convenience: commit this page's buffered ops to `builder`. Same
|
|
326
|
+
* as `builder.commitPage(this)` but lets JS users keep the
|
|
327
|
+
* chain-like flow:
|
|
328
|
+
*
|
|
329
|
+
* ```javascript
|
|
330
|
+
* const page = builder.a4Page();
|
|
331
|
+
* page.at(72, 720); page.text("Hi");
|
|
332
|
+
* page.done(builder);
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
done(builder: WasmDocumentBuilder): void;
|
|
336
|
+
fieldCalculate(script: string): void;
|
|
337
|
+
fieldFormat(script: string): void;
|
|
338
|
+
fieldKeystroke(script: string): void;
|
|
339
|
+
fieldValidate(script: string): void;
|
|
340
|
+
/**
|
|
341
|
+
* Draw a filled rectangle. RGB channels in 0.0-1.0.
|
|
342
|
+
*/
|
|
343
|
+
filledRect(x: number, y: number, w: number, h: number, r: number, g: number, b: number): void;
|
|
344
|
+
font(name: string, size: number): void;
|
|
345
|
+
/**
|
|
346
|
+
* Add a footnote: inline `refMark` at the cursor and `noteText` body
|
|
347
|
+
* near the page bottom with a separator artifact line.
|
|
348
|
+
*/
|
|
349
|
+
footnote(ref_mark: string, note_text: string): void;
|
|
350
|
+
freeText(x: number, y: number, w: number, h: number, text: string): void;
|
|
351
|
+
heading(level: number, text: string): void;
|
|
352
|
+
highlight(r: number, g: number, b: number): void;
|
|
353
|
+
horizontalRule(): void;
|
|
354
|
+
/**
|
|
355
|
+
* Embed a decorative image (JPEG/PNG/WebP bytes) as an /Artifact (no alt text).
|
|
356
|
+
*/
|
|
357
|
+
imageArtifact(bytes: Uint8Array, x: number, y: number, w: number, h: number): void;
|
|
358
|
+
/**
|
|
359
|
+
* Embed an image (JPEG/PNG/WebP bytes) with an accessibility alt text.
|
|
360
|
+
*/
|
|
361
|
+
imageWithAlt(bytes: Uint8Array, x: number, y: number, w: number, h: number, alt_text: string): void;
|
|
362
|
+
/**
|
|
363
|
+
* Emit `text` inline (advances cursorX only, not cursorY).
|
|
364
|
+
*/
|
|
365
|
+
inline(text: string): void;
|
|
366
|
+
/**
|
|
367
|
+
* Inline bold run.
|
|
368
|
+
*/
|
|
369
|
+
inlineBold(text: string): void;
|
|
370
|
+
/**
|
|
371
|
+
* Inline colored run (RGB 0.0–1.0).
|
|
372
|
+
*/
|
|
373
|
+
inlineColor(r: number, g: number, b: number, text: string): void;
|
|
374
|
+
/**
|
|
375
|
+
* Inline italic run.
|
|
376
|
+
*/
|
|
377
|
+
inlineItalic(text: string): void;
|
|
378
|
+
/**
|
|
379
|
+
* Draw a line from (x1, y1) to (x2, y2) with 1pt black stroke.
|
|
380
|
+
*/
|
|
381
|
+
line(x1: number, y1: number, x2: number, y2: number): void;
|
|
382
|
+
linkJavascript(script: string): void;
|
|
383
|
+
linkNamed(destination: string): void;
|
|
384
|
+
linkPage(page: number): void;
|
|
385
|
+
linkUrl(url: string): void;
|
|
386
|
+
/**
|
|
387
|
+
* Measure the rendered width of `text` in the builder's current font
|
|
388
|
+
* and size, in PDF points. Pure query — does not mutate state.
|
|
389
|
+
*
|
|
390
|
+
* Thin JS view over [`crate::writer::FluentPageBuilder::measure`]. The
|
|
391
|
+
* WASM class tracks the current font/size independently of the
|
|
392
|
+
* buffered ops so this query is served without a live builder.
|
|
393
|
+
*/
|
|
394
|
+
measure(text: string): number;
|
|
395
|
+
/**
|
|
396
|
+
* Finish the current page and start a new one with the same page
|
|
397
|
+
* size. Cursor resets to the top-left margin (72, height-72). The
|
|
398
|
+
* builder's font carries over.
|
|
399
|
+
*/
|
|
400
|
+
newPageSameSize(): void;
|
|
401
|
+
/**
|
|
402
|
+
* Advance cursorY by one line-height and reset cursorX to 72 pt.
|
|
403
|
+
*/
|
|
404
|
+
newline(): void;
|
|
405
|
+
onClose(script: string): void;
|
|
406
|
+
onOpen(script: string): void;
|
|
407
|
+
paragraph(text: string): void;
|
|
408
|
+
/**
|
|
409
|
+
* Add a clickable push button with a visible caption.
|
|
410
|
+
*/
|
|
411
|
+
pushButton(name: string, x: number, y: number, w: number, h: number, caption: string): void;
|
|
412
|
+
/**
|
|
413
|
+
* Add a radio-button group. `values`, `xs`, `ys`, `ws`, `hs` are
|
|
414
|
+
* parallel arrays of length N describing each option's export
|
|
415
|
+
* value and rectangle. `selected` picks the initial value.
|
|
416
|
+
*/
|
|
417
|
+
radioGroup(name: string, values: string[], xs: Float32Array, ys: Float32Array, ws: Float32Array, hs: Float32Array, selected?: string | null): void;
|
|
418
|
+
/**
|
|
419
|
+
* Draw a stroked rectangle outline (1pt black).
|
|
420
|
+
*/
|
|
421
|
+
rect(x: number, y: number, w: number, h: number): void;
|
|
422
|
+
/**
|
|
423
|
+
* Points remaining on the current page below the cursor (down to the
|
|
424
|
+
* 72 pt bottom margin). Mirrors
|
|
425
|
+
* [`crate::writer::FluentPageBuilder::remaining_space`] using the WASM
|
|
426
|
+
* class's independently-tracked cursor — accurate after `at`, `text`,
|
|
427
|
+
* `space`, `newPageSameSize`, `textInRect` and the table helpers.
|
|
428
|
+
*/
|
|
429
|
+
remainingSpace(): number;
|
|
430
|
+
/**
|
|
431
|
+
* Add an unsigned signature placeholder field at the given bounds.
|
|
432
|
+
*/
|
|
433
|
+
signatureField(name: string, x: number, y: number, w: number, h: number): void;
|
|
434
|
+
space(points: number): void;
|
|
435
|
+
squiggly(r: number, g: number, b: number): void;
|
|
436
|
+
stamp(name: string): void;
|
|
437
|
+
stickyNote(text: string): void;
|
|
438
|
+
stickyNoteAt(x: number, y: number, text: string): void;
|
|
439
|
+
/**
|
|
440
|
+
* Open a streaming table. Returns a `StreamingTable` handle the caller
|
|
441
|
+
* pushes rows into; call `finish()` when done. The streamed rows are
|
|
442
|
+
* buffered per-table and replayed against the real Rust
|
|
443
|
+
* `StreamingTable` at `done()` commit time — avoiding the
|
|
444
|
+
* FluentPageBuilder-lifetime problem that otherwise can't cross the
|
|
445
|
+
* wasm-bindgen boundary.
|
|
446
|
+
*/
|
|
447
|
+
streamingTable(spec: any): StreamingTable;
|
|
448
|
+
strikeout(r: number, g: number, b: number): void;
|
|
449
|
+
/**
|
|
450
|
+
* Draw a straight line with explicit stroke width and RGB colour.
|
|
451
|
+
*/
|
|
452
|
+
strokeLine(x1: number, y1: number, x2: number, y2: number, width: number, r: number, g: number, b: number): void;
|
|
453
|
+
/**
|
|
454
|
+
* Draw a stroked rectangle with explicit stroke width and RGB colour.
|
|
455
|
+
*/
|
|
456
|
+
strokeRect(x: number, y: number, w: number, h: number, width: number, r: number, g: number, b: number): void;
|
|
457
|
+
/**
|
|
458
|
+
* Render a buffered table from a JS object:
|
|
459
|
+
*
|
|
460
|
+
* ```javascript
|
|
461
|
+
* page.table({
|
|
462
|
+
* columns: [
|
|
463
|
+
* { header: "SKU", width: 100, align: Align.Left },
|
|
464
|
+
* { header: "Qty", width: 60, align: Align.Right },
|
|
465
|
+
* ],
|
|
466
|
+
* rows: [["A-1","12"], ["B-2","3"]],
|
|
467
|
+
* hasHeader: true,
|
|
468
|
+
* });
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* Uses `serde-wasm-bindgen` for deserialisation. Replays against the
|
|
472
|
+
* Rust `Table` builder at `done()` commit time.
|
|
473
|
+
*/
|
|
474
|
+
table(spec: any): void;
|
|
475
|
+
text(text: string): void;
|
|
476
|
+
textField(name: string, x: number, y: number, w: number, h: number, default_value?: string | null): void;
|
|
477
|
+
/**
|
|
478
|
+
* Place wrapped text inside a rectangle with horizontal alignment.
|
|
479
|
+
* `align` is the `Align` enum (0 = Left, 1 = Center, 2 = Right) — also
|
|
480
|
+
* accepts a raw integer for JS callers that pre-date the enum import.
|
|
481
|
+
*/
|
|
482
|
+
textInRect(x: number, y: number, w: number, h: number, text: string, align: number): void;
|
|
483
|
+
underline(r: number, g: number, b: number): void;
|
|
484
|
+
watermark(text: string): void;
|
|
485
|
+
watermarkConfidential(): void;
|
|
486
|
+
watermarkDraft(): void;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* A footer definition.
|
|
491
|
+
*/
|
|
492
|
+
export class WasmFooter {
|
|
493
|
+
free(): void;
|
|
494
|
+
[Symbol.dispose](): void;
|
|
495
|
+
/**
|
|
496
|
+
* Create a center-aligned footer.
|
|
497
|
+
*/
|
|
498
|
+
static center(text: string): WasmFooter;
|
|
499
|
+
/**
|
|
500
|
+
* Create a left-aligned footer.
|
|
501
|
+
*/
|
|
502
|
+
static left(text: string): WasmFooter;
|
|
503
|
+
/**
|
|
504
|
+
* Create a new empty footer.
|
|
505
|
+
*/
|
|
506
|
+
constructor();
|
|
507
|
+
/**
|
|
508
|
+
* Create a right-aligned footer.
|
|
509
|
+
*/
|
|
510
|
+
static right(text: string): WasmFooter;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* A header definition.
|
|
515
|
+
*/
|
|
516
|
+
export class WasmHeader {
|
|
517
|
+
free(): void;
|
|
518
|
+
[Symbol.dispose](): void;
|
|
519
|
+
/**
|
|
520
|
+
* Create a center-aligned header.
|
|
521
|
+
*/
|
|
522
|
+
static center(text: string): WasmHeader;
|
|
523
|
+
/**
|
|
524
|
+
* Create a left-aligned header.
|
|
525
|
+
*/
|
|
526
|
+
static left(text: string): WasmHeader;
|
|
527
|
+
/**
|
|
528
|
+
* Create a new empty header.
|
|
529
|
+
*/
|
|
530
|
+
constructor();
|
|
531
|
+
/**
|
|
532
|
+
* Create a right-aligned header.
|
|
533
|
+
*/
|
|
534
|
+
static right(text: string): WasmHeader;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* OCR configuration for WebAssembly.
|
|
539
|
+
*/
|
|
540
|
+
export class WasmOcrConfig {
|
|
541
|
+
free(): void;
|
|
542
|
+
[Symbol.dispose](): void;
|
|
543
|
+
/**
|
|
544
|
+
* Create a new OCR configuration.
|
|
545
|
+
*/
|
|
546
|
+
constructor();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* OCR engine for WebAssembly.
|
|
551
|
+
*/
|
|
552
|
+
export class WasmOcrEngine {
|
|
553
|
+
free(): void;
|
|
554
|
+
[Symbol.dispose](): void;
|
|
555
|
+
/**
|
|
556
|
+
* Create a new OCR engine.
|
|
557
|
+
*/
|
|
558
|
+
constructor(_det_model_path: string, _rec_model_path: string, _dict_path: string, _config?: WasmOcrConfig | null);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* A complete page template with header and footer.
|
|
563
|
+
*/
|
|
564
|
+
export class WasmPageTemplate {
|
|
565
|
+
free(): void;
|
|
566
|
+
[Symbol.dispose](): void;
|
|
567
|
+
/**
|
|
568
|
+
* Set footer artifact.
|
|
569
|
+
*/
|
|
570
|
+
footer(footer: WasmArtifact): WasmPageTemplate;
|
|
571
|
+
/**
|
|
572
|
+
* Set header artifact.
|
|
573
|
+
*/
|
|
574
|
+
header(header: WasmArtifact): WasmPageTemplate;
|
|
575
|
+
/**
|
|
576
|
+
* Create a new page template.
|
|
577
|
+
*/
|
|
578
|
+
constructor();
|
|
579
|
+
/**
|
|
580
|
+
* Skip rendering template on the first page.
|
|
581
|
+
*/
|
|
582
|
+
skipFirstPage(): WasmPageTemplate;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Create new PDF documents from Markdown, HTML, or plain text.
|
|
587
|
+
*
|
|
588
|
+
* ```javascript
|
|
589
|
+
* const pdf = WasmPdf.fromMarkdown("# Hello\n\nWorld");
|
|
590
|
+
* const bytes = pdf.toBytes(); // Uint8Array
|
|
591
|
+
* console.log(`PDF size: ${pdf.size} bytes`);
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
export class WasmPdf {
|
|
595
|
+
private constructor();
|
|
596
|
+
free(): void;
|
|
597
|
+
[Symbol.dispose](): void;
|
|
598
|
+
/**
|
|
599
|
+
* Open an existing PDF from bytes for editing.
|
|
600
|
+
*
|
|
601
|
+
* @param data - PDF file contents as Uint8Array
|
|
602
|
+
* @returns WasmPdf for editing
|
|
603
|
+
*/
|
|
604
|
+
static fromBytes(data: Uint8Array): WasmPdf;
|
|
605
|
+
/**
|
|
606
|
+
* Create a PDF from HTML content.
|
|
607
|
+
*
|
|
608
|
+
* @param content - HTML string
|
|
609
|
+
* @param title - Optional document title
|
|
610
|
+
* @param author - Optional document author
|
|
611
|
+
*/
|
|
612
|
+
static fromHtml(content: string, title?: string | null, author?: string | null): WasmPdf;
|
|
613
|
+
/**
|
|
614
|
+
* Render `html` with `css` applied, embedding `font_bytes` for the
|
|
615
|
+
* body text. The font must cover every codepoint used by `html` or
|
|
616
|
+
* unknown glyphs fall back to `.notdef`. See
|
|
617
|
+
* [`Self::from_html_css_with_fonts`] for a multi-font cascade.
|
|
618
|
+
*/
|
|
619
|
+
static fromHtmlCss(html: string, css: string, font_bytes: Uint8Array): WasmPdf;
|
|
620
|
+
/**
|
|
621
|
+
* Render `html` + `css` with a multi-font cascade. `families` and
|
|
622
|
+
* `fonts` are parallel arrays: `families[i]` names the CSS
|
|
623
|
+
* `font-family` that resolves to `fonts[i]` bytes. The first entry
|
|
624
|
+
* is the default used whenever a CSS `font-family` doesn't match a
|
|
625
|
+
* registered family.
|
|
626
|
+
*/
|
|
627
|
+
static fromHtmlCssWithFonts(html: string, css: string, families: string[], fonts: Uint8Array[]): WasmPdf;
|
|
628
|
+
/**
|
|
629
|
+
* Create a PDF from image bytes (PNG, JPEG, etc.).
|
|
630
|
+
*
|
|
631
|
+
* @param data - Image file contents as a Uint8Array
|
|
632
|
+
*/
|
|
633
|
+
static fromImageBytes(data: Uint8Array): WasmPdf;
|
|
634
|
+
/**
|
|
635
|
+
* Create a PDF from Markdown content.
|
|
636
|
+
*
|
|
637
|
+
* @param content - Markdown string
|
|
638
|
+
* @param title - Optional document title
|
|
639
|
+
* @param author - Optional document author
|
|
640
|
+
*/
|
|
641
|
+
static fromMarkdown(content: string, title?: string | null, author?: string | null): WasmPdf;
|
|
642
|
+
/**
|
|
643
|
+
* Create a PDF from multiple image byte arrays.
|
|
644
|
+
*
|
|
645
|
+
* Each image becomes a separate page. Pass an array of Uint8Arrays.
|
|
646
|
+
*
|
|
647
|
+
* @param images_array - Array of Uint8Arrays, each containing image file bytes (PNG/JPEG)
|
|
648
|
+
*/
|
|
649
|
+
static fromMultipleImageBytes(images_array: any): WasmPdf;
|
|
650
|
+
/**
|
|
651
|
+
* Create a PDF from plain text.
|
|
652
|
+
*
|
|
653
|
+
* @param content - Plain text string
|
|
654
|
+
* @param title - Optional document title
|
|
655
|
+
* @param author - Optional document author
|
|
656
|
+
*/
|
|
657
|
+
static fromText(content: string, title?: string | null, author?: string | null): WasmPdf;
|
|
658
|
+
/**
|
|
659
|
+
* Merge multiple PDF byte arrays into a single PDF.
|
|
660
|
+
*
|
|
661
|
+
* @param pdfs - Array of Uint8Array, each containing a PDF
|
|
662
|
+
* @returns WasmPdf containing all pages
|
|
663
|
+
*/
|
|
664
|
+
static merge(pdfs: Uint8Array[]): WasmPdf;
|
|
665
|
+
/**
|
|
666
|
+
* Get the PDF as a Uint8Array.
|
|
667
|
+
*/
|
|
668
|
+
toBytes(): Uint8Array;
|
|
669
|
+
/**
|
|
670
|
+
* Get the size of the PDF in bytes.
|
|
671
|
+
*/
|
|
672
|
+
readonly size: number;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* A PDF document loaded from bytes for use in WebAssembly.
|
|
677
|
+
*
|
|
678
|
+
* Create an instance by passing PDF file bytes to the constructor.
|
|
679
|
+
* Call `.free()` when done to release memory.
|
|
680
|
+
*/
|
|
681
|
+
export class WasmPdfDocument {
|
|
682
|
+
free(): void;
|
|
683
|
+
[Symbol.dispose](): void;
|
|
684
|
+
/**
|
|
685
|
+
* Apply all redactions in the document.
|
|
686
|
+
*/
|
|
687
|
+
applyAllRedactions(): void;
|
|
688
|
+
/**
|
|
689
|
+
* Apply redactions on a page (removes redacted content permanently).
|
|
690
|
+
*/
|
|
691
|
+
applyPageRedactions(page_index: number): void;
|
|
692
|
+
/**
|
|
693
|
+
* Authenticate with a password to decrypt an encrypted PDF.
|
|
694
|
+
*
|
|
695
|
+
* @param password - The password string
|
|
696
|
+
* @returns true if authentication succeeded
|
|
697
|
+
*/
|
|
698
|
+
authenticate(password: string): boolean;
|
|
699
|
+
/**
|
|
700
|
+
* Clear all pending erase operations for a page.
|
|
701
|
+
*/
|
|
702
|
+
clearEraseRegions(page_index: number): void;
|
|
703
|
+
/**
|
|
704
|
+
* Crop margins from all pages.
|
|
705
|
+
*/
|
|
706
|
+
cropMargins(left: number, right: number, top: number, bottom: number): void;
|
|
707
|
+
/**
|
|
708
|
+
* Delete a page by index (0-based).
|
|
709
|
+
*/
|
|
710
|
+
deletePage(index: number): void;
|
|
711
|
+
/**
|
|
712
|
+
* Deprecated: Use eraseFooter instead.
|
|
713
|
+
*/
|
|
714
|
+
editFooter(page_index: number): void;
|
|
715
|
+
/**
|
|
716
|
+
* Deprecated: Use eraseHeader instead.
|
|
717
|
+
*/
|
|
718
|
+
editHeader(page_index: number): void;
|
|
719
|
+
/**
|
|
720
|
+
* Embed a file into the PDF document.
|
|
721
|
+
*
|
|
722
|
+
* @param name - Display name for the embedded file
|
|
723
|
+
* @param data - File contents as a Uint8Array
|
|
724
|
+
*/
|
|
725
|
+
embedFile(name: string, data: Uint8Array): void;
|
|
726
|
+
/**
|
|
727
|
+
* Erase both header and footer content.
|
|
728
|
+
*
|
|
729
|
+
* @param page_index - Zero-based page number
|
|
730
|
+
*/
|
|
731
|
+
eraseArtifacts(page_index: number): void;
|
|
732
|
+
/**
|
|
733
|
+
* Erase existing footer content.
|
|
734
|
+
*
|
|
735
|
+
* Identifies existing text in the footer area (bottom 15%) and marks it for erasure.
|
|
736
|
+
*
|
|
737
|
+
* @param page_index - Zero-based page number
|
|
738
|
+
*/
|
|
739
|
+
eraseFooter(page_index: number): void;
|
|
740
|
+
/**
|
|
741
|
+
* Erase existing header content.
|
|
742
|
+
*
|
|
743
|
+
* Identifies existing text in the header area (top 15%) and marks it for erasure.
|
|
744
|
+
*
|
|
745
|
+
* @param page_index - Zero-based page number
|
|
746
|
+
*/
|
|
747
|
+
eraseHeader(page_index: number): void;
|
|
748
|
+
/**
|
|
749
|
+
* Erase (whiteout) a rectangular region on a page.
|
|
750
|
+
*/
|
|
751
|
+
eraseRegion(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
|
|
752
|
+
/**
|
|
753
|
+
* Erase multiple rectangular regions on a page.
|
|
754
|
+
*
|
|
755
|
+
* @param page_index - Zero-based page number
|
|
756
|
+
* @param rects - Flat array of coordinates [llx1,lly1,urx1,ury1, llx2,lly2,urx2,ury2, ...]
|
|
757
|
+
*/
|
|
758
|
+
eraseRegions(page_index: number, rects: Float32Array): void;
|
|
759
|
+
/**
|
|
760
|
+
* Export form field data as FDF or XFDF bytes.
|
|
761
|
+
*
|
|
762
|
+
* @param format - "fdf" or "xfdf" (default: "fdf")
|
|
763
|
+
* @returns Uint8Array containing the exported form data
|
|
764
|
+
*/
|
|
765
|
+
exportFormData(format?: string | null): Uint8Array;
|
|
766
|
+
/**
|
|
767
|
+
* Extract plain text from all pages, separated by form feed characters.
|
|
768
|
+
*/
|
|
769
|
+
extractAllText(): string;
|
|
770
|
+
/**
|
|
771
|
+
* Extract character-level data from a page.
|
|
772
|
+
*
|
|
773
|
+
* Returns an array of objects with: char, bbox {x, y, width, height},
|
|
774
|
+
* font_name, font_size, font_weight, is_italic, color {r, g, b}, etc.
|
|
775
|
+
*
|
|
776
|
+
* @param page_index - Zero-based page number
|
|
777
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
778
|
+
*/
|
|
779
|
+
extractChars(page_index: number, region?: Float32Array | null): any;
|
|
780
|
+
/**
|
|
781
|
+
* Extract image bytes from a page as PNG data.
|
|
782
|
+
*
|
|
783
|
+
* Returns an array of objects with: width, height, data (Uint8Array of PNG bytes), format ("png").
|
|
784
|
+
*/
|
|
785
|
+
extractImageBytes(page_index: number): any;
|
|
786
|
+
/**
|
|
787
|
+
* Extract image metadata from a page.
|
|
788
|
+
*
|
|
789
|
+
* Returns an array of objects with: width, height, color_space,
|
|
790
|
+
* bits_per_component, bbox (if available). Does NOT return raw image bytes.
|
|
791
|
+
*
|
|
792
|
+
* @param page_index - Zero-based page number
|
|
793
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
794
|
+
*/
|
|
795
|
+
extractImages(page_index: number, region?: Float32Array | null): any;
|
|
796
|
+
/**
|
|
797
|
+
* Extract only straight lines from a page (v0.3.14).
|
|
798
|
+
*
|
|
799
|
+
* Identifies paths that form a single straight line segment.
|
|
800
|
+
*
|
|
801
|
+
* @param page_index - Zero-based page number
|
|
802
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
803
|
+
* @returns Array of path objects
|
|
804
|
+
*/
|
|
805
|
+
extractLines(page_index: number, region?: Float32Array | null): any;
|
|
806
|
+
/**
|
|
807
|
+
* Extract complete page text data in a single call.
|
|
808
|
+
*
|
|
809
|
+
* Returns `{ spans, chars, page_width, page_height }`.
|
|
810
|
+
* The `chars` are derived from spans using font-metric widths when available.
|
|
811
|
+
*
|
|
812
|
+
* Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
|
|
813
|
+
* or `"top_to_bottom"` (default).
|
|
814
|
+
*/
|
|
815
|
+
extractPageText(page_index: number, reading_order?: string | null): any;
|
|
816
|
+
/**
|
|
817
|
+
* Extract specific pages to a new PDF (returns bytes).
|
|
818
|
+
*/
|
|
819
|
+
extractPages(pages: Uint32Array): Uint8Array;
|
|
820
|
+
/**
|
|
821
|
+
* Extract vector paths (lines, curves, shapes) from a page.
|
|
822
|
+
*
|
|
823
|
+
* @param page_index - Zero-based page number
|
|
824
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
825
|
+
* @returns Array of path objects with bbox, stroke_color, fill_color, etc.
|
|
826
|
+
*/
|
|
827
|
+
extractPaths(page_index: number, region?: Float32Array | null): any;
|
|
828
|
+
/**
|
|
829
|
+
* Extract only rectangles from a page (v0.3.14).
|
|
830
|
+
*
|
|
831
|
+
* Identifies paths that form axis-aligned rectangles.
|
|
832
|
+
*
|
|
833
|
+
* @param page_index - Zero-based page number
|
|
834
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
835
|
+
* @returns Array of path objects
|
|
836
|
+
*/
|
|
837
|
+
extractRects(page_index: number, region?: Float32Array | null): any;
|
|
838
|
+
/**
|
|
839
|
+
* Extract span-level data from a page.
|
|
840
|
+
*
|
|
841
|
+
* Returns an array of objects with: text, bbox, font_name, font_size,
|
|
842
|
+
* font_weight, is_italic, color, etc.
|
|
843
|
+
*
|
|
844
|
+
* Optional `reading_order`: `"column_aware"` for XY-Cut column detection,
|
|
845
|
+
* or `"top_to_bottom"` (default).
|
|
846
|
+
*/
|
|
847
|
+
extractSpans(page_index: number, region?: Float32Array | null, reading_order?: string | null): any;
|
|
848
|
+
/**
|
|
849
|
+
* Extract tables from a page (v0.3.14).
|
|
850
|
+
*
|
|
851
|
+
* @param page_index - Zero-based page number
|
|
852
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
853
|
+
*/
|
|
854
|
+
extractTables(page_index: number, region?: Float32Array | null): any;
|
|
855
|
+
/**
|
|
856
|
+
* Extract plain text from a single page.
|
|
857
|
+
*
|
|
858
|
+
* @param page_index - Zero-based page number
|
|
859
|
+
* @param region - Optional [x, y, width, height] to filter by
|
|
860
|
+
*/
|
|
861
|
+
extractText(page_index: number, region: any): string;
|
|
862
|
+
/**
|
|
863
|
+
* Extract text lines from a page.
|
|
864
|
+
*
|
|
865
|
+
* Returns an array of objects with: text, bbox, words (array of Word objects).
|
|
866
|
+
*/
|
|
867
|
+
extractTextLines(page_index: number, region?: Float32Array | null): any;
|
|
868
|
+
/**
|
|
869
|
+
* Extract text using OCR (optical character recognition).
|
|
870
|
+
*
|
|
871
|
+
* NOTE: OCR is not yet supported in the WebAssembly build due to missing
|
|
872
|
+
* ONNX Runtime support for the web backend in the current implementation.
|
|
873
|
+
*/
|
|
874
|
+
extractTextOcr(_page_index: number, _engine?: WasmOcrEngine | null): string;
|
|
875
|
+
/**
|
|
876
|
+
* Extract word-level data from a page.
|
|
877
|
+
*
|
|
878
|
+
* Returns an array of objects with: text, bbox, font_name, font_size,
|
|
879
|
+
* font_weight, is_italic, is_bold.
|
|
880
|
+
*/
|
|
881
|
+
extractWords(page_index: number, region?: Float32Array | null): any;
|
|
882
|
+
/**
|
|
883
|
+
* Flatten all annotations in the document into page content.
|
|
884
|
+
*/
|
|
885
|
+
flattenAllAnnotations(): void;
|
|
886
|
+
/**
|
|
887
|
+
* Flatten all form fields into page content.
|
|
888
|
+
*
|
|
889
|
+
* After flattening, form field values become static text and are no longer editable.
|
|
890
|
+
*/
|
|
891
|
+
flattenForms(): void;
|
|
892
|
+
/**
|
|
893
|
+
* Flatten form fields on a specific page.
|
|
894
|
+
*
|
|
895
|
+
* @param page_index - Zero-based page number
|
|
896
|
+
*/
|
|
897
|
+
flattenFormsOnPage(page_index: number): void;
|
|
898
|
+
/**
|
|
899
|
+
* Flatten annotations on a page into the page content.
|
|
900
|
+
*/
|
|
901
|
+
flattenPageAnnotations(page_index: number): void;
|
|
902
|
+
/**
|
|
903
|
+
* Return warnings collected during the last form-flattening save.
|
|
904
|
+
*
|
|
905
|
+
* Each entry names a widget field that had no `/AP` appearance stream;
|
|
906
|
+
* flattening such a field produces a blank rectangle.
|
|
907
|
+
*
|
|
908
|
+
* @returns Array of warning strings
|
|
909
|
+
*/
|
|
910
|
+
flattenWarnings(): string[];
|
|
911
|
+
/**
|
|
912
|
+
* Get annotations from a page.
|
|
913
|
+
*
|
|
914
|
+
* @param page_index - Zero-based page number
|
|
915
|
+
* @returns Array of annotation objects with fields like subtype, rect, contents, etc.
|
|
916
|
+
*/
|
|
917
|
+
getAnnotations(page_index: number): any;
|
|
918
|
+
/**
|
|
919
|
+
* Get the value of a specific form field by name.
|
|
920
|
+
*
|
|
921
|
+
* @param name - Full qualified field name (e.g., "name" or "topmostSubform[0].Page1[0].f1_01[0]")
|
|
922
|
+
* @returns The field value: string for text, boolean for checkbox, null if not found
|
|
923
|
+
*/
|
|
924
|
+
getFormFieldValue(name: string): any;
|
|
925
|
+
/**
|
|
926
|
+
* Get all form fields from the document.
|
|
927
|
+
*
|
|
928
|
+
* Returns an array of form field objects, each with:
|
|
929
|
+
* - name: Full qualified field name
|
|
930
|
+
* - field_type: "text", "button", "choice", "signature", or "unknown"
|
|
931
|
+
* - value: string, boolean, array of strings, or null
|
|
932
|
+
* - tooltip: string or null
|
|
933
|
+
* - bounds: [x1, y1, x2, y2] or null
|
|
934
|
+
* - flags: number or null
|
|
935
|
+
* - max_length: number or null
|
|
936
|
+
* - is_readonly: boolean
|
|
937
|
+
* - is_required: boolean
|
|
938
|
+
*/
|
|
939
|
+
getFormFields(): any;
|
|
940
|
+
/**
|
|
941
|
+
* Get the document outline (bookmarks / table of contents).
|
|
942
|
+
*
|
|
943
|
+
* @returns Array of outline items or null if no outline exists.
|
|
944
|
+
* Each item has: { title, page (number|null), dest_name (string, optional), children (array) }
|
|
945
|
+
*/
|
|
946
|
+
getOutline(): any;
|
|
947
|
+
/**
|
|
948
|
+
* Check if the document has a structure tree (Tagged PDF).
|
|
949
|
+
*/
|
|
950
|
+
hasStructureTree(): boolean;
|
|
951
|
+
/**
|
|
952
|
+
* Check if the document contains XFA form data.
|
|
953
|
+
*
|
|
954
|
+
* @returns true if the document has XFA form data
|
|
955
|
+
*/
|
|
956
|
+
hasXfa(): boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Merge another PDF (provided as bytes) into this document.
|
|
959
|
+
*
|
|
960
|
+
* @param data - The PDF file contents to merge as a Uint8Array
|
|
961
|
+
* @returns Number of pages merged
|
|
962
|
+
*/
|
|
963
|
+
mergeFrom(data: Uint8Array): number;
|
|
964
|
+
/**
|
|
965
|
+
* Move a page within the document. Zero-based; `from_index` and
|
|
966
|
+
* `to_index` refer to positions **before** the move, matching the
|
|
967
|
+
* Python (`PyPdfDocument.move_page`) / Go (`DocumentEditor.MovePage`) /
|
|
968
|
+
* C# contracts.
|
|
969
|
+
*/
|
|
970
|
+
movePage(from_index: number, to_index: number): void;
|
|
971
|
+
/**
|
|
972
|
+
* Load a PDF document from raw bytes.
|
|
973
|
+
*
|
|
974
|
+
* @param data - PDF file contents as Uint8Array
|
|
975
|
+
* @param password - Optional password for encrypted PDFs
|
|
976
|
+
* @throws Error if the PDF is invalid or cannot be parsed
|
|
977
|
+
*/
|
|
978
|
+
constructor(data: Uint8Array, password?: string | null);
|
|
979
|
+
/**
|
|
980
|
+
* Get the number of pages in the document.
|
|
981
|
+
*/
|
|
982
|
+
pageCount(): number;
|
|
983
|
+
/**
|
|
984
|
+
* Get the CropBox of a page as [llx, lly, urx, ury], or null if not set.
|
|
985
|
+
*/
|
|
986
|
+
pageCropBox(page_index: number): any;
|
|
987
|
+
/**
|
|
988
|
+
* Get information about images on a page.
|
|
989
|
+
*
|
|
990
|
+
* Returns an array of {name, bounds: [x, y, width, height], matrix: [a, b, c, d, e, f]}.
|
|
991
|
+
*/
|
|
992
|
+
pageImages(page_index: number): any;
|
|
993
|
+
/**
|
|
994
|
+
* Get page label ranges from the document.
|
|
995
|
+
*
|
|
996
|
+
* @returns Array of {start_page, style, prefix, start_value} objects, or empty array
|
|
997
|
+
*/
|
|
998
|
+
pageLabels(): any;
|
|
999
|
+
/**
|
|
1000
|
+
* Get the MediaBox of a page as [llx, lly, urx, ury].
|
|
1001
|
+
*/
|
|
1002
|
+
pageMediaBox(page_index: number): Float32Array;
|
|
1003
|
+
/**
|
|
1004
|
+
* Get the rotation of a page in degrees (0, 90, 180, 270).
|
|
1005
|
+
*/
|
|
1006
|
+
pageRotation(page_index: number): number;
|
|
1007
|
+
/**
|
|
1008
|
+
* Identify and remove both headers and footers.
|
|
1009
|
+
*
|
|
1010
|
+
* Prioritizes ISO 32000 spec-compliant /Artifact tags, with a heuristic
|
|
1011
|
+
* fallback for untagged PDFs.
|
|
1012
|
+
*
|
|
1013
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1014
|
+
*/
|
|
1015
|
+
removeArtifacts(threshold: number): number;
|
|
1016
|
+
/**
|
|
1017
|
+
* Identify and remove footers.
|
|
1018
|
+
*
|
|
1019
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1020
|
+
* falls back to heuristic analysis of the bottom 15% of pages.
|
|
1021
|
+
*
|
|
1022
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1023
|
+
*/
|
|
1024
|
+
removeFooters(threshold: number): number;
|
|
1025
|
+
/**
|
|
1026
|
+
* Identify and remove headers.
|
|
1027
|
+
*
|
|
1028
|
+
* Uses spec-compliant /Artifact tags when available (100% accuracy), or
|
|
1029
|
+
* falls back to heuristic analysis of the top 15% of pages.
|
|
1030
|
+
*
|
|
1031
|
+
* @param threshold - Fraction of pages (0.0-1.0) where text must repeat (heuristic mode)
|
|
1032
|
+
*/
|
|
1033
|
+
removeHeaders(threshold: number): number;
|
|
1034
|
+
/**
|
|
1035
|
+
* Reposition an image on a page.
|
|
1036
|
+
*/
|
|
1037
|
+
repositionImage(page_index: number, name: string, x: number, y: number): void;
|
|
1038
|
+
/**
|
|
1039
|
+
* Resize an image on a page.
|
|
1040
|
+
*/
|
|
1041
|
+
resizeImage(page_index: number, name: string, width: number, height: number): void;
|
|
1042
|
+
/**
|
|
1043
|
+
* Rotate all pages by the given degrees.
|
|
1044
|
+
*/
|
|
1045
|
+
rotateAllPages(degrees: number): void;
|
|
1046
|
+
/**
|
|
1047
|
+
* Rotate a page by the given degrees (adds to current rotation).
|
|
1048
|
+
*/
|
|
1049
|
+
rotatePage(page_index: number, degrees: number): void;
|
|
1050
|
+
/**
|
|
1051
|
+
* Save all edits and return the resulting PDF as bytes.
|
|
1052
|
+
*
|
|
1053
|
+
* @returns Uint8Array containing the modified PDF
|
|
1054
|
+
*/
|
|
1055
|
+
save(): Uint8Array;
|
|
1056
|
+
/**
|
|
1057
|
+
* Save with encryption and return the resulting PDF as bytes.
|
|
1058
|
+
*/
|
|
1059
|
+
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;
|
|
1060
|
+
/**
|
|
1061
|
+
* Save the modified PDF and return as bytes.
|
|
1062
|
+
* `saveToBytes()` is the original method; `save()` is a convenience alias.
|
|
1063
|
+
*
|
|
1064
|
+
* @returns Uint8Array containing the modified PDF
|
|
1065
|
+
*/
|
|
1066
|
+
saveToBytes(): Uint8Array;
|
|
1067
|
+
/**
|
|
1068
|
+
* Save with options (compress, garbage_collect, linearize) and return bytes.
|
|
1069
|
+
*
|
|
1070
|
+
* @param {Object} [options] - Optional save options.
|
|
1071
|
+
* @param {boolean} [options.compress=true] - Compress raw streams with FlateDecode.
|
|
1072
|
+
* @param {boolean} [options.garbageCollect=true] - Remove unreachable objects.
|
|
1073
|
+
* @param {boolean} [options.linearize=false] - Linearize (reserved, no-op).
|
|
1074
|
+
* @returns Uint8Array containing the modified PDF
|
|
1075
|
+
*/
|
|
1076
|
+
saveWithOptions(compress?: boolean | null, garbage_collect?: boolean | null, linearize?: boolean | null): Uint8Array;
|
|
1077
|
+
/**
|
|
1078
|
+
* Search for text across all pages.
|
|
1079
|
+
*
|
|
1080
|
+
* @param pattern - Regex pattern or literal text to search for
|
|
1081
|
+
* @param case_insensitive - Case insensitive search (default: false)
|
|
1082
|
+
* @param literal - Treat pattern as literal text, not regex (default: false)
|
|
1083
|
+
* @param whole_word - Match whole words only (default: false)
|
|
1084
|
+
* @param max_results - Maximum results to return, 0 = unlimited (default: 0)
|
|
1085
|
+
*
|
|
1086
|
+
* Returns an array of {page, text, bbox, start_index, end_index, span_boxes}.
|
|
1087
|
+
*/
|
|
1088
|
+
search(pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
|
|
1089
|
+
/**
|
|
1090
|
+
* Search for text on a specific page.
|
|
1091
|
+
*/
|
|
1092
|
+
searchPage(page_index: number, pattern: string, case_insensitive?: boolean | null, literal?: boolean | null, whole_word?: boolean | null, max_results?: number | null): any;
|
|
1093
|
+
/**
|
|
1094
|
+
* Set the document author.
|
|
1095
|
+
*/
|
|
1096
|
+
setAuthor(author: string): void;
|
|
1097
|
+
/**
|
|
1098
|
+
* Set the value of a form field.
|
|
1099
|
+
*
|
|
1100
|
+
* @param name - Full qualified field name
|
|
1101
|
+
* @param value - New value: string for text fields, boolean for checkboxes
|
|
1102
|
+
*/
|
|
1103
|
+
setFormFieldValue(name: string, value: any): void;
|
|
1104
|
+
/**
|
|
1105
|
+
* Set the complete bounds of an image on a page.
|
|
1106
|
+
*/
|
|
1107
|
+
setImageBounds(page_index: number, name: string, x: number, y: number, width: number, height: number): void;
|
|
1108
|
+
/**
|
|
1109
|
+
* Set the document keywords.
|
|
1110
|
+
*/
|
|
1111
|
+
setKeywords(keywords: string): void;
|
|
1112
|
+
/**
|
|
1113
|
+
* Set the CropBox of a page.
|
|
1114
|
+
*/
|
|
1115
|
+
setPageCropBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
|
|
1116
|
+
/**
|
|
1117
|
+
* Set the MediaBox of a page.
|
|
1118
|
+
*/
|
|
1119
|
+
setPageMediaBox(page_index: number, llx: number, lly: number, urx: number, ury: number): void;
|
|
1120
|
+
/**
|
|
1121
|
+
* Set the rotation of a page (0, 90, 180, or 270 degrees).
|
|
1122
|
+
*/
|
|
1123
|
+
setPageRotation(page_index: number, degrees: number): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* Set the document subject.
|
|
1126
|
+
*/
|
|
1127
|
+
setSubject(subject: string): void;
|
|
1128
|
+
/**
|
|
1129
|
+
* Set the document title.
|
|
1130
|
+
*/
|
|
1131
|
+
setTitle(title: string): void;
|
|
1132
|
+
/**
|
|
1133
|
+
* Count existing PDF signatures. Returns 0 when the document has
|
|
1134
|
+
* no AcroForm or no signed signature fields.
|
|
1135
|
+
*/
|
|
1136
|
+
signatureCount(): number;
|
|
1137
|
+
/**
|
|
1138
|
+
* Enumerate existing PDF signatures. Each entry is a
|
|
1139
|
+
* `WasmSignature` (inspection-only) mirroring the C# and Python
|
|
1140
|
+
* Signature surfaces.
|
|
1141
|
+
*/
|
|
1142
|
+
signatures(): WasmSignature[];
|
|
1143
|
+
/**
|
|
1144
|
+
* Convert a single page to HTML.
|
|
1145
|
+
*
|
|
1146
|
+
* @param page_index - Zero-based page number
|
|
1147
|
+
* @param preserve_layout - Use CSS positioning to preserve layout (default: false)
|
|
1148
|
+
* @param detect_headings - Whether to detect headings (default: true)
|
|
1149
|
+
*/
|
|
1150
|
+
toHtml(page_index: number, preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
|
|
1151
|
+
/**
|
|
1152
|
+
* Convert all pages to HTML.
|
|
1153
|
+
*/
|
|
1154
|
+
toHtmlAll(preserve_layout?: boolean | null, detect_headings?: boolean | null, include_form_fields?: boolean | null): string;
|
|
1155
|
+
/**
|
|
1156
|
+
* Convert a single page to Markdown.
|
|
1157
|
+
*
|
|
1158
|
+
* @param page_index - Zero-based page number
|
|
1159
|
+
* @param detect_headings - Whether to detect headings (default: true)
|
|
1160
|
+
* @param include_images - Whether to include images (default: false)
|
|
1161
|
+
*/
|
|
1162
|
+
toMarkdown(page_index: number, detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
|
|
1163
|
+
/**
|
|
1164
|
+
* Convert all pages to Markdown.
|
|
1165
|
+
*/
|
|
1166
|
+
toMarkdownAll(detect_headings?: boolean | null, include_images?: boolean | null, include_form_fields?: boolean | null): string;
|
|
1167
|
+
/**
|
|
1168
|
+
* Convert a single page to plain text (with layout preservation options).
|
|
1169
|
+
*/
|
|
1170
|
+
toPlainText(page_index: number): string;
|
|
1171
|
+
/**
|
|
1172
|
+
* Convert all pages to plain text.
|
|
1173
|
+
*/
|
|
1174
|
+
toPlainTextAll(): string;
|
|
1175
|
+
/**
|
|
1176
|
+
* Validate PDF/A compliance. Level: "1b", "2b", etc.
|
|
1177
|
+
*/
|
|
1178
|
+
validatePdfA(level: string): any;
|
|
1179
|
+
/**
|
|
1180
|
+
* Validate PDF/UA accessibility compliance.
|
|
1181
|
+
*/
|
|
1182
|
+
validatePdfUa(level?: string | null): any;
|
|
1183
|
+
/**
|
|
1184
|
+
* Validate PDF/X print production compliance.
|
|
1185
|
+
*/
|
|
1186
|
+
validatePdfX(level?: string | null): any;
|
|
1187
|
+
/**
|
|
1188
|
+
* Get the PDF version as [major, minor].
|
|
1189
|
+
*/
|
|
1190
|
+
version(): Uint8Array;
|
|
1191
|
+
/**
|
|
1192
|
+
* Focus extraction on a specific rectangular region of a page (v0.3.14).
|
|
1193
|
+
*
|
|
1194
|
+
* @param page_index - Zero-based page number
|
|
1195
|
+
* @param region - [x, y, width, height] in points
|
|
1196
|
+
*/
|
|
1197
|
+
within(page_index: number, region: Float32Array): WasmPdfPageRegion;
|
|
1198
|
+
/**
|
|
1199
|
+
* Get XMP metadata from the document.
|
|
1200
|
+
*
|
|
1201
|
+
* @returns Object with XMP fields (dc_title, dc_creator, etc.) or null if no XMP
|
|
1202
|
+
*/
|
|
1203
|
+
xmpMetadata(): any;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* A focused view of a PDF page region for scoped extraction (v0.3.14).
|
|
1208
|
+
*/
|
|
1209
|
+
export class WasmPdfPageRegion {
|
|
1210
|
+
private constructor();
|
|
1211
|
+
free(): void;
|
|
1212
|
+
[Symbol.dispose](): void;
|
|
1213
|
+
/**
|
|
1214
|
+
* Extract character-level data from this region.
|
|
1215
|
+
*/
|
|
1216
|
+
extractChars(): any;
|
|
1217
|
+
/**
|
|
1218
|
+
* Extract images from this region.
|
|
1219
|
+
*/
|
|
1220
|
+
extractImages(): any;
|
|
1221
|
+
/**
|
|
1222
|
+
* Extract straight lines from this region.
|
|
1223
|
+
*/
|
|
1224
|
+
extractLines(): any;
|
|
1225
|
+
/**
|
|
1226
|
+
* Extract vector paths from this region.
|
|
1227
|
+
*/
|
|
1228
|
+
extractPaths(): any;
|
|
1229
|
+
/**
|
|
1230
|
+
* Extract rectangles from this region.
|
|
1231
|
+
*/
|
|
1232
|
+
extractRects(): any;
|
|
1233
|
+
/**
|
|
1234
|
+
* Extract tables from this region.
|
|
1235
|
+
*/
|
|
1236
|
+
extractTables(): any;
|
|
1237
|
+
/**
|
|
1238
|
+
* Extract text from this region.
|
|
1239
|
+
*/
|
|
1240
|
+
extractText(): string;
|
|
1241
|
+
/**
|
|
1242
|
+
* Extract text lines from this region.
|
|
1243
|
+
*/
|
|
1244
|
+
extractTextLines(): any;
|
|
1245
|
+
/**
|
|
1246
|
+
* Extract text using OCR from this region.
|
|
1247
|
+
*/
|
|
1248
|
+
extractTextOcr(_engine?: WasmOcrEngine | null): string;
|
|
1249
|
+
/**
|
|
1250
|
+
* Extract words from this region.
|
|
1251
|
+
*/
|
|
1252
|
+
extractWords(): any;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* A single existing PDF signature surfaced by
|
|
1257
|
+
* `WasmPdfDocument.signatures()`. `verify()` runs the RSA-PKCS#1 v1.5
|
|
1258
|
+
* signer-attributes check; `verifyDetached()` adds the
|
|
1259
|
+
* `messageDigest` content-hash check. RSA-PSS / ECDSA signers still
|
|
1260
|
+
* throw an `UnsupportedFeature`-mapped JS error.
|
|
1261
|
+
*/
|
|
1262
|
+
export class WasmSignature {
|
|
1263
|
+
private constructor();
|
|
1264
|
+
free(): void;
|
|
1265
|
+
[Symbol.dispose](): void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Run the RFC 5652 §5.4 signer-attributes crypto check. Today
|
|
1268
|
+
* this covers RSA-PKCS#1 v1.5 over SHA-1/256/384/512 — the
|
|
1269
|
+
* padding used by essentially every PDF signature.
|
|
1270
|
+
*
|
|
1271
|
+
* A `true` return proves the signer held the private key matching
|
|
1272
|
+
* the embedded certificate and that the signed-attribute bundle
|
|
1273
|
+
* is authentic. It does **not** verify the `messageDigest`
|
|
1274
|
+
* attribute against the document's byte-range content hash —
|
|
1275
|
+
* call `verifyDetached()` for that end-to-end check.
|
|
1276
|
+
*
|
|
1277
|
+
* Throws for RSA-PSS, ECDSA, unknown digest OIDs, or signatures
|
|
1278
|
+
* without signed_attrs.
|
|
1279
|
+
*/
|
|
1280
|
+
verify(): boolean;
|
|
1281
|
+
/**
|
|
1282
|
+
* End-to-end detached-signature verification. Runs both the
|
|
1283
|
+
* signer-attributes RSA-PKCS#1 v1.5 crypto check AND the RFC 5652
|
|
1284
|
+
* §11.2 `messageDigest` check against the segment of `pdfData`
|
|
1285
|
+
* this signature covers (extracted via `/ByteRange`).
|
|
1286
|
+
*
|
|
1287
|
+
* `pdfData` must be the full PDF file. A `true` result proves
|
|
1288
|
+
* both the signer is authentic and that the document's byte-range
|
|
1289
|
+
* content has not been altered since signing. `false` means one
|
|
1290
|
+
* of the two checks failed (wrong key or tampered content).
|
|
1291
|
+
*
|
|
1292
|
+
* Throws for RSA-PSS, ECDSA, unknown digest OIDs, or CMS blobs
|
|
1293
|
+
* missing `signed_attrs` / `messageDigest`.
|
|
1294
|
+
*/
|
|
1295
|
+
verifyDetached(pdf_data: Uint8Array): boolean;
|
|
1296
|
+
/**
|
|
1297
|
+
* `/ContactInfo` entry from the signature dictionary, if present.
|
|
1298
|
+
*/
|
|
1299
|
+
readonly contactInfo: string | undefined;
|
|
1300
|
+
/**
|
|
1301
|
+
* True iff `/ByteRange` is a 4-element array covering the whole
|
|
1302
|
+
* document (i.e. the signature protects every byte of the file).
|
|
1303
|
+
*/
|
|
1304
|
+
readonly coversWholeDocument: boolean;
|
|
1305
|
+
/**
|
|
1306
|
+
* `/Location` entry from the signature dictionary, if present.
|
|
1307
|
+
*/
|
|
1308
|
+
readonly location: string | undefined;
|
|
1309
|
+
/**
|
|
1310
|
+
* `/Reason` entry from the signature dictionary, if present.
|
|
1311
|
+
*/
|
|
1312
|
+
readonly reason: string | undefined;
|
|
1313
|
+
/**
|
|
1314
|
+
* `/Name` entry from the signature dictionary, if present.
|
|
1315
|
+
*/
|
|
1316
|
+
readonly signerName: string | undefined;
|
|
1317
|
+
/**
|
|
1318
|
+
* Unix epoch (seconds). `None` if the `/M` entry is missing or
|
|
1319
|
+
* unparseable.
|
|
1320
|
+
*/
|
|
1321
|
+
readonly signingTime: bigint | undefined;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* RFC 3161 timestamp parsed from a DER TimeStampToken or bare
|
|
1326
|
+
* TSTInfo. Mirrors the C#, Go, and Python `Timestamp` surfaces.
|
|
1327
|
+
*/
|
|
1328
|
+
export class WasmTimestamp {
|
|
1329
|
+
private constructor();
|
|
1330
|
+
free(): void;
|
|
1331
|
+
[Symbol.dispose](): void;
|
|
1332
|
+
/**
|
|
1333
|
+
* Parse a DER blob that may be either a full TimeStampToken or
|
|
1334
|
+
* the bare TSTInfo SEQUENCE.
|
|
1335
|
+
*/
|
|
1336
|
+
static parse(data: Uint8Array): WasmTimestamp;
|
|
1337
|
+
/**
|
|
1338
|
+
* Cryptographic verify — not yet implemented.
|
|
1339
|
+
*/
|
|
1340
|
+
verify(): boolean;
|
|
1341
|
+
/**
|
|
1342
|
+
* Hash algorithm enum value (1=SHA1, 2=SHA256, 3=SHA384,
|
|
1343
|
+
* 4=SHA512, 0=unknown).
|
|
1344
|
+
*/
|
|
1345
|
+
readonly hashAlgorithm: number;
|
|
1346
|
+
/**
|
|
1347
|
+
* Raw message-imprint hash bytes.
|
|
1348
|
+
*/
|
|
1349
|
+
readonly messageImprint: Uint8Array;
|
|
1350
|
+
/**
|
|
1351
|
+
* TSA policy OID in dotted-decimal form.
|
|
1352
|
+
*/
|
|
1353
|
+
readonly policyOid: string;
|
|
1354
|
+
/**
|
|
1355
|
+
* Serial number as a hex string (no `0x` prefix).
|
|
1356
|
+
*/
|
|
1357
|
+
readonly serial: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Generation time as Unix epoch seconds.
|
|
1360
|
+
*/
|
|
1361
|
+
readonly time: bigint;
|
|
1362
|
+
/**
|
|
1363
|
+
* TSA name from the token (may be empty).
|
|
1364
|
+
*/
|
|
1365
|
+
readonly tsaName: string;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Disable all pdf_oxide log output — convenience wrapper for
|
|
1370
|
+
* `setLogLevel("off")`.
|
|
1371
|
+
*/
|
|
1372
|
+
export function disableLogging(): void;
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Set the maximum log level for pdf_oxide messages.
|
|
1376
|
+
*
|
|
1377
|
+
* Accepts one of: `"off"`, `"error"`, `"warn"` / `"warning"`, `"info"`,
|
|
1378
|
+
* `"debug"`, `"trace"`. Case-insensitive. Default is `"off"` — the library
|
|
1379
|
+
* is silent unless explicitly enabled.
|
|
1380
|
+
*
|
|
1381
|
+
* Logs are forwarded to the browser console (`console.log`, `console.warn`,
|
|
1382
|
+
* `console.error`, etc.). Fixes issue #280.
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```javascript
|
|
1386
|
+
* import init, { setLogLevel } from "pdf-oxide-wasm";
|
|
1387
|
+
* await init();
|
|
1388
|
+
* setLogLevel("warn");
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
export function setLogLevel(level: string): void;
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Sign raw PDF bytes and return the signed PDF as a `Uint8Array`.
|
|
1395
|
+
*
|
|
1396
|
+
* `cert` must carry a private key (loaded via `Certificate.loadPem` or
|
|
1397
|
+
* `Certificate.loadPkcs12`).
|
|
1398
|
+
*/
|
|
1399
|
+
export function signPdfBytes(pdf_data: Uint8Array, cert: WasmCertificate, reason?: string | null, location?: string | null): Uint8Array;
|