@laminapdf/wasm 0.2.0-alpha.4 → 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.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +243 -0
- package/dist/lamina_pdf_extract.js +59 -0
- 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 +233 -0
- package/dist/lamina_pdf_text.js +31 -0
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -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
|
*/
|
|
@@ -308,6 +407,32 @@ export interface SetInfo {
|
|
|
308
407
|
*/
|
|
309
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" };
|
|
310
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
|
+
|
|
311
436
|
/**
|
|
312
437
|
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
313
438
|
*/
|
|
@@ -395,6 +520,32 @@ export interface StructureNodeJs {
|
|
|
395
520
|
kids: StructureKidJs[];
|
|
396
521
|
}
|
|
397
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
|
+
|
|
398
549
|
/**
|
|
399
550
|
* One outline item and its children.
|
|
400
551
|
*/
|
|
@@ -742,6 +893,11 @@ export interface DocumentInfoJs {
|
|
|
742
893
|
*/
|
|
743
894
|
export type PdfVersionInit = "1.4" | "1.5" | "1.6" | "1.7" | "2.0";
|
|
744
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
|
+
|
|
745
901
|
/**
|
|
746
902
|
* The cross-reference form.
|
|
747
903
|
*/
|
|
@@ -845,6 +1001,62 @@ export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
|
845
1001
|
*/
|
|
846
1002
|
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
847
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
|
+
|
|
848
1060
|
/**
|
|
849
1061
|
* What a save wrote (`laminapdf::SaveReport`).
|
|
850
1062
|
*/
|
|
@@ -880,6 +1092,11 @@ export interface SaveReportJs {
|
|
|
880
1092
|
*/
|
|
881
1093
|
export type OutputJs = "whole" | "appendedOnly";
|
|
882
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
|
+
|
|
883
1100
|
/**
|
|
884
1101
|
* What happens to hidden text and page furniture.
|
|
885
1102
|
*/
|
|
@@ -1182,6 +1399,13 @@ export class WasmDocument {
|
|
|
1182
1399
|
* Reading errors.
|
|
1183
1400
|
*/
|
|
1184
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[];
|
|
1185
1409
|
/**
|
|
1186
1410
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
1187
1411
|
*
|
|
@@ -1189,6 +1413,13 @@ export class WasmDocument {
|
|
|
1189
1413
|
* `page-index-out-of-range`; reading errors.
|
|
1190
1414
|
*/
|
|
1191
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;
|
|
1192
1423
|
/**
|
|
1193
1424
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
1194
1425
|
*
|
|
@@ -1203,6 +1434,15 @@ export class WasmDocument {
|
|
|
1203
1434
|
* As [`WasmDocument::undo`].
|
|
1204
1435
|
*/
|
|
1205
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;
|
|
1206
1446
|
/**
|
|
1207
1447
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
1208
1448
|
*
|
|
@@ -1661,8 +1901,11 @@ export interface InitOutput {
|
|
|
1661
1901
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
1662
1902
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1663
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];
|
|
1664
1906
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1665
1907
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1908
|
+
readonly wasmdocument_reflow: (a: number) => [number, number, number, number];
|
|
1666
1909
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
1667
1910
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
1668
1911
|
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
@@ -466,6 +466,22 @@ export class WasmDocument {
|
|
|
466
466
|
}
|
|
467
467
|
return takeFromExternrefTable0(ret[0]);
|
|
468
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* The visible links on page `index`, in annotation order (the extract and text modules).
|
|
471
|
+
*
|
|
472
|
+
* # Errors
|
|
473
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
474
|
+
* @param {number} index
|
|
475
|
+
* @returns {PageLinkJs[]}
|
|
476
|
+
*/
|
|
477
|
+
pageLinks(index) {
|
|
478
|
+
let ret;
|
|
479
|
+
ret = wasm.wasmdocument_pageLinks(this.__wbg_ptr, index);
|
|
480
|
+
if (ret[2]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
482
|
+
}
|
|
483
|
+
return takeFromExternrefTable0(ret[0]);
|
|
484
|
+
}
|
|
469
485
|
/**
|
|
470
486
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
471
487
|
*
|
|
@@ -482,6 +498,21 @@ export class WasmDocument {
|
|
|
482
498
|
}
|
|
483
499
|
return WasmPage.__wrap(ret[0]);
|
|
484
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* The document's properties (the extract and text modules). Reads every object once.
|
|
503
|
+
*
|
|
504
|
+
* # Errors
|
|
505
|
+
* `data-pending` and the reading errors.
|
|
506
|
+
* @returns {PropertiesJs}
|
|
507
|
+
*/
|
|
508
|
+
properties() {
|
|
509
|
+
let ret;
|
|
510
|
+
ret = wasm.wasmdocument_properties(this.__wbg_ptr);
|
|
511
|
+
if (ret[2]) {
|
|
512
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
513
|
+
}
|
|
514
|
+
return takeFromExternrefTable0(ret[0]);
|
|
515
|
+
}
|
|
485
516
|
/**
|
|
486
517
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
487
518
|
*
|
|
@@ -513,6 +544,34 @@ export class WasmDocument {
|
|
|
513
544
|
}
|
|
514
545
|
return takeFromExternrefTable0(ret[0]);
|
|
515
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* The document for reader mode, as JSON: whether it can be shown and why not, its
|
|
549
|
+
* language, its blocks in the structure tree's order (figures, formulas and tables as crops
|
|
550
|
+
* with their alternate text) and the checks' measures (the extract module only).
|
|
551
|
+
*
|
|
552
|
+
* # Errors
|
|
553
|
+
* `data-pending` and the reading errors.
|
|
554
|
+
* @returns {string}
|
|
555
|
+
*/
|
|
556
|
+
reflow() {
|
|
557
|
+
let deferred2_0;
|
|
558
|
+
let deferred2_1;
|
|
559
|
+
try {
|
|
560
|
+
let ret;
|
|
561
|
+
ret = wasm.wasmdocument_reflow(this.__wbg_ptr);
|
|
562
|
+
var ptr1 = ret[0];
|
|
563
|
+
var len1 = ret[1];
|
|
564
|
+
if (ret[3]) {
|
|
565
|
+
ptr1 = 0; len1 = 0;
|
|
566
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
567
|
+
}
|
|
568
|
+
deferred2_0 = ptr1;
|
|
569
|
+
deferred2_1 = len1;
|
|
570
|
+
return getStringFromWasm0(ptr1, len1);
|
|
571
|
+
} finally {
|
|
572
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
516
575
|
/**
|
|
517
576
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
518
577
|
*
|
|
Binary file
|
|
@@ -35,12 +35,15 @@ export class HayroDocument {
|
|
|
35
35
|
*/
|
|
36
36
|
plan(page: number, scale: number, x: number, y: number, width: number, height: number, rotation: number, flags: number, background?: number | null): Uint32Array;
|
|
37
37
|
/**
|
|
38
|
-
* Renders the request into `out` (exactly `width × height × 4` bytes, straight RGBA)
|
|
38
|
+
* Renders the request into `out` (exactly `width × height × 4` bytes, straight RGBA), in
|
|
39
|
+
* the page appearance `appearance` (0 original, 1 sepia, 2 dark, 3 high contrast with `ink`
|
|
40
|
+
* and `paper` as `0xRRGGBBAA`; the colours are ignored otherwise).
|
|
39
41
|
*
|
|
40
42
|
* # Errors
|
|
41
|
-
* As [`HayroDocument::plan`], plus `render-failed
|
|
43
|
+
* As [`HayroDocument::plan`], plus `render-failed`, and `invalid-argument` for a wrong size
|
|
44
|
+
* or an unknown appearance.
|
|
42
45
|
*/
|
|
43
|
-
render(page: number, scale: number, x: number, y: number, width: number, height: number, rotation: number, flags: number, background: number | null | undefined, out: Uint8Array): void;
|
|
46
|
+
render(page: number, scale: number, x: number, y: number, width: number, height: number, rotation: number, flags: number, background: number | null | undefined, appearance: number, ink: number, paper: number, out: Uint8Array): void;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
/**
|
|
@@ -78,7 +81,7 @@ export interface InitOutput {
|
|
|
78
81
|
readonly hayrodocument_page: (a: number, b: number) => [number, number, number, number];
|
|
79
82
|
readonly hayrodocument_pageCount: (a: number) => number;
|
|
80
83
|
readonly hayrodocument_plan: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
|
|
81
|
-
readonly hayrodocument_render: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: any) => [number, number];
|
|
84
|
+
readonly hayrodocument_render: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: any) => [number, number];
|
|
82
85
|
readonly inputbuffer_new: (a: number) => [number, number, number];
|
|
83
86
|
readonly inputbuffer_write: (a: number, b: number, c: number, d: number) => [number, number];
|
|
84
87
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -95,10 +95,13 @@ export class HayroDocument {
|
|
|
95
95
|
return v1;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
-
* Renders the request into `out` (exactly `width × height × 4` bytes, straight RGBA)
|
|
98
|
+
* Renders the request into `out` (exactly `width × height × 4` bytes, straight RGBA), in
|
|
99
|
+
* the page appearance `appearance` (0 original, 1 sepia, 2 dark, 3 high contrast with `ink`
|
|
100
|
+
* and `paper` as `0xRRGGBBAA`; the colours are ignored otherwise).
|
|
99
101
|
*
|
|
100
102
|
* # Errors
|
|
101
|
-
* As [`HayroDocument::plan`], plus `render-failed
|
|
103
|
+
* As [`HayroDocument::plan`], plus `render-failed`, and `invalid-argument` for a wrong size
|
|
104
|
+
* or an unknown appearance.
|
|
102
105
|
* @param {number} page
|
|
103
106
|
* @param {number} scale
|
|
104
107
|
* @param {number} x
|
|
@@ -108,12 +111,15 @@ export class HayroDocument {
|
|
|
108
111
|
* @param {number} rotation
|
|
109
112
|
* @param {number} flags
|
|
110
113
|
* @param {number | null | undefined} background
|
|
114
|
+
* @param {number} appearance
|
|
115
|
+
* @param {number} ink
|
|
116
|
+
* @param {number} paper
|
|
111
117
|
* @param {Uint8Array} out
|
|
112
118
|
*/
|
|
113
|
-
render(page, scale, x, y, width, height, rotation, flags, background, out) {
|
|
119
|
+
render(page, scale, x, y, width, height, rotation, flags, background, appearance, ink, paper, out) {
|
|
114
120
|
var ptr0 = passArray8ToWasm0(out, wasm.__wbindgen_malloc);
|
|
115
121
|
var len0 = WASM_VECTOR_LEN;
|
|
116
|
-
const ret = wasm.hayrodocument_render(this.__wbg_ptr, page, scale, x, y, width, height, rotation, flags, isLikeNone(background) ? Number.MAX_SAFE_INTEGER : (background) >>> 0, ptr0, len0, out);
|
|
122
|
+
const ret = wasm.hayrodocument_render(this.__wbg_ptr, page, scale, x, y, width, height, rotation, flags, isLikeNone(background) ? Number.MAX_SAFE_INTEGER : (background) >>> 0, appearance, ink, paper, ptr0, len0, out);
|
|
117
123
|
if (ret[1]) {
|
|
118
124
|
throw takeFromExternrefTable0(ret[0]);
|
|
119
125
|
}
|
|
Binary file
|
|
@@ -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
|
*/
|
|
@@ -354,6 +453,32 @@ export interface SetInfo {
|
|
|
354
453
|
*/
|
|
355
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" };
|
|
356
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
|
+
|
|
357
482
|
/**
|
|
358
483
|
* How a run of text is drawn.
|
|
359
484
|
*/
|
|
@@ -518,6 +643,32 @@ export interface StructureNodeJs {
|
|
|
518
643
|
kids: StructureKidJs[];
|
|
519
644
|
}
|
|
520
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
|
+
|
|
521
672
|
/**
|
|
522
673
|
* One outline item and its children.
|
|
523
674
|
*/
|
|
@@ -905,6 +1056,11 @@ export interface DocumentInfoJs {
|
|
|
905
1056
|
*/
|
|
906
1057
|
export type PdfVersionInit = "1.4" | "1.5" | "1.6" | "1.7" | "2.0";
|
|
907
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
|
+
|
|
908
1064
|
/**
|
|
909
1065
|
* The cross-reference form.
|
|
910
1066
|
*/
|
|
@@ -1008,6 +1164,62 @@ export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
|
1008
1164
|
*/
|
|
1009
1165
|
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
1010
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
|
+
|
|
1011
1223
|
/**
|
|
1012
1224
|
* What a run measures.
|
|
1013
1225
|
*/
|
|
@@ -1067,6 +1279,11 @@ export interface SaveReportJs {
|
|
|
1067
1279
|
*/
|
|
1068
1280
|
export type OutputJs = "whole" | "appendedOnly";
|
|
1069
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
|
+
|
|
1070
1287
|
/**
|
|
1071
1288
|
* What happens to hidden text and page furniture.
|
|
1072
1289
|
*/
|
|
@@ -1390,6 +1607,13 @@ export class WasmDocument {
|
|
|
1390
1607
|
* Reading errors.
|
|
1391
1608
|
*/
|
|
1392
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[];
|
|
1393
1617
|
/**
|
|
1394
1618
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
1395
1619
|
*
|
|
@@ -1397,6 +1621,13 @@ export class WasmDocument {
|
|
|
1397
1621
|
* `page-index-out-of-range`; reading errors.
|
|
1398
1622
|
*/
|
|
1399
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;
|
|
1400
1631
|
/**
|
|
1401
1632
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
1402
1633
|
*
|
|
@@ -1910,6 +2141,8 @@ export interface InitOutput {
|
|
|
1910
2141
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
1911
2142
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1912
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];
|
|
1913
2146
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1914
2147
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1915
2148
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
package/dist/lamina_pdf_text.js
CHANGED
|
@@ -504,6 +504,22 @@ export class WasmDocument {
|
|
|
504
504
|
}
|
|
505
505
|
return takeFromExternrefTable0(ret[0]);
|
|
506
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* The visible links on page `index`, in annotation order (the extract and text modules).
|
|
509
|
+
*
|
|
510
|
+
* # Errors
|
|
511
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
512
|
+
* @param {number} index
|
|
513
|
+
* @returns {PageLinkJs[]}
|
|
514
|
+
*/
|
|
515
|
+
pageLinks(index) {
|
|
516
|
+
let ret;
|
|
517
|
+
ret = wasm.wasmdocument_pageLinks(this.__wbg_ptr, index);
|
|
518
|
+
if (ret[2]) {
|
|
519
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
520
|
+
}
|
|
521
|
+
return takeFromExternrefTable0(ret[0]);
|
|
522
|
+
}
|
|
507
523
|
/**
|
|
508
524
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
509
525
|
*
|
|
@@ -520,6 +536,21 @@ export class WasmDocument {
|
|
|
520
536
|
}
|
|
521
537
|
return WasmPage.__wrap(ret[0]);
|
|
522
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* The document's properties (the extract and text modules). Reads every object once.
|
|
541
|
+
*
|
|
542
|
+
* # Errors
|
|
543
|
+
* `data-pending` and the reading errors.
|
|
544
|
+
* @returns {PropertiesJs}
|
|
545
|
+
*/
|
|
546
|
+
properties() {
|
|
547
|
+
let ret;
|
|
548
|
+
ret = wasm.wasmdocument_properties(this.__wbg_ptr);
|
|
549
|
+
if (ret[2]) {
|
|
550
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
551
|
+
}
|
|
552
|
+
return takeFromExternrefTable0(ret[0]);
|
|
553
|
+
}
|
|
523
554
|
/**
|
|
524
555
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
525
556
|
*
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laminapdf/wasm",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.5",
|
|
4
4
|
"description": "Lamina PDF's WebAssembly modules and their wasm-bindgen glue: lamina_pdf_base (open, read, edit, save, vector and image pages), lamina_pdf_text (all of base plus fonts and text) and lamina_pdf_extract (all of base plus text extraction); and lamina_pdf_render_hayro, laminapdf-render's hayro adapter, which @laminapdf/render-hayro wraps. Generated into dist/ by `cargo xtask wasm`; @laminapdf/sdk is the API to use.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"homepage": "https://laminapdf.com",
|