@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,11 +32,110 @@ 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 conformance profile.
|
|
37
49
|
*/
|
|
38
50
|
export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
|
|
39
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A document's properties, for a properties view.
|
|
54
|
+
*/
|
|
55
|
+
export interface PropertiesJs {
|
|
56
|
+
/**
|
|
57
|
+
* `/Title`.
|
|
58
|
+
*/
|
|
59
|
+
title?: string;
|
|
60
|
+
/**
|
|
61
|
+
* `/Author`.
|
|
62
|
+
*/
|
|
63
|
+
author?: string;
|
|
64
|
+
/**
|
|
65
|
+
* `/Subject`.
|
|
66
|
+
*/
|
|
67
|
+
subject?: string;
|
|
68
|
+
/**
|
|
69
|
+
* `/Keywords`.
|
|
70
|
+
*/
|
|
71
|
+
keywords?: string;
|
|
72
|
+
/**
|
|
73
|
+
* `/Creator`: the application the document was made with.
|
|
74
|
+
*/
|
|
75
|
+
creator?: string;
|
|
76
|
+
/**
|
|
77
|
+
* `/Producer`: the application that wrote the PDF.
|
|
78
|
+
*/
|
|
79
|
+
producer?: string;
|
|
80
|
+
/**
|
|
81
|
+
* `/CreationDate` as ISO 8601.
|
|
82
|
+
*/
|
|
83
|
+
created?: string;
|
|
84
|
+
/**
|
|
85
|
+
* `/ModDate` as ISO 8601.
|
|
86
|
+
*/
|
|
87
|
+
modified?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The XMP packet as text.
|
|
90
|
+
*/
|
|
91
|
+
xmp?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The PDF version.
|
|
94
|
+
*/
|
|
95
|
+
version?: string;
|
|
96
|
+
/**
|
|
97
|
+
* The number of pages.
|
|
98
|
+
*/
|
|
99
|
+
pageCount: number;
|
|
100
|
+
/**
|
|
101
|
+
* The file's size in bytes.
|
|
102
|
+
*/
|
|
103
|
+
fileSize: number;
|
|
104
|
+
/**
|
|
105
|
+
* The file is linearized ("fast web view").
|
|
106
|
+
*/
|
|
107
|
+
linearized: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* The catalog says the document is tagged.
|
|
110
|
+
*/
|
|
111
|
+
tagged: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* How the file is encrypted; absent when it isn't.
|
|
114
|
+
*/
|
|
115
|
+
encryption?: EncryptionJs;
|
|
116
|
+
/**
|
|
117
|
+
* The fonts the pages use.
|
|
118
|
+
*/
|
|
119
|
+
fonts: FontJs[];
|
|
120
|
+
/**
|
|
121
|
+
* The signatures present, not verified.
|
|
122
|
+
*/
|
|
123
|
+
signatures: number;
|
|
124
|
+
/**
|
|
125
|
+
* The signature fields' full names.
|
|
126
|
+
*/
|
|
127
|
+
signatureFields: string[];
|
|
128
|
+
/**
|
|
129
|
+
* What the document holds besides its pages.
|
|
130
|
+
*/
|
|
131
|
+
contains: ContainsJs;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A font's encoding: a named one (`WinAnsiEncoding`, `Identity-H`), or the font's own.
|
|
136
|
+
*/
|
|
137
|
+
export type EncodingJs = { kind: "named"; name: string } | { kind: "custom" };
|
|
138
|
+
|
|
40
139
|
/**
|
|
41
140
|
* A job's progress (`laminapdf::Step::Progress`).
|
|
42
141
|
*/
|
|
@@ -50,11 +149,35 @@ export interface ProgressJs {
|
|
|
50
149
|
*/
|
|
51
150
|
total?: number;
|
|
52
151
|
/**
|
|
53
|
-
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`).
|
|
152
|
+
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`, `model`).
|
|
54
153
|
*/
|
|
55
154
|
phase: string;
|
|
56
155
|
}
|
|
57
156
|
|
|
157
|
+
/**
|
|
158
|
+
* A kid of a structure element: an element, or marked content on a page.
|
|
159
|
+
*/
|
|
160
|
+
export type StructureKidJs = ({ type: "node" } & StructureNodeJs) | { type: "content"; page: number; mcid: number };
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A layout region, its box `[x, y, width, height]` in top-left points (ADR 0027), as the
|
|
164
|
+
* output's boxes are.
|
|
165
|
+
*/
|
|
166
|
+
export interface RegionInit {
|
|
167
|
+
/**
|
|
168
|
+
* What it is.
|
|
169
|
+
*/
|
|
170
|
+
label: RegionLabelName;
|
|
171
|
+
/**
|
|
172
|
+
* `[x, y, width, height]`.
|
|
173
|
+
*/
|
|
174
|
+
bbox: [number, number, number, number];
|
|
175
|
+
/**
|
|
176
|
+
* The model's confidence, 0 to 1.
|
|
177
|
+
*/
|
|
178
|
+
score: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
58
181
|
/**
|
|
59
182
|
* A list of ops with its schema version ([ADR 0006] §6): `{ "v": 1, "ops": [ … ] }`, used
|
|
60
183
|
* for saved op logs, batch processing and sync messages. Unknown fields are rejected, and so
|
|
@@ -76,11 +199,114 @@ export interface OpLog {
|
|
|
76
199
|
ops: Op[];
|
|
77
200
|
}
|
|
78
201
|
|
|
202
|
+
/**
|
|
203
|
+
* A model result the job waits for.
|
|
204
|
+
*/
|
|
205
|
+
export interface ModelRequestJs {
|
|
206
|
+
/**
|
|
207
|
+
* `layout` (regions) or `ocr` (words).
|
|
208
|
+
*/
|
|
209
|
+
kind: string;
|
|
210
|
+
/**
|
|
211
|
+
* The 0-based page to render.
|
|
212
|
+
*/
|
|
213
|
+
page: number;
|
|
214
|
+
/**
|
|
215
|
+
* The resolution to render it at.
|
|
216
|
+
*/
|
|
217
|
+
dpi: number;
|
|
218
|
+
/**
|
|
219
|
+
* OCR's languages (BCP 47); empty for the engine's default.
|
|
220
|
+
*/
|
|
221
|
+
langs: string[];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A model the host runs, as the output's `generator.models` names it.
|
|
226
|
+
*/
|
|
227
|
+
export interface ModelInfoInit {
|
|
228
|
+
/**
|
|
229
|
+
* Its name.
|
|
230
|
+
*/
|
|
231
|
+
name: string;
|
|
232
|
+
/**
|
|
233
|
+
* Its version or revision.
|
|
234
|
+
*/
|
|
235
|
+
version: string;
|
|
236
|
+
/**
|
|
237
|
+
* Its weights' SHA-256, lowercase hex.
|
|
238
|
+
*/
|
|
239
|
+
sha256: string;
|
|
240
|
+
/**
|
|
241
|
+
* Its weights' SPDX licence.
|
|
242
|
+
*/
|
|
243
|
+
licence: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A page and how to show it.
|
|
248
|
+
*/
|
|
249
|
+
export interface TargetJs {
|
|
250
|
+
/**
|
|
251
|
+
* The page's 0-based index.
|
|
252
|
+
*/
|
|
253
|
+
page: number;
|
|
254
|
+
/**
|
|
255
|
+
* How to show it, in page space.
|
|
256
|
+
*/
|
|
257
|
+
view: TargetViewJs;
|
|
258
|
+
}
|
|
259
|
+
|
|
79
260
|
/**
|
|
80
261
|
* A page-label numbering style.
|
|
81
262
|
*/
|
|
82
263
|
export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
|
|
83
264
|
|
|
265
|
+
/**
|
|
266
|
+
* A region's kind.
|
|
267
|
+
*/
|
|
268
|
+
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A step's progress, and the model result the job waits for, if any.
|
|
272
|
+
*/
|
|
273
|
+
export interface ExtractProgressJs {
|
|
274
|
+
/**
|
|
275
|
+
* Pages done.
|
|
276
|
+
*/
|
|
277
|
+
done: number;
|
|
278
|
+
/**
|
|
279
|
+
* Pages asked for.
|
|
280
|
+
*/
|
|
281
|
+
total?: number;
|
|
282
|
+
/**
|
|
283
|
+
* `extract`, or `model` while a request is open.
|
|
284
|
+
*/
|
|
285
|
+
phase: string;
|
|
286
|
+
/**
|
|
287
|
+
* The result the job waits for: hand it to `provide`.
|
|
288
|
+
*/
|
|
289
|
+
request?: ModelRequestJs;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* An OCR word, its box as a region's.
|
|
294
|
+
*/
|
|
295
|
+
export interface WordInit {
|
|
296
|
+
/**
|
|
297
|
+
* Its text.
|
|
298
|
+
*/
|
|
299
|
+
text: string;
|
|
300
|
+
/**
|
|
301
|
+
* `[x, y, width, height]`.
|
|
302
|
+
*/
|
|
303
|
+
bbox: [number, number, number, number];
|
|
304
|
+
/**
|
|
305
|
+
* The engine's confidence, 0 to 1.
|
|
306
|
+
*/
|
|
307
|
+
confidence: number;
|
|
308
|
+
}
|
|
309
|
+
|
|
84
310
|
/**
|
|
85
311
|
* An attached file's options.
|
|
86
312
|
*/
|
|
@@ -181,6 +407,37 @@ export interface SetInfo {
|
|
|
181
407
|
*/
|
|
182
408
|
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" };
|
|
183
409
|
|
|
410
|
+
/**
|
|
411
|
+
* How a file is encrypted, and what its author permits.
|
|
412
|
+
*/
|
|
413
|
+
export interface EncryptionJs {
|
|
414
|
+
/**
|
|
415
|
+
* `/V`.
|
|
416
|
+
*/
|
|
417
|
+
version: number;
|
|
418
|
+
/**
|
|
419
|
+
* `/R`.
|
|
420
|
+
*/
|
|
421
|
+
revision: number;
|
|
422
|
+
/**
|
|
423
|
+
* The key length in bits.
|
|
424
|
+
*/
|
|
425
|
+
keyBits: number;
|
|
426
|
+
/**
|
|
427
|
+
* The cipher streams use.
|
|
428
|
+
*/
|
|
429
|
+
cipher: CipherJs;
|
|
430
|
+
/**
|
|
431
|
+
* What `/P` permits; absent when the handler gives no permissions.
|
|
432
|
+
*/
|
|
433
|
+
permissions?: PermissionsJs;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
438
|
+
*/
|
|
439
|
+
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 };
|
|
440
|
+
|
|
184
441
|
/**
|
|
185
442
|
* How a viewer lays pages out.
|
|
186
443
|
*/
|
|
@@ -237,6 +494,58 @@ export interface ViewerPreferencesInit {
|
|
|
237
494
|
*/
|
|
238
495
|
export type RenumberJs = "keep" | "compact";
|
|
239
496
|
|
|
497
|
+
/**
|
|
498
|
+
* One element of the structure tree (`laminapdf::StructureNode`; its strings are document text).
|
|
499
|
+
*/
|
|
500
|
+
export interface StructureNodeJs {
|
|
501
|
+
/**
|
|
502
|
+
* Its standard structure type (`H1`, `P`, `LI`, `Figure` …), through the `/RoleMap`.
|
|
503
|
+
*/
|
|
504
|
+
kind: string;
|
|
505
|
+
/**
|
|
506
|
+
* `/Alt`: alternate text.
|
|
507
|
+
*/
|
|
508
|
+
alt?: string;
|
|
509
|
+
/**
|
|
510
|
+
* `/Lang`: the language of its content.
|
|
511
|
+
*/
|
|
512
|
+
lang?: string;
|
|
513
|
+
/**
|
|
514
|
+
* `/ActualText`: the text its content stands for.
|
|
515
|
+
*/
|
|
516
|
+
actualText?: string;
|
|
517
|
+
/**
|
|
518
|
+
* Its kids, in reading order.
|
|
519
|
+
*/
|
|
520
|
+
kids: StructureKidJs[];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* One font the document uses.
|
|
525
|
+
*/
|
|
526
|
+
export interface FontJs {
|
|
527
|
+
/**
|
|
528
|
+
* Its name without a subset tag.
|
|
529
|
+
*/
|
|
530
|
+
name?: string;
|
|
531
|
+
/**
|
|
532
|
+
* `Type0`, `Type1`, `MMType1`, `Type3` or `TrueType`.
|
|
533
|
+
*/
|
|
534
|
+
kind?: string;
|
|
535
|
+
/**
|
|
536
|
+
* The file holds the font.
|
|
537
|
+
*/
|
|
538
|
+
embedded: boolean;
|
|
539
|
+
/**
|
|
540
|
+
* The file holds only the glyphs used.
|
|
541
|
+
*/
|
|
542
|
+
subset: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* Its encoding; absent when the font gives none.
|
|
545
|
+
*/
|
|
546
|
+
encoding?: EncodingJs;
|
|
547
|
+
}
|
|
548
|
+
|
|
240
549
|
/**
|
|
241
550
|
* One outline item and its children.
|
|
242
551
|
*/
|
|
@@ -271,6 +580,28 @@ export interface OutlineEntryInit {
|
|
|
271
580
|
italic?: boolean;
|
|
272
581
|
}
|
|
273
582
|
|
|
583
|
+
/**
|
|
584
|
+
* One outline item.
|
|
585
|
+
*/
|
|
586
|
+
export interface OutlineNodeJs {
|
|
587
|
+
/**
|
|
588
|
+
* Its title (document text).
|
|
589
|
+
*/
|
|
590
|
+
title: string;
|
|
591
|
+
/**
|
|
592
|
+
* Whether it opens with its children shown.
|
|
593
|
+
*/
|
|
594
|
+
open: boolean;
|
|
595
|
+
/**
|
|
596
|
+
* Where it goes, when its destination names a page of this document.
|
|
597
|
+
*/
|
|
598
|
+
target?: TargetJs;
|
|
599
|
+
/**
|
|
600
|
+
* Its children, in order.
|
|
601
|
+
*/
|
|
602
|
+
children: OutlineNodeJs[];
|
|
603
|
+
}
|
|
604
|
+
|
|
274
605
|
/**
|
|
275
606
|
* One page's facts (`laminapdf::PageInfo`).
|
|
276
607
|
*/
|
|
@@ -402,6 +733,10 @@ export interface ExtractInit {
|
|
|
402
733
|
* How chunks are cut (`chunks`, and `json` to include them).
|
|
403
734
|
*/
|
|
404
735
|
chunk?: ChunkInit;
|
|
736
|
+
/**
|
|
737
|
+
* Models the host runs (`extractJob` only): the job asks for their results.
|
|
738
|
+
*/
|
|
739
|
+
models?: ModelsInit;
|
|
405
740
|
}
|
|
406
741
|
|
|
407
742
|
/**
|
|
@@ -558,6 +893,11 @@ export interface DocumentInfoJs {
|
|
|
558
893
|
*/
|
|
559
894
|
export type PdfVersionInit = "1.4" | "1.5" | "1.6" | "1.7" | "2.0";
|
|
560
895
|
|
|
896
|
+
/**
|
|
897
|
+
* The cipher a file's streams use (ISO 32000-2 §7.6): the one list, which the `.d.ts` gets as a union.
|
|
898
|
+
*/
|
|
899
|
+
export type CipherJs = "rc4" | "aes-128" | "aes-256" | "identity" | "other";
|
|
900
|
+
|
|
561
901
|
/**
|
|
562
902
|
* The cross-reference form.
|
|
563
903
|
*/
|
|
@@ -609,6 +949,28 @@ export interface MetadataInit {
|
|
|
609
949
|
*/
|
|
610
950
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
611
951
|
|
|
952
|
+
/**
|
|
953
|
+
* The models the host runs for an extraction job.
|
|
954
|
+
*/
|
|
955
|
+
export interface ModelsInit {
|
|
956
|
+
/**
|
|
957
|
+
* A layout model: every page's regions are asked for.
|
|
958
|
+
*/
|
|
959
|
+
layout?: ModelInfoInit;
|
|
960
|
+
/**
|
|
961
|
+
* An OCR engine: pages with no visible text are asked for.
|
|
962
|
+
*/
|
|
963
|
+
ocr?: ModelInfoInit;
|
|
964
|
+
/**
|
|
965
|
+
* The resolution pages are asked for at; 150 by default.
|
|
966
|
+
*/
|
|
967
|
+
dpi?: number;
|
|
968
|
+
/**
|
|
969
|
+
* OCR's languages (BCP 47).
|
|
970
|
+
*/
|
|
971
|
+
langs?: string[];
|
|
972
|
+
}
|
|
973
|
+
|
|
612
974
|
/**
|
|
613
975
|
* The pages an edit touched.
|
|
614
976
|
*/
|
|
@@ -634,6 +996,67 @@ export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
|
634
996
|
*/
|
|
635
997
|
export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
636
998
|
|
|
999
|
+
/**
|
|
1000
|
+
* What `provide` takes.
|
|
1001
|
+
*/
|
|
1002
|
+
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* What a document holds besides its pages.
|
|
1006
|
+
*/
|
|
1007
|
+
export interface ContainsJs {
|
|
1008
|
+
/**
|
|
1009
|
+
* Some action runs JavaScript.
|
|
1010
|
+
*/
|
|
1011
|
+
javascript: boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
* The number of embedded files.
|
|
1014
|
+
*/
|
|
1015
|
+
attachments: number;
|
|
1016
|
+
/**
|
|
1017
|
+
* The document has a form with at least one field.
|
|
1018
|
+
*/
|
|
1019
|
+
forms: boolean;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* What a file's author permits: a request to readers, not a lock.
|
|
1024
|
+
*/
|
|
1025
|
+
export interface PermissionsJs {
|
|
1026
|
+
/**
|
|
1027
|
+
* Printing.
|
|
1028
|
+
*/
|
|
1029
|
+
print: boolean;
|
|
1030
|
+
/**
|
|
1031
|
+
* Printing at full quality.
|
|
1032
|
+
*/
|
|
1033
|
+
printHighQuality: boolean;
|
|
1034
|
+
/**
|
|
1035
|
+
* Changing the contents.
|
|
1036
|
+
*/
|
|
1037
|
+
modify: boolean;
|
|
1038
|
+
/**
|
|
1039
|
+
* Copying text and graphics.
|
|
1040
|
+
*/
|
|
1041
|
+
copy: boolean;
|
|
1042
|
+
/**
|
|
1043
|
+
* Adding or changing annotations.
|
|
1044
|
+
*/
|
|
1045
|
+
annotate: boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* Filling form fields.
|
|
1048
|
+
*/
|
|
1049
|
+
fillForms: boolean;
|
|
1050
|
+
/**
|
|
1051
|
+
* Extracting text for accessibility.
|
|
1052
|
+
*/
|
|
1053
|
+
accessibility: boolean;
|
|
1054
|
+
/**
|
|
1055
|
+
* Inserting, rotating or deleting pages.
|
|
1056
|
+
*/
|
|
1057
|
+
assemble: boolean;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
637
1060
|
/**
|
|
638
1061
|
* What a save wrote (`laminapdf::SaveReport`).
|
|
639
1062
|
*/
|
|
@@ -669,6 +1092,11 @@ export interface SaveReportJs {
|
|
|
669
1092
|
*/
|
|
670
1093
|
export type OutputJs = "whole" | "appendedOnly";
|
|
671
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* What following a link does, by `kind`.
|
|
1097
|
+
*/
|
|
1098
|
+
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 };
|
|
1099
|
+
|
|
672
1100
|
/**
|
|
673
1101
|
* What happens to hidden text and page furniture.
|
|
674
1102
|
*/
|
|
@@ -873,6 +1301,16 @@ export class WasmDocument {
|
|
|
873
1301
|
* error (nothing is applied).
|
|
874
1302
|
*/
|
|
875
1303
|
apply(ops: Op[]): EditedJs;
|
|
1304
|
+
/**
|
|
1305
|
+
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
1306
|
+
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
1307
|
+
* run the model, hand the result to `provide`), and once every page is done, the output in
|
|
1308
|
+
* `options.format` (the extract and text modules).
|
|
1309
|
+
*
|
|
1310
|
+
* # Errors
|
|
1311
|
+
* As `extract`, for the options and the pages asked for.
|
|
1312
|
+
*/
|
|
1313
|
+
extractJob(options: ExtractInit): WasmExtractJob;
|
|
876
1314
|
/**
|
|
877
1315
|
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
878
1316
|
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
@@ -893,6 +1331,21 @@ export class WasmDocument {
|
|
|
893
1331
|
* Reading errors.
|
|
894
1332
|
*/
|
|
895
1333
|
info(): DocumentInfoJs;
|
|
1334
|
+
/**
|
|
1335
|
+
* Whether the document says it is tagged (`/MarkInfo /Marked true`; the extract and text modules).
|
|
1336
|
+
*
|
|
1337
|
+
* # Errors
|
|
1338
|
+
* Reading errors.
|
|
1339
|
+
*/
|
|
1340
|
+
isTagged(): boolean;
|
|
1341
|
+
/**
|
|
1342
|
+
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1343
|
+
* it names no page here (the extract and text modules).
|
|
1344
|
+
*
|
|
1345
|
+
* # Errors
|
|
1346
|
+
* `data-pending` and the reading errors.
|
|
1347
|
+
*/
|
|
1348
|
+
namedDestination(name: string): TargetJs | undefined;
|
|
896
1349
|
/**
|
|
897
1350
|
* Opens a document from its bytes.
|
|
898
1351
|
*
|
|
@@ -910,6 +1363,14 @@ export class WasmDocument {
|
|
|
910
1363
|
* As `openBytes`, and `data-pending`.
|
|
911
1364
|
*/
|
|
912
1365
|
static openSource(source: WasmSparseSource, options: OpenOptionsInit | undefined): WasmDocument;
|
|
1366
|
+
/**
|
|
1367
|
+
* The outline's top-level items, each with its children; empty without an outline (the
|
|
1368
|
+
* extract and text modules).
|
|
1369
|
+
*
|
|
1370
|
+
* # Errors
|
|
1371
|
+
* `data-pending` and the reading errors.
|
|
1372
|
+
*/
|
|
1373
|
+
outline(): OutlineNodeJs[];
|
|
913
1374
|
/**
|
|
914
1375
|
* A handle on the page with `id` (`p12.0`).
|
|
915
1376
|
*
|
|
@@ -938,6 +1399,13 @@ export class WasmDocument {
|
|
|
938
1399
|
* Reading errors.
|
|
939
1400
|
*/
|
|
940
1401
|
pageInfos(): PageInfoJs[];
|
|
1402
|
+
/**
|
|
1403
|
+
* The visible links on page `index`, in annotation order (the extract and text modules).
|
|
1404
|
+
*
|
|
1405
|
+
* # Errors
|
|
1406
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
1407
|
+
*/
|
|
1408
|
+
pageLinks(index: number): PageLinkJs[];
|
|
941
1409
|
/**
|
|
942
1410
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
943
1411
|
*
|
|
@@ -945,6 +1413,13 @@ export class WasmDocument {
|
|
|
945
1413
|
* `page-index-out-of-range`; reading errors.
|
|
946
1414
|
*/
|
|
947
1415
|
page(index: number): WasmPage;
|
|
1416
|
+
/**
|
|
1417
|
+
* The document's properties (the extract and text modules). Reads every object once.
|
|
1418
|
+
*
|
|
1419
|
+
* # Errors
|
|
1420
|
+
* `data-pending` and the reading errors.
|
|
1421
|
+
*/
|
|
1422
|
+
properties(): PropertiesJs;
|
|
948
1423
|
/**
|
|
949
1424
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
950
1425
|
*
|
|
@@ -959,6 +1434,15 @@ export class WasmDocument {
|
|
|
959
1434
|
* As [`WasmDocument::undo`].
|
|
960
1435
|
*/
|
|
961
1436
|
redo(): UndoOutcomeJs | undefined;
|
|
1437
|
+
/**
|
|
1438
|
+
* The document for reader mode, as JSON: whether it can be shown and why not, its
|
|
1439
|
+
* language, its blocks in the structure tree's order (figures, formulas and tables as crops
|
|
1440
|
+
* with their alternate text) and the checks' measures (the extract module only).
|
|
1441
|
+
*
|
|
1442
|
+
* # Errors
|
|
1443
|
+
* `data-pending` and the reading errors.
|
|
1444
|
+
*/
|
|
1445
|
+
reflow(): string;
|
|
962
1446
|
/**
|
|
963
1447
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
964
1448
|
*
|
|
@@ -973,6 +1457,14 @@ export class WasmDocument {
|
|
|
973
1457
|
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
974
1458
|
*/
|
|
975
1459
|
save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1460
|
+
/**
|
|
1461
|
+
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
1462
|
+
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
1463
|
+
*
|
|
1464
|
+
* # Errors
|
|
1465
|
+
* Reading errors.
|
|
1466
|
+
*/
|
|
1467
|
+
structureTree(): StructureNodeJs[] | undefined;
|
|
976
1468
|
/**
|
|
977
1469
|
* Undoes the newest transaction; `undefined` when there is nothing to undo.
|
|
978
1470
|
*
|
|
@@ -986,6 +1478,38 @@ export class WasmDocument {
|
|
|
986
1478
|
warnings(): WasmWarningCursor;
|
|
987
1479
|
}
|
|
988
1480
|
|
|
1481
|
+
/**
|
|
1482
|
+
* An extraction in progress, from `WasmDocument.extractJob`; it holds its document weakly.
|
|
1483
|
+
*/
|
|
1484
|
+
export class WasmExtractJob {
|
|
1485
|
+
private constructor();
|
|
1486
|
+
free(): void;
|
|
1487
|
+
[Symbol.dispose](): void;
|
|
1488
|
+
/**
|
|
1489
|
+
* Stops the job: its next step fails with `cancelled`.
|
|
1490
|
+
*/
|
|
1491
|
+
cancel(): void;
|
|
1492
|
+
/**
|
|
1493
|
+
* Hands the job the result of its open request: `{ kind: "layout", regions }` or
|
|
1494
|
+
* `{ kind: "ocr", words }`, boxes as `[x, y, width, height]` in top-left points.
|
|
1495
|
+
*
|
|
1496
|
+
* # Errors
|
|
1497
|
+
* `model-result-unexpected` when nothing was asked for or `result` is the other kind;
|
|
1498
|
+
* `invalid-argument` / `unknown-option` for a malformed result.
|
|
1499
|
+
*/
|
|
1500
|
+
provide(result: ModelResultInit): void;
|
|
1501
|
+
/**
|
|
1502
|
+
* Extracts up to `budget` pages: `{ state: "progress", done, total, phase, request? }` or
|
|
1503
|
+
* `{ state: "done", output }`, the output in the job's format. While `request` is set, a
|
|
1504
|
+
* step does nothing until `provide` answers it.
|
|
1505
|
+
*
|
|
1506
|
+
* # Errors
|
|
1507
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1508
|
+
* and the reading errors.
|
|
1509
|
+
*/
|
|
1510
|
+
step(budget: number): ({ state: "progress" } & ExtractProgressJs) | { state: "done"; output: string };
|
|
1511
|
+
}
|
|
1512
|
+
|
|
989
1513
|
/**
|
|
990
1514
|
* An image to draw (decoded or passed through once, shared by every use).
|
|
991
1515
|
*/
|
|
@@ -1071,7 +1595,8 @@ export class WasmPageBuilder {
|
|
|
1071
1595
|
[Symbol.dispose](): void;
|
|
1072
1596
|
/**
|
|
1073
1597
|
* Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
|
|
1074
|
-
* or `background
|
|
1598
|
+
* or `background`, or a pagination artifact that says what it is: `header` (attached to the
|
|
1599
|
+
* top edge), `footer` (the bottom) or `watermark`.
|
|
1075
1600
|
*
|
|
1076
1601
|
* # Errors
|
|
1077
1602
|
* `invalid-argument` for another kind.
|
|
@@ -1340,6 +1865,7 @@ export interface InitOutput {
|
|
|
1340
1865
|
readonly memory: WebAssembly.Memory;
|
|
1341
1866
|
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
1342
1867
|
readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
|
|
1868
|
+
readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
|
|
1343
1869
|
readonly __wbg_wasmimage_free: (a: number, b: number) => void;
|
|
1344
1870
|
readonly __wbg_wasmpage_free: (a: number, b: number) => void;
|
|
1345
1871
|
readonly __wbg_wasmpagebuilder_free: (a: number, b: number) => void;
|
|
@@ -1362,21 +1888,32 @@ export interface InitOutput {
|
|
|
1362
1888
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1363
1889
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1364
1890
|
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
1891
|
+
readonly wasmdocument_extractJob: (a: number, b: any) => [number, number, number];
|
|
1365
1892
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1366
1893
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
1894
|
+
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
1895
|
+
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
1367
1896
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1368
1897
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
1898
|
+
readonly wasmdocument_outline: (a: number) => [number, number, number];
|
|
1369
1899
|
readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
|
|
1370
1900
|
readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
|
|
1371
1901
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
1372
1902
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1373
1903
|
readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
|
|
1904
|
+
readonly wasmdocument_pageLinks: (a: number, b: number) => [number, number, number];
|
|
1905
|
+
readonly wasmdocument_properties: (a: number) => [number, number, number];
|
|
1374
1906
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1375
1907
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1908
|
+
readonly wasmdocument_reflow: (a: number) => [number, number, number, number];
|
|
1376
1909
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
1377
1910
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
1911
|
+
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
1378
1912
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1379
1913
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
1914
|
+
readonly wasmextractjob_cancel: (a: number) => void;
|
|
1915
|
+
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
1916
|
+
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|
|
1380
1917
|
readonly wasmimage_height: (a: number) => number;
|
|
1381
1918
|
readonly wasmimage_jpeg: (a: number, b: number) => [number, number, number];
|
|
1382
1919
|
readonly wasmimage_png: (a: number, b: number) => [number, number, number];
|