@laminapdf/wasm 0.2.0-alpha.6 → 0.2.0
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/dist/lamina_pdf_base.d.ts +438 -1
- package/dist/lamina_pdf_base.js +84 -0
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +438 -1
- package/dist/lamina_pdf_extract.js +84 -0
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +496 -1
- package/dist/lamina_pdf_text.js +164 -0
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +9 -3
|
@@ -44,11 +44,117 @@ export type PageLinkJs = {
|
|
|
44
44
|
} & LinkToJs;
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A change a signature's restriction forbids.
|
|
49
|
+
*/
|
|
50
|
+
export interface ViolationJs {
|
|
51
|
+
/**
|
|
52
|
+
* The kind of change.
|
|
53
|
+
*/
|
|
54
|
+
class: ModificationClass;
|
|
55
|
+
/**
|
|
56
|
+
* `docMdp`, `fieldMdp`, `usageRights`, `signedBytes` or `signedWidget`.
|
|
57
|
+
*/
|
|
58
|
+
restriction: string;
|
|
59
|
+
/**
|
|
60
|
+
* The certification's `/P` (1, 2 or 3), for a `docMdp` restriction.
|
|
61
|
+
*/
|
|
62
|
+
permission?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The signature that carries the restriction.
|
|
65
|
+
*/
|
|
66
|
+
signature: SignatureJs;
|
|
67
|
+
/**
|
|
68
|
+
* The form field whose widget a page edit deletes or reshows (its ID), for a
|
|
69
|
+
* `signedWidget` restriction or a `fieldMdp` one that a page edit breaks.
|
|
70
|
+
*/
|
|
71
|
+
field?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A conformance claim the document's metadata no longer meets.
|
|
76
|
+
*
|
|
77
|
+
* Added in 0.2.0.
|
|
78
|
+
*/
|
|
79
|
+
export type ConformanceWarning = { code: "pdfa-one-author"; authors: number } | { code: "pdfua-title-missing" } | { code: "pdfa-info-mismatch"; keys: MetadataKey[] };
|
|
80
|
+
|
|
47
81
|
/**
|
|
48
82
|
* A conformance profile.
|
|
49
83
|
*/
|
|
50
84
|
export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
|
|
51
85
|
|
|
86
|
+
/**
|
|
87
|
+
* A document's metadata as one record, read from the Info dictionary and the XMP packet.
|
|
88
|
+
*
|
|
89
|
+
* When the two disagree, the values come from the XMP packet in a PDF 2.0 file (ISO 32000-2
|
|
90
|
+
* §14.3.3 deprecates the Info entries) or a file that claims PDF/A (whose packet is
|
|
91
|
+
* authoritative, ISO 19005-2 §6.6.2.3.1), and otherwise from the side whose modification date
|
|
92
|
+
* is newer, Info winning a tie. A field the winning side lacks is taken from the other.
|
|
93
|
+
* [`disagreements`](DocumentMetadata::disagreements) names the fields where the two differ, so
|
|
94
|
+
* a properties view can say so.
|
|
95
|
+
*
|
|
96
|
+
* Added in 0.2.0.
|
|
97
|
+
*/
|
|
98
|
+
export interface DocumentMetadata {
|
|
99
|
+
/**
|
|
100
|
+
* The title.
|
|
101
|
+
*/
|
|
102
|
+
title?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The authors, in order (Info's `/Author` split at `;`).
|
|
105
|
+
*/
|
|
106
|
+
authors: string[];
|
|
107
|
+
/**
|
|
108
|
+
* The subject.
|
|
109
|
+
*/
|
|
110
|
+
subject?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The keywords.
|
|
113
|
+
*/
|
|
114
|
+
keywords?: string;
|
|
115
|
+
/**
|
|
116
|
+
* The application the content came from.
|
|
117
|
+
*/
|
|
118
|
+
creator?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The application that wrote the PDF.
|
|
121
|
+
*/
|
|
122
|
+
producer?: string;
|
|
123
|
+
/**
|
|
124
|
+
* The creation date (a PDF date string on the wire).
|
|
125
|
+
*/
|
|
126
|
+
created?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The modification date.
|
|
129
|
+
*/
|
|
130
|
+
modified?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Which side the values come from.
|
|
133
|
+
*/
|
|
134
|
+
source: MetadataSource;
|
|
135
|
+
/**
|
|
136
|
+
* The fields where Info and XMP hold different values.
|
|
137
|
+
*/
|
|
138
|
+
disagreements: MetadataKey[];
|
|
139
|
+
/**
|
|
140
|
+
* What `/Metadata` holds.
|
|
141
|
+
*/
|
|
142
|
+
packet: PacketStatus;
|
|
143
|
+
/**
|
|
144
|
+
* The PDF/A part and conformance the packet claims (`pdfaid:`), e.g. `"2B"`.
|
|
145
|
+
*/
|
|
146
|
+
pdfa?: string;
|
|
147
|
+
/**
|
|
148
|
+
* The PDF/UA part the packet claims (`pdfuaid:part`).
|
|
149
|
+
*/
|
|
150
|
+
pdfua?: number;
|
|
151
|
+
/**
|
|
152
|
+
* In a PDF 2.0 file, the Info entries besides the two dates: deprecated, kept as they
|
|
153
|
+
* were for older readers, and never written by an edit.
|
|
154
|
+
*/
|
|
155
|
+
keptInfoKeys: MetadataKey[];
|
|
156
|
+
}
|
|
157
|
+
|
|
52
158
|
/**
|
|
53
159
|
* A document's properties, for a properties view.
|
|
54
160
|
*/
|
|
@@ -193,12 +299,33 @@ export interface RegionInit {
|
|
|
193
299
|
* ```
|
|
194
300
|
*
|
|
195
301
|
* [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
|
|
302
|
+
*
|
|
303
|
+
* Added in 0.2.0.
|
|
196
304
|
*/
|
|
197
305
|
export interface OpLog {
|
|
198
306
|
v: 1;
|
|
199
307
|
ops: Op[];
|
|
200
308
|
}
|
|
201
309
|
|
|
310
|
+
/**
|
|
311
|
+
* A metadata field Lamina PDF keeps in step in the Info dictionary and the XMP packet: what
|
|
312
|
+
* [`RemoveMetadata`] removes and [`DocumentMetadata::disagreements`] names.
|
|
313
|
+
*
|
|
314
|
+
* | Key | Info | XMP |
|
|
315
|
+
* | --- | --- | --- |
|
|
316
|
+
* | `title` | `/Title` | `dc:title` |
|
|
317
|
+
* | `authors` | `/Author` (joined with `; `) | `dc:creator` |
|
|
318
|
+
* | `subject` | `/Subject` | `dc:description` |
|
|
319
|
+
* | `keywords` | `/Keywords` | `pdf:Keywords` |
|
|
320
|
+
* | `creator` | `/Creator` | `xmp:CreatorTool` |
|
|
321
|
+
* | `producer` | `/Producer` | `pdf:Producer` |
|
|
322
|
+
* | `created` | `/CreationDate` | `xmp:CreateDate` |
|
|
323
|
+
* | `modified` | `/ModDate` | `xmp:ModifyDate` |
|
|
324
|
+
*
|
|
325
|
+
* Added in 0.2.0.
|
|
326
|
+
*/
|
|
327
|
+
export type MetadataKey = "title" | "authors" | "subject" | "keywords" | "creator" | "producer" | "created" | "modified";
|
|
328
|
+
|
|
202
329
|
/**
|
|
203
330
|
* A model result the job waits for.
|
|
204
331
|
*/
|
|
@@ -267,6 +394,24 @@ export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLet
|
|
|
267
394
|
*/
|
|
268
395
|
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
269
396
|
|
|
397
|
+
/**
|
|
398
|
+
* A signature the planner found.
|
|
399
|
+
*/
|
|
400
|
+
export interface SignatureJs {
|
|
401
|
+
/**
|
|
402
|
+
* `approval`, `certification`, `docTimeStamp` or `usageRights`.
|
|
403
|
+
*/
|
|
404
|
+
kind: string;
|
|
405
|
+
/**
|
|
406
|
+
* The signature field's ID, when a field holds it.
|
|
407
|
+
*/
|
|
408
|
+
field?: string;
|
|
409
|
+
/**
|
|
410
|
+
* The 1-based revision the signature closes, when known.
|
|
411
|
+
*/
|
|
412
|
+
revision?: number;
|
|
413
|
+
}
|
|
414
|
+
|
|
270
415
|
/**
|
|
271
416
|
* A step's progress, and the model result the job waits for, if any.
|
|
272
417
|
*/
|
|
@@ -345,8 +490,10 @@ export interface AttachmentInit {
|
|
|
345
490
|
* ```
|
|
346
491
|
*
|
|
347
492
|
* [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
|
|
493
|
+
*
|
|
494
|
+
* Added in 0.2.0.
|
|
348
495
|
*/
|
|
349
|
-
export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage };
|
|
496
|
+
export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage } | { op: "setMetadata"; args: SetMetadata } | { op: "removeMetadata"; args: RemoveMetadata };
|
|
350
497
|
|
|
351
498
|
/**
|
|
352
499
|
* Changes to the Info dictionary's text entries. For each field, `None` leaves the entry
|
|
@@ -355,6 +502,8 @@ export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: Ro
|
|
|
355
502
|
*
|
|
356
503
|
* On the wire an absent field is left alone and `null` clears: `{ "title": "Report",
|
|
357
504
|
* "author": null }`.
|
|
505
|
+
*
|
|
506
|
+
* Added in 0.2.0.
|
|
358
507
|
*/
|
|
359
508
|
export interface InfoPatch {
|
|
360
509
|
/**
|
|
@@ -383,13 +532,75 @@ export interface InfoPatch {
|
|
|
383
532
|
producer?: string | null;
|
|
384
533
|
}
|
|
385
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Changes to the document's metadata. For each field, `None` leaves it alone, `Some(None)`
|
|
537
|
+
* removes it and `Some(Some(value))` sets it, in Info and XMP alike.
|
|
538
|
+
*
|
|
539
|
+
* On the wire an absent field is left alone and `null` removes: `{ "title": "Report",
|
|
540
|
+
* "authors": ["Ada Lovelace", "Charles Babbage"], "keywords": null }`; dates are PDF date
|
|
541
|
+
* strings (`"D:20261110093000+01'00'"`).
|
|
542
|
+
*
|
|
543
|
+
* ```
|
|
544
|
+
* use laminapdf_ops::MetadataPatch;
|
|
545
|
+
*
|
|
546
|
+
* let patch = MetadataPatch::new().title(Some("Quarterly figures")).authors(&["Ada Lovelace", "Charles Babbage"]);
|
|
547
|
+
* assert_eq!(patch.authors, Some(Some(vec!["Ada Lovelace".to_owned(), "Charles Babbage".to_owned()])));
|
|
548
|
+
* assert_eq!(serde_json::to_string(&patch)?, r#"{"title":"Quarterly figures","authors":["Ada Lovelace","Charles Babbage"]}"#);
|
|
549
|
+
* # Ok::<(), serde_json::Error>(())
|
|
550
|
+
* ```
|
|
551
|
+
*
|
|
552
|
+
* Added in 0.2.0.
|
|
553
|
+
*/
|
|
554
|
+
export interface MetadataPatch {
|
|
555
|
+
/**
|
|
556
|
+
* `/Title`, `dc:title`.
|
|
557
|
+
*/
|
|
558
|
+
title?: string | null;
|
|
559
|
+
/**
|
|
560
|
+
* `/Author` (joined with `; `), `dc:creator` (in order). An empty list removes them.
|
|
561
|
+
*/
|
|
562
|
+
authors?: string[] | null;
|
|
563
|
+
/**
|
|
564
|
+
* `/Subject`, `dc:description`.
|
|
565
|
+
*/
|
|
566
|
+
subject?: string | null;
|
|
567
|
+
/**
|
|
568
|
+
* `/Keywords`, `pdf:Keywords`.
|
|
569
|
+
*/
|
|
570
|
+
keywords?: string | null;
|
|
571
|
+
/**
|
|
572
|
+
* `/Creator`, `xmp:CreatorTool`: the application the content came from.
|
|
573
|
+
*/
|
|
574
|
+
creator?: string | null;
|
|
575
|
+
/**
|
|
576
|
+
* `/Producer`, `pdf:Producer`: the application that wrote the PDF.
|
|
577
|
+
*/
|
|
578
|
+
producer?: string | null;
|
|
579
|
+
/**
|
|
580
|
+
* `/CreationDate`, `xmp:CreateDate`.
|
|
581
|
+
*/
|
|
582
|
+
created?: string | null;
|
|
583
|
+
/**
|
|
584
|
+
* `/ModDate`, `xmp:ModifyDate`.
|
|
585
|
+
*/
|
|
586
|
+
modified?: string | null;
|
|
587
|
+
}
|
|
588
|
+
|
|
386
589
|
/**
|
|
387
590
|
* Edits the Info dictionary: applies `patch` and, when `at` is given, sets `/ModDate` to it.
|
|
591
|
+
*
|
|
592
|
+
* **Deprecated:** use [`SetMetadata`](crate::SetMetadata), which writes authors as a list and
|
|
593
|
+
* the dates, and edits files whose metadata is in XMP alone. `SetInfo` stays, with its v1 wire
|
|
594
|
+
* form (`setInfo`) and meaning, so op logs already written still apply (ADR 0006 §6). It now
|
|
595
|
+
* goes through the same writer, so a document's XMP packet, when it has one, changes with it.
|
|
596
|
+
* It adds a packet only to a PDF 2.0 file, where the fields other than the dates belong in XMP.
|
|
388
597
|
* The date is part of the op, never read from a clock, so the same op gives the same bytes
|
|
389
598
|
* everywhere (ADR 0006 §1).
|
|
390
599
|
*
|
|
391
600
|
* An Info dictionary written directly in the trailer, or missing, becomes a new indirect
|
|
392
601
|
* object that the trailer's `/Info` points to (the first time the op changes something).
|
|
602
|
+
*
|
|
603
|
+
* Added in 0.2.0.
|
|
393
604
|
*/
|
|
394
605
|
export interface SetInfo {
|
|
395
606
|
/**
|
|
@@ -402,6 +613,42 @@ export interface SetInfo {
|
|
|
402
613
|
at?: string;
|
|
403
614
|
}
|
|
404
615
|
|
|
616
|
+
/**
|
|
617
|
+
* Edits the document's metadata: applies `patch` to the Info dictionary and the XMP packet
|
|
618
|
+
* together and, when `at` is given, records it as the modification date (`/ModDate`,
|
|
619
|
+
* `xmp:ModifyDate`) and as `xmp:MetadataDate`, unless the patch sets the modification date
|
|
620
|
+
* itself. The date is part of the op, never read from a clock (ADR 0006 §1).
|
|
621
|
+
*
|
|
622
|
+
* ```
|
|
623
|
+
* use laminapdf_ops::{MetadataPatch, Op, SetMetadata};
|
|
624
|
+
*
|
|
625
|
+
* let op = Op::from(SetMetadata::new(MetadataPatch::new().title(Some("Minutes")), Some("D:20261110093000Z".parse()?)));
|
|
626
|
+
* assert_eq!(
|
|
627
|
+
* serde_json::to_string(&op)?,
|
|
628
|
+
* r#"{"op":"setMetadata","args":{"patch":{"title":"Minutes"},"at":"D:20261110093000Z"}}"#
|
|
629
|
+
* );
|
|
630
|
+
* # Ok::<(), Box<dyn std::error::Error>>(())
|
|
631
|
+
* ```
|
|
632
|
+
*
|
|
633
|
+
* Added in 0.2.0.
|
|
634
|
+
*/
|
|
635
|
+
export interface SetMetadata {
|
|
636
|
+
/**
|
|
637
|
+
* The fields to set or remove.
|
|
638
|
+
*/
|
|
639
|
+
patch?: MetadataPatch;
|
|
640
|
+
/**
|
|
641
|
+
* The modification date the edit writes.
|
|
642
|
+
*/
|
|
643
|
+
at?: string;
|
|
644
|
+
/**
|
|
645
|
+
* Replace an XMP packet that can't be read with a new one, losing whatever it held.
|
|
646
|
+
* Without it, such a packet makes the op fail with `malformed-xmp`, so nothing is lost
|
|
647
|
+
* without the user saying so.
|
|
648
|
+
*/
|
|
649
|
+
replaceMalformed?: boolean;
|
|
650
|
+
}
|
|
651
|
+
|
|
405
652
|
/**
|
|
406
653
|
* How a destination shows its page (§12.3.2.2).
|
|
407
654
|
*/
|
|
@@ -433,6 +680,65 @@ export interface EncryptionJs {
|
|
|
433
680
|
permissions?: PermissionsJs;
|
|
434
681
|
}
|
|
435
682
|
|
|
683
|
+
/**
|
|
684
|
+
* How a save would go (`laminapdf::PlannedSave`).
|
|
685
|
+
*/
|
|
686
|
+
export interface PlannedSaveJs {
|
|
687
|
+
/**
|
|
688
|
+
* The mode the save resolves to; absent when it would be refused.
|
|
689
|
+
*/
|
|
690
|
+
mode?: SaveModeJs;
|
|
691
|
+
/**
|
|
692
|
+
* The code the save would be refused with.
|
|
693
|
+
*/
|
|
694
|
+
refusal?: string;
|
|
695
|
+
/**
|
|
696
|
+
* `free`, `appendOnly`, `requiresRewrite` or `conflict`.
|
|
697
|
+
*/
|
|
698
|
+
constraint: string;
|
|
699
|
+
/**
|
|
700
|
+
* Every signature, in the order found.
|
|
701
|
+
*/
|
|
702
|
+
signatures: SignatureJs[];
|
|
703
|
+
/**
|
|
704
|
+
* The certification's `/P` (1, 2 or 3), when the document is certified.
|
|
705
|
+
*/
|
|
706
|
+
docMdp?: number;
|
|
707
|
+
/**
|
|
708
|
+
* Why only a full rewrite is safe: `repairedBase`, `encryptedBase`, `noBase`,
|
|
709
|
+
* `opRequiresRewrite`.
|
|
710
|
+
*/
|
|
711
|
+
rewriteReasons: string[];
|
|
712
|
+
/**
|
|
713
|
+
* The pending changes a signature's restriction forbids.
|
|
714
|
+
*/
|
|
715
|
+
violations: ViolationJs[];
|
|
716
|
+
/**
|
|
717
|
+
* The signatures the save would invalidate (only with `invalidateSignatures`).
|
|
718
|
+
*/
|
|
719
|
+
wouldInvalidate: SignatureJs[];
|
|
720
|
+
/**
|
|
721
|
+
* Whether the save writes an encrypted document as plaintext.
|
|
722
|
+
*/
|
|
723
|
+
removesEncryption: boolean;
|
|
724
|
+
/**
|
|
725
|
+
* What the save does with the save-time metadata: `none`, `stamp` or `skipped`.
|
|
726
|
+
*/
|
|
727
|
+
metadata: string;
|
|
728
|
+
/**
|
|
729
|
+
* Whether an edit to save rewrote the XMP packet whole.
|
|
730
|
+
*/
|
|
731
|
+
packetRewritten: boolean;
|
|
732
|
+
/**
|
|
733
|
+
* The PDF/A and PDF/UA claims the edited metadata breaks (warnings that never block).
|
|
734
|
+
*/
|
|
735
|
+
conformanceWarnings: Diagnostic[];
|
|
736
|
+
/**
|
|
737
|
+
* The document has no changes.
|
|
738
|
+
*/
|
|
739
|
+
unchanged: boolean;
|
|
740
|
+
}
|
|
741
|
+
|
|
436
742
|
/**
|
|
437
743
|
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
438
744
|
*/
|
|
@@ -832,6 +1138,48 @@ export interface SaveOptionsInit {
|
|
|
832
1138
|
* The cross-reference form.
|
|
833
1139
|
*/
|
|
834
1140
|
xref?: XrefJs;
|
|
1141
|
+
/**
|
|
1142
|
+
* When the save happens, as the app's clock reads it: a PDF date (`D:20261110093000Z`)
|
|
1143
|
+
* or an ISO 8601 date-time. A save that writes changes stamps it as the modification and
|
|
1144
|
+
* metadata dates and gives the XMP packet a new instance ID.
|
|
1145
|
+
*/
|
|
1146
|
+
metadataDate?: string;
|
|
1147
|
+
/**
|
|
1148
|
+
* The XMP instance ID the save writes, a UUID (`uuid:` optional); without it, one is
|
|
1149
|
+
* derived from the content.
|
|
1150
|
+
*/
|
|
1151
|
+
instanceId?: string;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Removes metadata fields from the Info dictionary and the XMP packet; the packet's other
|
|
1156
|
+
* properties stay (J.10).
|
|
1157
|
+
*
|
|
1158
|
+
* The values stay in the file's earlier revisions until a full rewrite: an incremental save
|
|
1159
|
+
* appends the change and keeps the original bytes. When it removed anything, the op's result
|
|
1160
|
+
* says so ([`Applied::still_in_earlier_revisions`](crate::Applied::still_in_earlier_revisions)),
|
|
1161
|
+
* so the caller can offer a full rewrite (on a signed file, the override that removes the
|
|
1162
|
+
* signatures).
|
|
1163
|
+
*
|
|
1164
|
+
* ```
|
|
1165
|
+
* use laminapdf_ops::{MetadataKey, Op, RemoveMetadata};
|
|
1166
|
+
*
|
|
1167
|
+
* let op = Op::from(RemoveMetadata::new(vec![MetadataKey::Authors, MetadataKey::Creator]));
|
|
1168
|
+
* assert_eq!(serde_json::to_string(&op)?, r#"{"op":"removeMetadata","args":{"keys":["authors","creator"]}}"#);
|
|
1169
|
+
* # Ok::<(), serde_json::Error>(())
|
|
1170
|
+
* ```
|
|
1171
|
+
*
|
|
1172
|
+
* Added in 0.2.0.
|
|
1173
|
+
*/
|
|
1174
|
+
export interface RemoveMetadata {
|
|
1175
|
+
/**
|
|
1176
|
+
* The fields to remove.
|
|
1177
|
+
*/
|
|
1178
|
+
keys: MetadataKey[];
|
|
1179
|
+
/**
|
|
1180
|
+
* As [`SetMetadata::replace_malformed`].
|
|
1181
|
+
*/
|
|
1182
|
+
replaceMalformed?: boolean;
|
|
835
1183
|
}
|
|
836
1184
|
|
|
837
1185
|
/**
|
|
@@ -846,6 +1194,8 @@ export interface SaveOptionsInit {
|
|
|
846
1194
|
* On the wire: `{ "op": "rotatePage", "args": { "page": "p12.0", "rotate": 90 } }`.
|
|
847
1195
|
*
|
|
848
1196
|
* [ADR 0005]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0005-document-model.md
|
|
1197
|
+
*
|
|
1198
|
+
* Added in 0.2.0.
|
|
849
1199
|
*/
|
|
850
1200
|
export interface RotatePage {
|
|
851
1201
|
/**
|
|
@@ -946,6 +1296,8 @@ export interface MetadataInit {
|
|
|
946
1296
|
* permissions and the document's `SaveConstraint` ([ADR 0007]).
|
|
947
1297
|
*
|
|
948
1298
|
* [ADR 0007]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0007-save-planner.md
|
|
1299
|
+
*
|
|
1300
|
+
* Added in 0.2.0.
|
|
949
1301
|
*/
|
|
950
1302
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
951
1303
|
|
|
@@ -979,6 +1331,15 @@ export interface EditedJs {
|
|
|
979
1331
|
* IDs of the pages whose content or attributes changed.
|
|
980
1332
|
*/
|
|
981
1333
|
touchedPages: string[];
|
|
1334
|
+
/**
|
|
1335
|
+
* A metadata edit rewrote the XMP packet whole (UTF-16, or marked read-only).
|
|
1336
|
+
*/
|
|
1337
|
+
packetRewritten: boolean;
|
|
1338
|
+
/**
|
|
1339
|
+
* A metadata edit removed values the file's earlier revisions still hold, which only a
|
|
1340
|
+
* full rewrite drops.
|
|
1341
|
+
*/
|
|
1342
|
+
stillInEarlierRevisions: boolean;
|
|
982
1343
|
/**
|
|
983
1344
|
* Whether the edit changed the document: one that only set values they already had leaves
|
|
984
1345
|
* no step to undo.
|
|
@@ -1090,6 +1451,24 @@ export interface SaveReportJs {
|
|
|
1090
1451
|
* Whether encryption was removed.
|
|
1091
1452
|
*/
|
|
1092
1453
|
encryptionRemoved: boolean;
|
|
1454
|
+
/**
|
|
1455
|
+
* Whether the save stamped the save-time metadata (`metadataDate`, `instanceId`).
|
|
1456
|
+
*/
|
|
1457
|
+
metadataUpdated: boolean;
|
|
1458
|
+
/**
|
|
1459
|
+
* Whether the options asked for the stamp and the save left it out, because it would have
|
|
1460
|
+
* broken a signature's restriction the saved changes keep.
|
|
1461
|
+
*/
|
|
1462
|
+
metadataNotUpdated: boolean;
|
|
1463
|
+
/**
|
|
1464
|
+
* Whether an edit saved here rewrote the XMP packet whole.
|
|
1465
|
+
*/
|
|
1466
|
+
packetRewritten: boolean;
|
|
1467
|
+
/**
|
|
1468
|
+
* Whether the save emptied the undo history (a full rewrite, or an incremental save that
|
|
1469
|
+
* freed objects); for a copy, whether adopting it would.
|
|
1470
|
+
*/
|
|
1471
|
+
historyCleared: boolean;
|
|
1093
1472
|
}
|
|
1094
1473
|
|
|
1095
1474
|
/**
|
|
@@ -1131,6 +1510,13 @@ export interface DropInit {
|
|
|
1131
1510
|
furniture?: boolean;
|
|
1132
1511
|
}
|
|
1133
1512
|
|
|
1513
|
+
/**
|
|
1514
|
+
* What the document's `/Metadata` holds.
|
|
1515
|
+
*
|
|
1516
|
+
* Added in 0.2.0.
|
|
1517
|
+
*/
|
|
1518
|
+
export type PacketStatus = "absent" | "parsed" | "malformed";
|
|
1519
|
+
|
|
1134
1520
|
/**
|
|
1135
1521
|
* Where a link or outline item goes.
|
|
1136
1522
|
*/
|
|
@@ -1146,6 +1532,13 @@ export type SplitOnName = "headings" | "blocks" | "pages";
|
|
|
1146
1532
|
*/
|
|
1147
1533
|
export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
|
|
1148
1534
|
|
|
1535
|
+
/**
|
|
1536
|
+
* Which side [`DocumentMetadata`]'s values come from.
|
|
1537
|
+
*
|
|
1538
|
+
* Added in 0.2.0.
|
|
1539
|
+
*/
|
|
1540
|
+
export type MetadataSource = "info" | "xmp";
|
|
1541
|
+
|
|
1149
1542
|
/**
|
|
1150
1543
|
* Which table detectors run.
|
|
1151
1544
|
*/
|
|
@@ -1305,6 +1698,15 @@ export class WasmDocument {
|
|
|
1305
1698
|
private constructor();
|
|
1306
1699
|
free(): void;
|
|
1307
1700
|
[Symbol.dispose](): void;
|
|
1701
|
+
/**
|
|
1702
|
+
* Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
|
|
1703
|
+
* them), once they are written where the document lives; `historyCleared` is the copy's
|
|
1704
|
+
* report's.
|
|
1705
|
+
*
|
|
1706
|
+
* # Errors
|
|
1707
|
+
* `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
|
|
1708
|
+
*/
|
|
1709
|
+
adoptCopy(bytes: Uint8Array, historyCleared: boolean): void;
|
|
1308
1710
|
/**
|
|
1309
1711
|
* Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
|
|
1310
1712
|
*
|
|
@@ -1361,6 +1763,14 @@ export class WasmDocument {
|
|
|
1361
1763
|
* Reading errors.
|
|
1362
1764
|
*/
|
|
1363
1765
|
isTagged(): boolean;
|
|
1766
|
+
/**
|
|
1767
|
+
* The document's metadata, read from Info and XMP together, with the fields where they
|
|
1768
|
+
* disagree.
|
|
1769
|
+
*
|
|
1770
|
+
* # Errors
|
|
1771
|
+
* Reading errors.
|
|
1772
|
+
*/
|
|
1773
|
+
metadata(): DocumentMetadata;
|
|
1364
1774
|
/**
|
|
1365
1775
|
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1366
1776
|
* it names no page here (the extract and text modules).
|
|
@@ -1436,6 +1846,13 @@ export class WasmDocument {
|
|
|
1436
1846
|
* `page-index-out-of-range`; reading errors.
|
|
1437
1847
|
*/
|
|
1438
1848
|
page(index: number): WasmPage;
|
|
1849
|
+
/**
|
|
1850
|
+
* How a save with `options` would go, without saving.
|
|
1851
|
+
*
|
|
1852
|
+
* # Errors
|
|
1853
|
+
* `invalid-argument` / `unknown-option` for bad options; reading errors.
|
|
1854
|
+
*/
|
|
1855
|
+
plan(options: SaveOptionsInit | undefined): PlannedSaveJs;
|
|
1439
1856
|
/**
|
|
1440
1857
|
* The document's properties (the extract and text modules). Reads every object once.
|
|
1441
1858
|
*
|
|
@@ -1467,6 +1884,14 @@ export class WasmDocument {
|
|
|
1467
1884
|
* `data-pending` and the reading errors.
|
|
1468
1885
|
*/
|
|
1469
1886
|
reflow(): string;
|
|
1887
|
+
/**
|
|
1888
|
+
* Writes what `save` would and leaves the document as it was: not rebased, its changes
|
|
1889
|
+
* still unsaved, the save-time stamp in the copy only (Save a copy).
|
|
1890
|
+
*
|
|
1891
|
+
* # Errors
|
|
1892
|
+
* As `save`; the document is unchanged either way.
|
|
1893
|
+
*/
|
|
1894
|
+
saveCopy(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1470
1895
|
/**
|
|
1471
1896
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
1472
1897
|
*
|
|
@@ -1501,6 +1926,13 @@ export class WasmDocument {
|
|
|
1501
1926
|
* A cursor over the warnings so far (build warnings first), each as the §1 object.
|
|
1502
1927
|
*/
|
|
1503
1928
|
warnings(): WasmWarningCursor;
|
|
1929
|
+
/**
|
|
1930
|
+
* The signature restrictions `op` would break if it were applied and saved.
|
|
1931
|
+
*
|
|
1932
|
+
* # Errors
|
|
1933
|
+
* `invalid-argument` for a value that isn't an op; reading errors.
|
|
1934
|
+
*/
|
|
1935
|
+
wouldViolate(op: Op): ViolationJs[];
|
|
1504
1936
|
}
|
|
1505
1937
|
|
|
1506
1938
|
/**
|
|
@@ -1910,6 +2342,7 @@ export interface InitOutput {
|
|
|
1910
2342
|
readonly wasmbuilder_page: (a: number, b: number, c: number) => number;
|
|
1911
2343
|
readonly wasmbuilder_pageLabels: (a: number, b: any) => [number, number];
|
|
1912
2344
|
readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
|
|
2345
|
+
readonly wasmdocument_adoptCopy: (a: number, b: number, c: number, d: number) => [number, number];
|
|
1913
2346
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1914
2347
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1915
2348
|
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
@@ -1918,6 +2351,7 @@ export interface InitOutput {
|
|
|
1918
2351
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
1919
2352
|
readonly wasmdocument_isEncrypted: (a: number) => number;
|
|
1920
2353
|
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
2354
|
+
readonly wasmdocument_metadata: (a: number) => [number, number, number];
|
|
1921
2355
|
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
1922
2356
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1923
2357
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
@@ -1928,15 +2362,18 @@ export interface InitOutput {
|
|
|
1928
2362
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1929
2363
|
readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
|
|
1930
2364
|
readonly wasmdocument_pageLinks: (a: number, b: number) => [number, number, number];
|
|
2365
|
+
readonly wasmdocument_plan: (a: number, b: any) => [number, number, number];
|
|
1931
2366
|
readonly wasmdocument_properties: (a: number) => [number, number, number];
|
|
1932
2367
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1933
2368
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1934
2369
|
readonly wasmdocument_reflow: (a: number) => [number, number, number, number];
|
|
1935
2370
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
2371
|
+
readonly wasmdocument_saveCopy: (a: number, b: any) => [number, number, number];
|
|
1936
2372
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
1937
2373
|
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
1938
2374
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1939
2375
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
2376
|
+
readonly wasmdocument_wouldViolate: (a: number, b: any) => [number, number, number];
|
|
1940
2377
|
readonly wasmextractjob_cancel: (a: number) => void;
|
|
1941
2378
|
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
1942
2379
|
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|