@laminapdf/wasm 0.2.0-alpha.3 → 0.2.0-alpha.5
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/dist/lamina_pdf_base.d.ts +3 -2
- package/dist/lamina_pdf_base.js +2 -1
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +539 -2
- package/dist/lamina_pdf_extract.js +218 -1
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.d.ts +7 -4
- package/dist/lamina_pdf_render_hayro.js +10 -4
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +542 -3
- package/dist/lamina_pdf_text.js +190 -1
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +1 -1
|
@@ -32,6 +32,18 @@ export interface Diagnostic {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
/** One link on a page, in page space, and what following it does (by `kind`). */
|
|
37
|
+
export type PageLinkJs = {
|
|
38
|
+
/** Its rectangle: `[x0, y0, x1, y1]`, top-left and bottom-right. */
|
|
39
|
+
rect: [number, number, number, number];
|
|
40
|
+
/** The areas that follow it, eight numbers per area; absent when the rectangle is the area. */
|
|
41
|
+
quads?: number[];
|
|
42
|
+
/** Its description (`/Contents`, document text). */
|
|
43
|
+
contents?: string;
|
|
44
|
+
} & LinkToJs;
|
|
45
|
+
|
|
46
|
+
|
|
35
47
|
/**
|
|
36
48
|
* A colour for text options (the text module's records).
|
|
37
49
|
*/
|
|
@@ -42,6 +54,93 @@ export type ColorInit = number[] | string;
|
|
|
42
54
|
*/
|
|
43
55
|
export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
|
|
44
56
|
|
|
57
|
+
/**
|
|
58
|
+
* A document's properties, for a properties view.
|
|
59
|
+
*/
|
|
60
|
+
export interface PropertiesJs {
|
|
61
|
+
/**
|
|
62
|
+
* `/Title`.
|
|
63
|
+
*/
|
|
64
|
+
title?: string;
|
|
65
|
+
/**
|
|
66
|
+
* `/Author`.
|
|
67
|
+
*/
|
|
68
|
+
author?: string;
|
|
69
|
+
/**
|
|
70
|
+
* `/Subject`.
|
|
71
|
+
*/
|
|
72
|
+
subject?: string;
|
|
73
|
+
/**
|
|
74
|
+
* `/Keywords`.
|
|
75
|
+
*/
|
|
76
|
+
keywords?: string;
|
|
77
|
+
/**
|
|
78
|
+
* `/Creator`: the application the document was made with.
|
|
79
|
+
*/
|
|
80
|
+
creator?: string;
|
|
81
|
+
/**
|
|
82
|
+
* `/Producer`: the application that wrote the PDF.
|
|
83
|
+
*/
|
|
84
|
+
producer?: string;
|
|
85
|
+
/**
|
|
86
|
+
* `/CreationDate` as ISO 8601.
|
|
87
|
+
*/
|
|
88
|
+
created?: string;
|
|
89
|
+
/**
|
|
90
|
+
* `/ModDate` as ISO 8601.
|
|
91
|
+
*/
|
|
92
|
+
modified?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The XMP packet as text.
|
|
95
|
+
*/
|
|
96
|
+
xmp?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The PDF version.
|
|
99
|
+
*/
|
|
100
|
+
version?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The number of pages.
|
|
103
|
+
*/
|
|
104
|
+
pageCount: number;
|
|
105
|
+
/**
|
|
106
|
+
* The file's size in bytes.
|
|
107
|
+
*/
|
|
108
|
+
fileSize: number;
|
|
109
|
+
/**
|
|
110
|
+
* The file is linearized ("fast web view").
|
|
111
|
+
*/
|
|
112
|
+
linearized: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* The catalog says the document is tagged.
|
|
115
|
+
*/
|
|
116
|
+
tagged: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* How the file is encrypted; absent when it isn't.
|
|
119
|
+
*/
|
|
120
|
+
encryption?: EncryptionJs;
|
|
121
|
+
/**
|
|
122
|
+
* The fonts the pages use.
|
|
123
|
+
*/
|
|
124
|
+
fonts: FontJs[];
|
|
125
|
+
/**
|
|
126
|
+
* The signatures present, not verified.
|
|
127
|
+
*/
|
|
128
|
+
signatures: number;
|
|
129
|
+
/**
|
|
130
|
+
* The signature fields' full names.
|
|
131
|
+
*/
|
|
132
|
+
signatureFields: string[];
|
|
133
|
+
/**
|
|
134
|
+
* What the document holds besides its pages.
|
|
135
|
+
*/
|
|
136
|
+
contains: ContainsJs;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A font's encoding: a named one (`WinAnsiEncoding`, `Identity-H`), or the font's own.
|
|
141
|
+
*/
|
|
142
|
+
export type EncodingJs = { kind: "named"; name: string } | { kind: "custom" };
|
|
143
|
+
|
|
45
144
|
/**
|
|
46
145
|
* A job's progress (`laminapdf::Step::Progress`).
|
|
47
146
|
*/
|
|
@@ -55,11 +154,35 @@ export interface ProgressJs {
|
|
|
55
154
|
*/
|
|
56
155
|
total?: number;
|
|
57
156
|
/**
|
|
58
|
-
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`).
|
|
157
|
+
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`, `model`).
|
|
59
158
|
*/
|
|
60
159
|
phase: string;
|
|
61
160
|
}
|
|
62
161
|
|
|
162
|
+
/**
|
|
163
|
+
* A kid of a structure element: an element, or marked content on a page.
|
|
164
|
+
*/
|
|
165
|
+
export type StructureKidJs = ({ type: "node" } & StructureNodeJs) | { type: "content"; page: number; mcid: number };
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* A layout region, its box `[x, y, width, height]` in top-left points (ADR 0027), as the
|
|
169
|
+
* output's boxes are.
|
|
170
|
+
*/
|
|
171
|
+
export interface RegionInit {
|
|
172
|
+
/**
|
|
173
|
+
* What it is.
|
|
174
|
+
*/
|
|
175
|
+
label: RegionLabelName;
|
|
176
|
+
/**
|
|
177
|
+
* `[x, y, width, height]`.
|
|
178
|
+
*/
|
|
179
|
+
bbox: [number, number, number, number];
|
|
180
|
+
/**
|
|
181
|
+
* The model's confidence, 0 to 1.
|
|
182
|
+
*/
|
|
183
|
+
score: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
63
186
|
/**
|
|
64
187
|
* A link over drawn text.
|
|
65
188
|
*/
|
|
@@ -95,6 +218,64 @@ export interface OpLog {
|
|
|
95
218
|
ops: Op[];
|
|
96
219
|
}
|
|
97
220
|
|
|
221
|
+
/**
|
|
222
|
+
* A model result the job waits for.
|
|
223
|
+
*/
|
|
224
|
+
export interface ModelRequestJs {
|
|
225
|
+
/**
|
|
226
|
+
* `layout` (regions) or `ocr` (words).
|
|
227
|
+
*/
|
|
228
|
+
kind: string;
|
|
229
|
+
/**
|
|
230
|
+
* The 0-based page to render.
|
|
231
|
+
*/
|
|
232
|
+
page: number;
|
|
233
|
+
/**
|
|
234
|
+
* The resolution to render it at.
|
|
235
|
+
*/
|
|
236
|
+
dpi: number;
|
|
237
|
+
/**
|
|
238
|
+
* OCR's languages (BCP 47); empty for the engine's default.
|
|
239
|
+
*/
|
|
240
|
+
langs: string[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A model the host runs, as the output's `generator.models` names it.
|
|
245
|
+
*/
|
|
246
|
+
export interface ModelInfoInit {
|
|
247
|
+
/**
|
|
248
|
+
* Its name.
|
|
249
|
+
*/
|
|
250
|
+
name: string;
|
|
251
|
+
/**
|
|
252
|
+
* Its version or revision.
|
|
253
|
+
*/
|
|
254
|
+
version: string;
|
|
255
|
+
/**
|
|
256
|
+
* Its weights' SHA-256, lowercase hex.
|
|
257
|
+
*/
|
|
258
|
+
sha256: string;
|
|
259
|
+
/**
|
|
260
|
+
* Its weights' SPDX licence.
|
|
261
|
+
*/
|
|
262
|
+
licence: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A page and how to show it.
|
|
267
|
+
*/
|
|
268
|
+
export interface TargetJs {
|
|
269
|
+
/**
|
|
270
|
+
* The page's 0-based index.
|
|
271
|
+
*/
|
|
272
|
+
page: number;
|
|
273
|
+
/**
|
|
274
|
+
* How to show it, in page space.
|
|
275
|
+
*/
|
|
276
|
+
view: TargetViewJs;
|
|
277
|
+
}
|
|
278
|
+
|
|
98
279
|
/**
|
|
99
280
|
* A page-label numbering style.
|
|
100
281
|
*/
|
|
@@ -122,11 +303,56 @@ export interface RectJs {
|
|
|
122
303
|
height: number;
|
|
123
304
|
}
|
|
124
305
|
|
|
306
|
+
/**
|
|
307
|
+
* A region's kind.
|
|
308
|
+
*/
|
|
309
|
+
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* A step's progress, and the model result the job waits for, if any.
|
|
313
|
+
*/
|
|
314
|
+
export interface ExtractProgressJs {
|
|
315
|
+
/**
|
|
316
|
+
* Pages done.
|
|
317
|
+
*/
|
|
318
|
+
done: number;
|
|
319
|
+
/**
|
|
320
|
+
* Pages asked for.
|
|
321
|
+
*/
|
|
322
|
+
total?: number;
|
|
323
|
+
/**
|
|
324
|
+
* `extract`, or `model` while a request is open.
|
|
325
|
+
*/
|
|
326
|
+
phase: string;
|
|
327
|
+
/**
|
|
328
|
+
* The result the job waits for: hand it to `provide`.
|
|
329
|
+
*/
|
|
330
|
+
request?: ModelRequestJs;
|
|
331
|
+
}
|
|
332
|
+
|
|
125
333
|
/**
|
|
126
334
|
* Alignment of a text box's lines.
|
|
127
335
|
*/
|
|
128
336
|
export type AlignInit = "start" | "end" | "left" | "right" | "center";
|
|
129
337
|
|
|
338
|
+
/**
|
|
339
|
+
* An OCR word, its box as a region's.
|
|
340
|
+
*/
|
|
341
|
+
export interface WordInit {
|
|
342
|
+
/**
|
|
343
|
+
* Its text.
|
|
344
|
+
*/
|
|
345
|
+
text: string;
|
|
346
|
+
/**
|
|
347
|
+
* `[x, y, width, height]`.
|
|
348
|
+
*/
|
|
349
|
+
bbox: [number, number, number, number];
|
|
350
|
+
/**
|
|
351
|
+
* The engine's confidence, 0 to 1.
|
|
352
|
+
*/
|
|
353
|
+
confidence: number;
|
|
354
|
+
}
|
|
355
|
+
|
|
130
356
|
/**
|
|
131
357
|
* An attached file's options.
|
|
132
358
|
*/
|
|
@@ -227,6 +453,32 @@ export interface SetInfo {
|
|
|
227
453
|
*/
|
|
228
454
|
export type FitInit = { type: "page" } | { type: "width"; top?: number } | { type: "height"; left?: number } | { type: "xyz"; left?: number; top?: number; zoom?: number } | { type: "rect"; x: number; y: number; width: number; height: number } | { type: "bounds" };
|
|
229
455
|
|
|
456
|
+
/**
|
|
457
|
+
* How a file is encrypted, and what its author permits.
|
|
458
|
+
*/
|
|
459
|
+
export interface EncryptionJs {
|
|
460
|
+
/**
|
|
461
|
+
* `/V`.
|
|
462
|
+
*/
|
|
463
|
+
version: number;
|
|
464
|
+
/**
|
|
465
|
+
* `/R`.
|
|
466
|
+
*/
|
|
467
|
+
revision: number;
|
|
468
|
+
/**
|
|
469
|
+
* The key length in bits.
|
|
470
|
+
*/
|
|
471
|
+
keyBits: number;
|
|
472
|
+
/**
|
|
473
|
+
* The cipher streams use.
|
|
474
|
+
*/
|
|
475
|
+
cipher: CipherJs;
|
|
476
|
+
/**
|
|
477
|
+
* What `/P` permits; absent when the handler gives no permissions.
|
|
478
|
+
*/
|
|
479
|
+
permissions?: PermissionsJs;
|
|
480
|
+
}
|
|
481
|
+
|
|
230
482
|
/**
|
|
231
483
|
* How a run of text is drawn.
|
|
232
484
|
*/
|
|
@@ -257,6 +509,11 @@ export interface TextOptionsInit {
|
|
|
257
509
|
direction?: DirectionInit;
|
|
258
510
|
}
|
|
259
511
|
|
|
512
|
+
/**
|
|
513
|
+
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
514
|
+
*/
|
|
515
|
+
export type TargetViewJs = { kind: "at"; x?: number; y?: number; zoom?: number } | { kind: "fit" } | { kind: "fit-width"; y?: number } | { kind: "fit-height"; x?: number } | { kind: "fit-rect"; x0: number; y0: number; x1: number; y1: number };
|
|
516
|
+
|
|
260
517
|
/**
|
|
261
518
|
* How a text box laid its text out.
|
|
262
519
|
*/
|
|
@@ -266,9 +523,15 @@ export interface TextLayoutJs {
|
|
|
266
523
|
*/
|
|
267
524
|
lines: LineBoxJs[];
|
|
268
525
|
/**
|
|
269
|
-
* Where the text that didn't fit starts (UTF-16 offset), if any.
|
|
526
|
+
* Where the text that didn't fit starts (UTF-16 offset), if any; `0` when no line fitted.
|
|
270
527
|
*/
|
|
271
528
|
overflow?: number;
|
|
529
|
+
/**
|
|
530
|
+
* Where the next element can start: the bottom of the last drawn line that draws
|
|
531
|
+
* something, before the surface's transform. Left out when no line does (nothing, only
|
|
532
|
+
* white space and control characters, or a box too short).
|
|
533
|
+
*/
|
|
534
|
+
bottom?: number;
|
|
272
535
|
}
|
|
273
536
|
|
|
274
537
|
/**
|
|
@@ -354,6 +617,58 @@ export interface LineBoxJs {
|
|
|
354
617
|
baseline: number;
|
|
355
618
|
}
|
|
356
619
|
|
|
620
|
+
/**
|
|
621
|
+
* One element of the structure tree (`laminapdf::StructureNode`; its strings are document text).
|
|
622
|
+
*/
|
|
623
|
+
export interface StructureNodeJs {
|
|
624
|
+
/**
|
|
625
|
+
* Its standard structure type (`H1`, `P`, `LI`, `Figure` …), through the `/RoleMap`.
|
|
626
|
+
*/
|
|
627
|
+
kind: string;
|
|
628
|
+
/**
|
|
629
|
+
* `/Alt`: alternate text.
|
|
630
|
+
*/
|
|
631
|
+
alt?: string;
|
|
632
|
+
/**
|
|
633
|
+
* `/Lang`: the language of its content.
|
|
634
|
+
*/
|
|
635
|
+
lang?: string;
|
|
636
|
+
/**
|
|
637
|
+
* `/ActualText`: the text its content stands for.
|
|
638
|
+
*/
|
|
639
|
+
actualText?: string;
|
|
640
|
+
/**
|
|
641
|
+
* Its kids, in reading order.
|
|
642
|
+
*/
|
|
643
|
+
kids: StructureKidJs[];
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* One font the document uses.
|
|
648
|
+
*/
|
|
649
|
+
export interface FontJs {
|
|
650
|
+
/**
|
|
651
|
+
* Its name without a subset tag.
|
|
652
|
+
*/
|
|
653
|
+
name?: string;
|
|
654
|
+
/**
|
|
655
|
+
* `Type0`, `Type1`, `MMType1`, `Type3` or `TrueType`.
|
|
656
|
+
*/
|
|
657
|
+
kind?: string;
|
|
658
|
+
/**
|
|
659
|
+
* The file holds the font.
|
|
660
|
+
*/
|
|
661
|
+
embedded: boolean;
|
|
662
|
+
/**
|
|
663
|
+
* The file holds only the glyphs used.
|
|
664
|
+
*/
|
|
665
|
+
subset: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Its encoding; absent when the font gives none.
|
|
668
|
+
*/
|
|
669
|
+
encoding?: EncodingJs;
|
|
670
|
+
}
|
|
671
|
+
|
|
357
672
|
/**
|
|
358
673
|
* One outline item and its children.
|
|
359
674
|
*/
|
|
@@ -388,6 +703,28 @@ export interface OutlineEntryInit {
|
|
|
388
703
|
italic?: boolean;
|
|
389
704
|
}
|
|
390
705
|
|
|
706
|
+
/**
|
|
707
|
+
* One outline item.
|
|
708
|
+
*/
|
|
709
|
+
export interface OutlineNodeJs {
|
|
710
|
+
/**
|
|
711
|
+
* Its title (document text).
|
|
712
|
+
*/
|
|
713
|
+
title: string;
|
|
714
|
+
/**
|
|
715
|
+
* Whether it opens with its children shown.
|
|
716
|
+
*/
|
|
717
|
+
open: boolean;
|
|
718
|
+
/**
|
|
719
|
+
* Where it goes, when its destination names a page of this document.
|
|
720
|
+
*/
|
|
721
|
+
target?: TargetJs;
|
|
722
|
+
/**
|
|
723
|
+
* Its children, in order.
|
|
724
|
+
*/
|
|
725
|
+
children: OutlineNodeJs[];
|
|
726
|
+
}
|
|
727
|
+
|
|
391
728
|
/**
|
|
392
729
|
* One page's facts (`laminapdf::PageInfo`).
|
|
393
730
|
*/
|
|
@@ -519,6 +856,10 @@ export interface ExtractInit {
|
|
|
519
856
|
* How chunks are cut (`chunks`, and `json` to include them).
|
|
520
857
|
*/
|
|
521
858
|
chunk?: ChunkInit;
|
|
859
|
+
/**
|
|
860
|
+
* Models the host runs (`extractJob` only): the job asks for their results.
|
|
861
|
+
*/
|
|
862
|
+
models?: ModelsInit;
|
|
522
863
|
}
|
|
523
864
|
|
|
524
865
|
/**
|
|
@@ -715,6 +1056,11 @@ export interface DocumentInfoJs {
|
|
|
715
1056
|
*/
|
|
716
1057
|
export type PdfVersionInit = "1.4" | "1.5" | "1.6" | "1.7" | "2.0";
|
|
717
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* The cipher a file's streams use (ISO 32000-2 §7.6): the one list, which the `.d.ts` gets as a union.
|
|
1061
|
+
*/
|
|
1062
|
+
export type CipherJs = "rc4" | "aes-128" | "aes-256" | "identity" | "other";
|
|
1063
|
+
|
|
718
1064
|
/**
|
|
719
1065
|
* The cross-reference form.
|
|
720
1066
|
*/
|
|
@@ -766,6 +1112,28 @@ export interface MetadataInit {
|
|
|
766
1112
|
*/
|
|
767
1113
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
768
1114
|
|
|
1115
|
+
/**
|
|
1116
|
+
* The models the host runs for an extraction job.
|
|
1117
|
+
*/
|
|
1118
|
+
export interface ModelsInit {
|
|
1119
|
+
/**
|
|
1120
|
+
* A layout model: every page's regions are asked for.
|
|
1121
|
+
*/
|
|
1122
|
+
layout?: ModelInfoInit;
|
|
1123
|
+
/**
|
|
1124
|
+
* An OCR engine: pages with no visible text are asked for.
|
|
1125
|
+
*/
|
|
1126
|
+
ocr?: ModelInfoInit;
|
|
1127
|
+
/**
|
|
1128
|
+
* The resolution pages are asked for at; 150 by default.
|
|
1129
|
+
*/
|
|
1130
|
+
dpi?: number;
|
|
1131
|
+
/**
|
|
1132
|
+
* OCR's languages (BCP 47).
|
|
1133
|
+
*/
|
|
1134
|
+
langs?: string[];
|
|
1135
|
+
}
|
|
1136
|
+
|
|
769
1137
|
/**
|
|
770
1138
|
* The pages an edit touched.
|
|
771
1139
|
*/
|
|
@@ -791,6 +1159,67 @@ export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
|
791
1159
|
*/
|
|
792
1160
|
export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
793
1161
|
|
|
1162
|
+
/**
|
|
1163
|
+
* What `provide` takes.
|
|
1164
|
+
*/
|
|
1165
|
+
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* What a document holds besides its pages.
|
|
1169
|
+
*/
|
|
1170
|
+
export interface ContainsJs {
|
|
1171
|
+
/**
|
|
1172
|
+
* Some action runs JavaScript.
|
|
1173
|
+
*/
|
|
1174
|
+
javascript: boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* The number of embedded files.
|
|
1177
|
+
*/
|
|
1178
|
+
attachments: number;
|
|
1179
|
+
/**
|
|
1180
|
+
* The document has a form with at least one field.
|
|
1181
|
+
*/
|
|
1182
|
+
forms: boolean;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* What a file's author permits: a request to readers, not a lock.
|
|
1187
|
+
*/
|
|
1188
|
+
export interface PermissionsJs {
|
|
1189
|
+
/**
|
|
1190
|
+
* Printing.
|
|
1191
|
+
*/
|
|
1192
|
+
print: boolean;
|
|
1193
|
+
/**
|
|
1194
|
+
* Printing at full quality.
|
|
1195
|
+
*/
|
|
1196
|
+
printHighQuality: boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* Changing the contents.
|
|
1199
|
+
*/
|
|
1200
|
+
modify: boolean;
|
|
1201
|
+
/**
|
|
1202
|
+
* Copying text and graphics.
|
|
1203
|
+
*/
|
|
1204
|
+
copy: boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* Adding or changing annotations.
|
|
1207
|
+
*/
|
|
1208
|
+
annotate: boolean;
|
|
1209
|
+
/**
|
|
1210
|
+
* Filling form fields.
|
|
1211
|
+
*/
|
|
1212
|
+
fillForms: boolean;
|
|
1213
|
+
/**
|
|
1214
|
+
* Extracting text for accessibility.
|
|
1215
|
+
*/
|
|
1216
|
+
accessibility: boolean;
|
|
1217
|
+
/**
|
|
1218
|
+
* Inserting, rotating or deleting pages.
|
|
1219
|
+
*/
|
|
1220
|
+
assemble: boolean;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
794
1223
|
/**
|
|
795
1224
|
* What a run measures.
|
|
796
1225
|
*/
|
|
@@ -807,6 +1236,12 @@ export interface TextRunJs {
|
|
|
807
1236
|
* Its lines (a run breaks only at line breaks in the text).
|
|
808
1237
|
*/
|
|
809
1238
|
lines: number;
|
|
1239
|
+
/**
|
|
1240
|
+
* Where the next element can start: the bottom of the descent below its last line that
|
|
1241
|
+
* draws something, before the surface's transform. Left out when nothing is drawn (empty
|
|
1242
|
+
* text, or only white space and control characters); invisible text counts.
|
|
1243
|
+
*/
|
|
1244
|
+
bottom?: number;
|
|
810
1245
|
}
|
|
811
1246
|
|
|
812
1247
|
/**
|
|
@@ -844,6 +1279,11 @@ export interface SaveReportJs {
|
|
|
844
1279
|
*/
|
|
845
1280
|
export type OutputJs = "whole" | "appendedOnly";
|
|
846
1281
|
|
|
1282
|
+
/**
|
|
1283
|
+
* What following a link does, by `kind`.
|
|
1284
|
+
*/
|
|
1285
|
+
export type LinkToJs = { kind: "dest"; target?: TargetJs } | { kind: "named"; name: string; target?: TargetJs } | { kind: "uri"; uri: string } | { kind: "remote"; file?: string } | { kind: "named-action"; name: string } | { kind: "unsupported"; action: string };
|
|
1286
|
+
|
|
847
1287
|
/**
|
|
848
1288
|
* What happens to hidden text and page furniture.
|
|
849
1289
|
*/
|
|
@@ -1069,6 +1509,16 @@ export class WasmDocument {
|
|
|
1069
1509
|
* error (nothing is applied).
|
|
1070
1510
|
*/
|
|
1071
1511
|
apply(ops: Op[]): EditedJs;
|
|
1512
|
+
/**
|
|
1513
|
+
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
1514
|
+
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
1515
|
+
* run the model, hand the result to `provide`), and once every page is done, the output in
|
|
1516
|
+
* `options.format` (the extract and text modules).
|
|
1517
|
+
*
|
|
1518
|
+
* # Errors
|
|
1519
|
+
* As `extract`, for the options and the pages asked for.
|
|
1520
|
+
*/
|
|
1521
|
+
extractJob(options: ExtractInit): WasmExtractJob;
|
|
1072
1522
|
/**
|
|
1073
1523
|
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
1074
1524
|
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
@@ -1089,6 +1539,21 @@ export class WasmDocument {
|
|
|
1089
1539
|
* Reading errors.
|
|
1090
1540
|
*/
|
|
1091
1541
|
info(): DocumentInfoJs;
|
|
1542
|
+
/**
|
|
1543
|
+
* Whether the document says it is tagged (`/MarkInfo /Marked true`; the extract and text modules).
|
|
1544
|
+
*
|
|
1545
|
+
* # Errors
|
|
1546
|
+
* Reading errors.
|
|
1547
|
+
*/
|
|
1548
|
+
isTagged(): boolean;
|
|
1549
|
+
/**
|
|
1550
|
+
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1551
|
+
* it names no page here (the extract and text modules).
|
|
1552
|
+
*
|
|
1553
|
+
* # Errors
|
|
1554
|
+
* `data-pending` and the reading errors.
|
|
1555
|
+
*/
|
|
1556
|
+
namedDestination(name: string): TargetJs | undefined;
|
|
1092
1557
|
/**
|
|
1093
1558
|
* Opens a document from its bytes.
|
|
1094
1559
|
*
|
|
@@ -1106,6 +1571,14 @@ export class WasmDocument {
|
|
|
1106
1571
|
* As `openBytes`, and `data-pending`.
|
|
1107
1572
|
*/
|
|
1108
1573
|
static openSource(source: WasmSparseSource, options: OpenOptionsInit | undefined): WasmDocument;
|
|
1574
|
+
/**
|
|
1575
|
+
* The outline's top-level items, each with its children; empty without an outline (the
|
|
1576
|
+
* extract and text modules).
|
|
1577
|
+
*
|
|
1578
|
+
* # Errors
|
|
1579
|
+
* `data-pending` and the reading errors.
|
|
1580
|
+
*/
|
|
1581
|
+
outline(): OutlineNodeJs[];
|
|
1109
1582
|
/**
|
|
1110
1583
|
* A handle on the page with `id` (`p12.0`).
|
|
1111
1584
|
*
|
|
@@ -1134,6 +1607,13 @@ export class WasmDocument {
|
|
|
1134
1607
|
* Reading errors.
|
|
1135
1608
|
*/
|
|
1136
1609
|
pageInfos(): PageInfoJs[];
|
|
1610
|
+
/**
|
|
1611
|
+
* The visible links on page `index`, in annotation order (the extract and text modules).
|
|
1612
|
+
*
|
|
1613
|
+
* # Errors
|
|
1614
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
1615
|
+
*/
|
|
1616
|
+
pageLinks(index: number): PageLinkJs[];
|
|
1137
1617
|
/**
|
|
1138
1618
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
1139
1619
|
*
|
|
@@ -1141,6 +1621,13 @@ export class WasmDocument {
|
|
|
1141
1621
|
* `page-index-out-of-range`; reading errors.
|
|
1142
1622
|
*/
|
|
1143
1623
|
page(index: number): WasmPage;
|
|
1624
|
+
/**
|
|
1625
|
+
* The document's properties (the extract and text modules). Reads every object once.
|
|
1626
|
+
*
|
|
1627
|
+
* # Errors
|
|
1628
|
+
* `data-pending` and the reading errors.
|
|
1629
|
+
*/
|
|
1630
|
+
properties(): PropertiesJs;
|
|
1144
1631
|
/**
|
|
1145
1632
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
1146
1633
|
*
|
|
@@ -1169,6 +1656,14 @@ export class WasmDocument {
|
|
|
1169
1656
|
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
1170
1657
|
*/
|
|
1171
1658
|
save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1659
|
+
/**
|
|
1660
|
+
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
1661
|
+
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
1662
|
+
*
|
|
1663
|
+
* # Errors
|
|
1664
|
+
* Reading errors.
|
|
1665
|
+
*/
|
|
1666
|
+
structureTree(): StructureNodeJs[] | undefined;
|
|
1172
1667
|
/**
|
|
1173
1668
|
* Undoes the newest transaction; `undefined` when there is nothing to undo.
|
|
1174
1669
|
*
|
|
@@ -1182,6 +1677,38 @@ export class WasmDocument {
|
|
|
1182
1677
|
warnings(): WasmWarningCursor;
|
|
1183
1678
|
}
|
|
1184
1679
|
|
|
1680
|
+
/**
|
|
1681
|
+
* An extraction in progress, from `WasmDocument.extractJob`; it holds its document weakly.
|
|
1682
|
+
*/
|
|
1683
|
+
export class WasmExtractJob {
|
|
1684
|
+
private constructor();
|
|
1685
|
+
free(): void;
|
|
1686
|
+
[Symbol.dispose](): void;
|
|
1687
|
+
/**
|
|
1688
|
+
* Stops the job: its next step fails with `cancelled`.
|
|
1689
|
+
*/
|
|
1690
|
+
cancel(): void;
|
|
1691
|
+
/**
|
|
1692
|
+
* Hands the job the result of its open request: `{ kind: "layout", regions }` or
|
|
1693
|
+
* `{ kind: "ocr", words }`, boxes as `[x, y, width, height]` in top-left points.
|
|
1694
|
+
*
|
|
1695
|
+
* # Errors
|
|
1696
|
+
* `model-result-unexpected` when nothing was asked for or `result` is the other kind;
|
|
1697
|
+
* `invalid-argument` / `unknown-option` for a malformed result.
|
|
1698
|
+
*/
|
|
1699
|
+
provide(result: ModelResultInit): void;
|
|
1700
|
+
/**
|
|
1701
|
+
* Extracts up to `budget` pages: `{ state: "progress", done, total, phase, request? }` or
|
|
1702
|
+
* `{ state: "done", output }`, the output in the job's format. While `request` is set, a
|
|
1703
|
+
* step does nothing until `provide` answers it.
|
|
1704
|
+
*
|
|
1705
|
+
* # Errors
|
|
1706
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1707
|
+
* and the reading errors.
|
|
1708
|
+
*/
|
|
1709
|
+
step(budget: number): ({ state: "progress" } & ExtractProgressJs) | { state: "done"; output: string };
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1185
1712
|
/**
|
|
1186
1713
|
* A font registered with a [`WasmBuilder`].
|
|
1187
1714
|
*/
|
|
@@ -1288,7 +1815,8 @@ export class WasmPageBuilder {
|
|
|
1288
1815
|
[Symbol.dispose](): void;
|
|
1289
1816
|
/**
|
|
1290
1817
|
* Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
|
|
1291
|
-
* or `background
|
|
1818
|
+
* or `background`, or a pagination artifact that says what it is: `header` (attached to the
|
|
1819
|
+
* top edge), `footer` (the bottom) or `watermark`.
|
|
1292
1820
|
*
|
|
1293
1821
|
* # Errors
|
|
1294
1822
|
* `invalid-argument` for another kind.
|
|
@@ -1574,6 +2102,7 @@ export interface InitOutput {
|
|
|
1574
2102
|
readonly memory: WebAssembly.Memory;
|
|
1575
2103
|
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
1576
2104
|
readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
|
|
2105
|
+
readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
|
|
1577
2106
|
readonly __wbg_wasmfont_free: (a: number, b: number) => void;
|
|
1578
2107
|
readonly __wbg_wasmimage_free: (a: number, b: number) => void;
|
|
1579
2108
|
readonly __wbg_wasmpage_free: (a: number, b: number) => void;
|
|
@@ -1599,21 +2128,31 @@ export interface InitOutput {
|
|
|
1599
2128
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1600
2129
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1601
2130
|
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
2131
|
+
readonly wasmdocument_extractJob: (a: number, b: any) => [number, number, number];
|
|
1602
2132
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1603
2133
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
2134
|
+
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
2135
|
+
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
1604
2136
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1605
2137
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
2138
|
+
readonly wasmdocument_outline: (a: number) => [number, number, number];
|
|
1606
2139
|
readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
|
|
1607
2140
|
readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
|
|
1608
2141
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
1609
2142
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1610
2143
|
readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
|
|
2144
|
+
readonly wasmdocument_pageLinks: (a: number, b: number) => [number, number, number];
|
|
2145
|
+
readonly wasmdocument_properties: (a: number) => [number, number, number];
|
|
1611
2146
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1612
2147
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1613
2148
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
1614
2149
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
2150
|
+
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
1615
2151
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1616
2152
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
2153
|
+
readonly wasmextractjob_cancel: (a: number) => void;
|
|
2154
|
+
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
2155
|
+
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|
|
1617
2156
|
readonly wasmfont_family: (a: number) => [number, number];
|
|
1618
2157
|
readonly wasmfont_isStandard: (a: number) => number;
|
|
1619
2158
|
readonly wasmfont_postscriptName: (a: number) => [number, number];
|