@laminapdf/wasm 0.2.0-alpha.6 → 0.3.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 +1718 -119
- package/dist/lamina_pdf_base.js +224 -0
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +1995 -81
- package/dist/lamina_pdf_extract.js +368 -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 +2029 -57
- package/dist/lamina_pdf_text.js +448 -0
- package/dist/lamina_pdf_text.wasm +0 -0
- package/dist/lamina_pdf_tiff.d.ts +71 -0
- package/dist/lamina_pdf_tiff.js +259 -0
- package/dist/lamina_pdf_tiff.wasm +0 -0
- package/package.json +14 -3
|
@@ -44,11 +44,146 @@ export type PageLinkJs = {
|
|
|
44
44
|
} & LinkToJs;
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A bookmark's look: its colour (`/C`; `None` is the viewer's default, black) and type style
|
|
49
|
+
* (`/F`: bit 1 italic, bit 2 bold).
|
|
50
|
+
*
|
|
51
|
+
* Added in 0.3.0.
|
|
52
|
+
*/
|
|
53
|
+
export interface OutlineStyle {
|
|
54
|
+
/**
|
|
55
|
+
* The colour.
|
|
56
|
+
*/
|
|
57
|
+
color?: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Bold.
|
|
60
|
+
*/
|
|
61
|
+
bold?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Italic.
|
|
64
|
+
*/
|
|
65
|
+
italic?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A change a signature's restriction forbids.
|
|
70
|
+
*/
|
|
71
|
+
export interface ViolationJs {
|
|
72
|
+
/**
|
|
73
|
+
* The kind of change.
|
|
74
|
+
*/
|
|
75
|
+
class: ModificationClass;
|
|
76
|
+
/**
|
|
77
|
+
* `docMdp`, `fieldMdp`, `usageRights`, `signedBytes` or `signedWidget`.
|
|
78
|
+
*/
|
|
79
|
+
restriction: string;
|
|
80
|
+
/**
|
|
81
|
+
* The certification's `/P` (1, 2 or 3), for a `docMdp` restriction.
|
|
82
|
+
*/
|
|
83
|
+
permission?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The signature that carries the restriction.
|
|
86
|
+
*/
|
|
87
|
+
signature: SignatureJs;
|
|
88
|
+
/**
|
|
89
|
+
* The form field whose widget a page edit deletes or reshows (its ID), for a
|
|
90
|
+
* `signedWidget` restriction or a `fieldMdp` one that a page edit breaks.
|
|
91
|
+
*/
|
|
92
|
+
field?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A colour of 8 bits a channel, `"#rrggbb"` on the wire. A bookmark's `/C` (§12.3.3,
|
|
97
|
+
* Table 151) holds it as three numbers from 0 to 1.
|
|
98
|
+
*
|
|
99
|
+
* Added in 0.3.0.
|
|
100
|
+
*/
|
|
101
|
+
export type Rgb = string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A conformance claim the document's metadata no longer meets.
|
|
105
|
+
*
|
|
106
|
+
* Added in 0.2.0.
|
|
107
|
+
*/
|
|
108
|
+
export type ConformanceWarning = { code: "pdfa-one-author"; authors: number } | { code: "pdfua-title-missing" } | { code: "pdfa-info-mismatch"; keys: MetadataKey[] } | { code: "duplicate-tags-incomplete" } | { code: "imported-tags-dropped" } | { code: "imported-pdfa-unchecked" };
|
|
109
|
+
|
|
47
110
|
/**
|
|
48
111
|
* A conformance profile.
|
|
49
112
|
*/
|
|
50
113
|
export type ProfileInit = "PDF/UA-1" | "PDF/A-2b" | "PDF/A-2u" | "PDF/A-3b";
|
|
51
114
|
|
|
115
|
+
/**
|
|
116
|
+
* A document's metadata as one record, read from the Info dictionary and the XMP packet.
|
|
117
|
+
*
|
|
118
|
+
* When the two disagree, the values come from the XMP packet in a PDF 2.0 file (ISO 32000-2
|
|
119
|
+
* §14.3.3 deprecates the Info entries) or a file that claims PDF/A (whose packet is
|
|
120
|
+
* authoritative, ISO 19005-2 §6.6.2.3.1), and otherwise from the side whose modification date
|
|
121
|
+
* is newer, Info winning a tie. A field the winning side lacks is taken from the other.
|
|
122
|
+
* [`disagreements`](DocumentMetadata::disagreements) names the fields where the two differ, so
|
|
123
|
+
* a properties view can say so.
|
|
124
|
+
*
|
|
125
|
+
* Added in 0.2.0.
|
|
126
|
+
*/
|
|
127
|
+
export interface DocumentMetadata {
|
|
128
|
+
/**
|
|
129
|
+
* The title.
|
|
130
|
+
*/
|
|
131
|
+
title?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The authors, in order (Info's `/Author` split at `;`).
|
|
134
|
+
*/
|
|
135
|
+
authors: string[];
|
|
136
|
+
/**
|
|
137
|
+
* The subject.
|
|
138
|
+
*/
|
|
139
|
+
subject?: string;
|
|
140
|
+
/**
|
|
141
|
+
* The keywords.
|
|
142
|
+
*/
|
|
143
|
+
keywords?: string;
|
|
144
|
+
/**
|
|
145
|
+
* The application the content came from.
|
|
146
|
+
*/
|
|
147
|
+
creator?: string;
|
|
148
|
+
/**
|
|
149
|
+
* The application that wrote the PDF.
|
|
150
|
+
*/
|
|
151
|
+
producer?: string;
|
|
152
|
+
/**
|
|
153
|
+
* The creation date (a PDF date string on the wire).
|
|
154
|
+
*/
|
|
155
|
+
created?: string;
|
|
156
|
+
/**
|
|
157
|
+
* The modification date.
|
|
158
|
+
*/
|
|
159
|
+
modified?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Which side the values come from.
|
|
162
|
+
*/
|
|
163
|
+
source: MetadataSource;
|
|
164
|
+
/**
|
|
165
|
+
* The fields where Info and XMP hold different values.
|
|
166
|
+
*/
|
|
167
|
+
disagreements: MetadataKey[];
|
|
168
|
+
/**
|
|
169
|
+
* What `/Metadata` holds.
|
|
170
|
+
*/
|
|
171
|
+
packet: PacketStatus;
|
|
172
|
+
/**
|
|
173
|
+
* The PDF/A part and conformance the packet claims (`pdfaid:`), e.g. `"2B"`.
|
|
174
|
+
*/
|
|
175
|
+
pdfa?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The PDF/UA part the packet claims (`pdfuaid:part`).
|
|
178
|
+
*/
|
|
179
|
+
pdfua?: number;
|
|
180
|
+
/**
|
|
181
|
+
* In a PDF 2.0 file, the Info entries besides the two dates: deprecated, kept as they
|
|
182
|
+
* were for older readers, and never written by an edit.
|
|
183
|
+
*/
|
|
184
|
+
keptInfoKeys: MetadataKey[];
|
|
185
|
+
}
|
|
186
|
+
|
|
52
187
|
/**
|
|
53
188
|
* A document's properties, for a properties view.
|
|
54
189
|
*/
|
|
@@ -193,12 +328,33 @@ export interface RegionInit {
|
|
|
193
328
|
* ```
|
|
194
329
|
*
|
|
195
330
|
* [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
|
|
331
|
+
*
|
|
332
|
+
* Added in 0.2.0.
|
|
196
333
|
*/
|
|
197
334
|
export interface OpLog {
|
|
198
335
|
v: 1;
|
|
199
336
|
ops: Op[];
|
|
200
337
|
}
|
|
201
338
|
|
|
339
|
+
/**
|
|
340
|
+
* A metadata field Lamina PDF keeps in step in the Info dictionary and the XMP packet: what
|
|
341
|
+
* [`RemoveMetadata`] removes and [`DocumentMetadata::disagreements`] names.
|
|
342
|
+
*
|
|
343
|
+
* | Key | Info | XMP |
|
|
344
|
+
* | --- | --- | --- |
|
|
345
|
+
* | `title` | `/Title` | `dc:title` |
|
|
346
|
+
* | `authors` | `/Author` (joined with `; `) | `dc:creator` |
|
|
347
|
+
* | `subject` | `/Subject` | `dc:description` |
|
|
348
|
+
* | `keywords` | `/Keywords` | `pdf:Keywords` |
|
|
349
|
+
* | `creator` | `/Creator` | `xmp:CreatorTool` |
|
|
350
|
+
* | `producer` | `/Producer` | `pdf:Producer` |
|
|
351
|
+
* | `created` | `/CreationDate` | `xmp:CreateDate` |
|
|
352
|
+
* | `modified` | `/ModDate` | `xmp:ModifyDate` |
|
|
353
|
+
*
|
|
354
|
+
* Added in 0.2.0.
|
|
355
|
+
*/
|
|
356
|
+
export type MetadataKey = "title" | "authors" | "subject" | "keywords" | "creator" | "producer" | "created" | "modified";
|
|
357
|
+
|
|
202
358
|
/**
|
|
203
359
|
* A model result the job waits for.
|
|
204
360
|
*/
|
|
@@ -243,6 +399,32 @@ export interface ModelInfoInit {
|
|
|
243
399
|
licence: string;
|
|
244
400
|
}
|
|
245
401
|
|
|
402
|
+
/**
|
|
403
|
+
* A move in user space (ISO 32000-2 §8.3.2.3: y up), in user-space units. Both distances are
|
|
404
|
+
* finite: [`Offset::new`] and the wire form refuse anything else, so a move never writes a
|
|
405
|
+
* coordinate a PDF can't hold.
|
|
406
|
+
*
|
|
407
|
+
* Added in 0.3.0.
|
|
408
|
+
*/
|
|
409
|
+
export interface Offset {
|
|
410
|
+
dx: number;
|
|
411
|
+
dy: number;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A named destination brought in under another name.
|
|
416
|
+
*/
|
|
417
|
+
export interface RenamedDestinationJs {
|
|
418
|
+
/**
|
|
419
|
+
* Its name in the source.
|
|
420
|
+
*/
|
|
421
|
+
from: string;
|
|
422
|
+
/**
|
|
423
|
+
* Its name in this document.
|
|
424
|
+
*/
|
|
425
|
+
to: string;
|
|
426
|
+
}
|
|
427
|
+
|
|
246
428
|
/**
|
|
247
429
|
* A page and how to show it.
|
|
248
430
|
*/
|
|
@@ -257,16 +439,83 @@ export interface TargetJs {
|
|
|
257
439
|
view: TargetViewJs;
|
|
258
440
|
}
|
|
259
441
|
|
|
442
|
+
/**
|
|
443
|
+
* A page of this document and how to show it: what `/Dest [page /XYZ …]` holds.
|
|
444
|
+
*
|
|
445
|
+
* Added in 0.3.0.
|
|
446
|
+
*/
|
|
447
|
+
export interface ExplicitDestination {
|
|
448
|
+
/**
|
|
449
|
+
* The page.
|
|
450
|
+
*/
|
|
451
|
+
page: string;
|
|
452
|
+
/**
|
|
453
|
+
* How to show it.
|
|
454
|
+
*/
|
|
455
|
+
view: DestinationView;
|
|
456
|
+
}
|
|
457
|
+
|
|
260
458
|
/**
|
|
261
459
|
* A page-label numbering style.
|
|
262
460
|
*/
|
|
263
461
|
export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
|
|
264
462
|
|
|
463
|
+
/**
|
|
464
|
+
* A patch of the window entries of `/ViewerPreferences` ([`WindowPreferences`]): each field
|
|
465
|
+
* left out keeps what the file has, `true` sets the entry, `false` removes it.
|
|
466
|
+
*
|
|
467
|
+
* Added in 0.3.0.
|
|
468
|
+
*/
|
|
469
|
+
export interface WindowPreferencesPatch {
|
|
470
|
+
/**
|
|
471
|
+
* `/HideToolbar`.
|
|
472
|
+
*/
|
|
473
|
+
hideToolbar?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* `/HideMenubar`.
|
|
476
|
+
*/
|
|
477
|
+
hideMenubar?: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* `/HideWindowUI`.
|
|
480
|
+
*/
|
|
481
|
+
hideWindowUi?: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* `/FitWindow`.
|
|
484
|
+
*/
|
|
485
|
+
fitWindow?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* `/CenterWindow`.
|
|
488
|
+
*/
|
|
489
|
+
centerWindow?: boolean;
|
|
490
|
+
/**
|
|
491
|
+
* `/DisplayDocTitle`.
|
|
492
|
+
*/
|
|
493
|
+
displayDocTitle?: boolean;
|
|
494
|
+
}
|
|
495
|
+
|
|
265
496
|
/**
|
|
266
497
|
* A region's kind.
|
|
267
498
|
*/
|
|
268
499
|
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
269
500
|
|
|
501
|
+
/**
|
|
502
|
+
* A signature the planner found.
|
|
503
|
+
*/
|
|
504
|
+
export interface SignatureJs {
|
|
505
|
+
/**
|
|
506
|
+
* `approval`, `certification`, `docTimeStamp` or `usageRights`.
|
|
507
|
+
*/
|
|
508
|
+
kind: string;
|
|
509
|
+
/**
|
|
510
|
+
* The signature field's ID, when a field holds it.
|
|
511
|
+
*/
|
|
512
|
+
field?: string;
|
|
513
|
+
/**
|
|
514
|
+
* The 1-based revision the signature closes, when known.
|
|
515
|
+
*/
|
|
516
|
+
revision?: number;
|
|
517
|
+
}
|
|
518
|
+
|
|
270
519
|
/**
|
|
271
520
|
* A step's progress, and the model result the job waits for, if any.
|
|
272
521
|
*/
|
|
@@ -289,6 +538,60 @@ export interface ExtractProgressJs {
|
|
|
289
538
|
request?: ModelRequestJs;
|
|
290
539
|
}
|
|
291
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Adds a bookmark under `parent` (`null`: the top level) at `at`, with its title, target and
|
|
543
|
+
* style. It has no children, so it has no open state yet (`/Count`, §12.3.3): set it with
|
|
544
|
+
* [`UpdateOutlineItem::open`] once it has some. The new item's ID is in
|
|
545
|
+
* [`Applied::created_outline_items`](crate::Applied::created_outline_items).
|
|
546
|
+
*
|
|
547
|
+
* On the wire: `{ "op": "addOutlineItem", "args": { "parent": null, "at": "last", "title":
|
|
548
|
+
* "Chapter 1", "target": { "destination": { "page": "p3.0", "view": { "kind": "fit" } } } } }`.
|
|
549
|
+
*
|
|
550
|
+
* Added in 0.3.0.
|
|
551
|
+
*/
|
|
552
|
+
export interface AddOutlineItem {
|
|
553
|
+
/**
|
|
554
|
+
* The parent item; `None` for the top level.
|
|
555
|
+
*/
|
|
556
|
+
parent?: string | null;
|
|
557
|
+
/**
|
|
558
|
+
* Where among the parent's children.
|
|
559
|
+
*/
|
|
560
|
+
at: "first" | "last" | { before: string } | { after: string };
|
|
561
|
+
/**
|
|
562
|
+
* The title.
|
|
563
|
+
*/
|
|
564
|
+
title: string;
|
|
565
|
+
/**
|
|
566
|
+
* Where the bookmark goes.
|
|
567
|
+
*/
|
|
568
|
+
target: OutlineTarget;
|
|
569
|
+
/**
|
|
570
|
+
* Its colour and type style.
|
|
571
|
+
*/
|
|
572
|
+
style?: OutlineStyle;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Adds a named destination, or points an existing one at `destination`. A name the catalog's
|
|
577
|
+
* `/Dests` dictionary holds stays there; any other goes into the `/Names /Dests` tree.
|
|
578
|
+
*
|
|
579
|
+
* On the wire: `{ "op": "setNamedDestination", "args": { "name": "results", "destination": {
|
|
580
|
+
* "page": "p7.0", "view": { "kind": "fitH", "top": 700 } } } }`.
|
|
581
|
+
*
|
|
582
|
+
* Added in 0.3.0.
|
|
583
|
+
*/
|
|
584
|
+
export interface SetNamedDestination {
|
|
585
|
+
/**
|
|
586
|
+
* The name.
|
|
587
|
+
*/
|
|
588
|
+
name: string;
|
|
589
|
+
/**
|
|
590
|
+
* Where it points.
|
|
591
|
+
*/
|
|
592
|
+
destination: ExplicitDestination;
|
|
593
|
+
}
|
|
594
|
+
|
|
292
595
|
/**
|
|
293
596
|
* An OCR word, its box as a region's.
|
|
294
597
|
*/
|
|
@@ -307,6 +610,47 @@ export interface WordInit {
|
|
|
307
610
|
confidence: number;
|
|
308
611
|
}
|
|
309
612
|
|
|
613
|
+
/**
|
|
614
|
+
* An XMP property declared in a PDF/A file's extension schemas.
|
|
615
|
+
*/
|
|
616
|
+
export interface ExtensionPropertyJs {
|
|
617
|
+
/**
|
|
618
|
+
* The schema's namespace URI.
|
|
619
|
+
*/
|
|
620
|
+
namespace: string;
|
|
621
|
+
/**
|
|
622
|
+
* The prefix the packet writes the namespace with.
|
|
623
|
+
*/
|
|
624
|
+
prefix: string;
|
|
625
|
+
/**
|
|
626
|
+
* The property's local name.
|
|
627
|
+
*/
|
|
628
|
+
name: string;
|
|
629
|
+
/**
|
|
630
|
+
* Its declared type, e.g. `Text` or `Seq Integer`.
|
|
631
|
+
*/
|
|
632
|
+
valueType: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* An annotation's own geometry, by `kind`; points are flat `[x, y, …]` lists in page space.
|
|
637
|
+
*/
|
|
638
|
+
export type GeometryJs = { kind: "none" } | { kind: "quads"; quads: number[] } | { kind: "ink"; strokes: number[][] } | { kind: "vertices"; points: number[] } | { kind: "line"; points: number[] } | { kind: "callout"; points: number[] };
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* An article thread: its title and its parts in reading order.
|
|
642
|
+
*/
|
|
643
|
+
export interface ThreadJs {
|
|
644
|
+
/**
|
|
645
|
+
* Its title (document text), when it has one.
|
|
646
|
+
*/
|
|
647
|
+
title?: string;
|
|
648
|
+
/**
|
|
649
|
+
* Its parts.
|
|
650
|
+
*/
|
|
651
|
+
parts: ThreadPartJs[];
|
|
652
|
+
}
|
|
653
|
+
|
|
310
654
|
/**
|
|
311
655
|
* An attached file's options.
|
|
312
656
|
*/
|
|
@@ -345,8 +689,149 @@ export interface AttachmentInit {
|
|
|
345
689
|
* ```
|
|
346
690
|
*
|
|
347
691
|
* [ADR 0006]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0006-op-log-and-undo.md
|
|
692
|
+
*
|
|
693
|
+
* Added in 0.2.0.
|
|
694
|
+
*/
|
|
695
|
+
export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage } | { op: "setMetadata"; args: SetMetadata } | { op: "removeMetadata"; args: RemoveMetadata } | { op: "setInitialView"; args: SetInitialView } | { op: "addOutlineItem"; args: AddOutlineItem } | { op: "updateOutlineItem"; args: UpdateOutlineItem } | { op: "moveOutlineItem"; args: MoveOutlineItem } | { op: "deleteOutlineItem"; args: DeleteOutlineItem } | { op: "setNamedDestination"; args: SetNamedDestination } | { op: "renameNamedDestination"; args: RenameNamedDestination } | { op: "deleteNamedDestination"; args: DeleteNamedDestination } | { op: "setXmpProperty"; args: SetXmpProperty } | { op: "removeXmpProperty"; args: RemoveXmpProperty } | { op: "replaceXmpPacket"; args: ReplaceXmpPacket } | { op: "insertBlankPages"; args: InsertBlankPages } | { op: "deletePages"; args: DeletePages } | { op: "movePages"; args: MovePages } | { op: "rotatePages"; args: RotatePages } | { op: "reversePages"; args: ReversePages } | { op: "duplicatePages"; args: DuplicatePages } | { op: "insertPagesFrom"; args: InsertPagesFrom } | { op: "replacePages"; args: ReplacePages } | { op: "mergeDocuments"; args: MergeDocuments } | { op: "updateAnnot"; args: UpdateAnnot } | { op: "deleteAnnot"; args: DeleteAnnot } | { op: "setPageLabels"; args: SetPageLabels };
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Changes a bookmark's title, target, style or open state. An absent field is left alone. A
|
|
699
|
+
* target held as another action (JavaScript, `Launch`, …) is replaced only when `target` is
|
|
700
|
+
* given; the item's other entries are kept.
|
|
701
|
+
*
|
|
702
|
+
* On the wire: `{ "op": "updateOutlineItem", "args": { "item": "o12.0", "title": "Results",
|
|
703
|
+
* "open": true } }`.
|
|
704
|
+
*
|
|
705
|
+
* Added in 0.3.0.
|
|
706
|
+
*/
|
|
707
|
+
export interface UpdateOutlineItem {
|
|
708
|
+
/**
|
|
709
|
+
* The item.
|
|
710
|
+
*/
|
|
711
|
+
item: string;
|
|
712
|
+
/**
|
|
713
|
+
* A new title.
|
|
714
|
+
*/
|
|
715
|
+
title?: string;
|
|
716
|
+
/**
|
|
717
|
+
* A new target.
|
|
718
|
+
*/
|
|
719
|
+
target?: OutlineTarget;
|
|
720
|
+
/**
|
|
721
|
+
* A new style (colour and type style together).
|
|
722
|
+
*/
|
|
723
|
+
style?: OutlineStyle;
|
|
724
|
+
/**
|
|
725
|
+
* Open (children shown) or closed; a bookmark without children has nowhere to keep it
|
|
726
|
+
* (`/Count`, §12.3.3), so it writes nothing there.
|
|
727
|
+
*/
|
|
728
|
+
open?: boolean;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Changes an annotation's common and markup entries and moves it.
|
|
733
|
+
*
|
|
734
|
+
* An absent field leaves the entry alone and `null` removes it. `translate` moves `/Rect` and
|
|
735
|
+
* the subtype's geometry (`/QuadPoints`, `/InkList`, `/Vertices`, `/L`, `/CL`) and the
|
|
736
|
+
* annotation's Popup with it, and keeps the appearance, which §12.5.5 maps onto the new
|
|
737
|
+
* `/Rect`. A `Locked` annotation refuses everything but a change of its flags and its
|
|
738
|
+
* contents; a `LockedContents` one refuses a change of its contents (`annotation-locked`).
|
|
739
|
+
* Widgets and annotations stored as direct dictionaries are refused (`annotation-not-editable`).
|
|
740
|
+
*
|
|
741
|
+
* On the wire: `{ "op": "updateAnnot", "args": { "id": "a12.0", "contents": "Checked",
|
|
742
|
+
* "translate": { "dx": 0, "dy": -10 } } }`.
|
|
743
|
+
*
|
|
744
|
+
* Added in 0.3.0.
|
|
745
|
+
*/
|
|
746
|
+
export interface UpdateAnnot {
|
|
747
|
+
/**
|
|
748
|
+
* The annotation.
|
|
749
|
+
*/
|
|
750
|
+
id: string;
|
|
751
|
+
/**
|
|
752
|
+
* `/Contents`: the comment, or the alternative description.
|
|
753
|
+
*/
|
|
754
|
+
contents?: string | null;
|
|
755
|
+
/**
|
|
756
|
+
* `/T`: the author.
|
|
757
|
+
*/
|
|
758
|
+
author?: string | null;
|
|
759
|
+
/**
|
|
760
|
+
* `/Subj`.
|
|
761
|
+
*/
|
|
762
|
+
subject?: string | null;
|
|
763
|
+
/**
|
|
764
|
+
* `/M`, the modification date the edit writes.
|
|
765
|
+
*/
|
|
766
|
+
modified?: string;
|
|
767
|
+
/**
|
|
768
|
+
* `/F`, all the flags at once (Table 167).
|
|
769
|
+
*/
|
|
770
|
+
flags?: number;
|
|
771
|
+
/**
|
|
772
|
+
* A move in user space.
|
|
773
|
+
*/
|
|
774
|
+
translate?: Offset;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Changes how the document asks to be shown when it opens. Each field is a patch: left out,
|
|
779
|
+
* it keeps what the file has; `null` removes the entry, so readers use their default; a value
|
|
780
|
+
* sets it.
|
|
781
|
+
*
|
|
782
|
+
* * `open`: the page and zoom to open at, written as an explicit destination in
|
|
783
|
+
* `/OpenAction` (§12.3.2.2). An `/OpenAction` that is an action other than `GoTo`
|
|
784
|
+
* (JavaScript, a named action, a link to another file) is never replaced or removed: the op
|
|
785
|
+
* fails with [`Error::OpenActionNotDestination`].
|
|
786
|
+
* * `page_mode`, `page_layout`: the panel to show and how to lay the pages out.
|
|
787
|
+
* * `preferences`: the window entries of `/ViewerPreferences` (§12.2, Table 147); `true` sets
|
|
788
|
+
* one, `false` removes it (its default), and other entries (`/Direction`, `/PrintScaling`, …)
|
|
789
|
+
* are kept.
|
|
790
|
+
*
|
|
791
|
+
* When a value needs a later PDF version than the file declares (`UseAttachments` 1.6,
|
|
792
|
+
* `UseOC` and the two-page layouts 1.5, `/DisplayDocTitle` 1.4), the catalog's `/Version` is
|
|
793
|
+
* raised to it. The op is class [`Document`](crate::ModificationClass::Document) and touches no
|
|
794
|
+
* page.
|
|
795
|
+
*
|
|
796
|
+
* On the wire:
|
|
797
|
+
* `{ "op": "setInitialView", "args": { "open": { "page": "p12.0", "zoom": "fitWidth" },
|
|
798
|
+
* "pageMode": "outlines", "pageLayout": null, "preferences": { "displayDocTitle": true } } }`.
|
|
799
|
+
*
|
|
800
|
+
* ```
|
|
801
|
+
* use laminapdf_ops::{OpenAt, OpenZoom, SetInitialView, WindowPreferencesPatch};
|
|
802
|
+
* use laminapdf_model::PageMode;
|
|
803
|
+
*
|
|
804
|
+
* let op = SetInitialView::default()
|
|
805
|
+
* .with_open(Some(OpenAt::new("p3.0".parse()?, OpenZoom::FitWidth)))
|
|
806
|
+
* .with_page_mode(Some(PageMode::Outlines))
|
|
807
|
+
* .with_preferences(WindowPreferencesPatch::default().with_display_doc_title(true));
|
|
808
|
+
* assert_eq!(
|
|
809
|
+
* serde_json::to_string(&op)?,
|
|
810
|
+
* r#"{"open":{"page":"p3.0","zoom":"fitWidth"},"pageMode":"outlines","preferences":{"displayDocTitle":true}}"#
|
|
811
|
+
* );
|
|
812
|
+
* # Ok::<(), Box<dyn std::error::Error>>(())
|
|
813
|
+
* ```
|
|
814
|
+
*
|
|
815
|
+
* Added in 0.3.0.
|
|
348
816
|
*/
|
|
349
|
-
export
|
|
817
|
+
export interface SetInitialView {
|
|
818
|
+
/**
|
|
819
|
+
* The page and zoom to open at.
|
|
820
|
+
*/
|
|
821
|
+
open?: OpenAt | null;
|
|
822
|
+
/**
|
|
823
|
+
* The panel to show (`/PageMode`).
|
|
824
|
+
*/
|
|
825
|
+
pageMode?: "none" | "outlines" | "thumbnails" | "fullScreen" | "optionalContent" | "attachments" | null;
|
|
826
|
+
/**
|
|
827
|
+
* How to lay the pages out (`/PageLayout`).
|
|
828
|
+
*/
|
|
829
|
+
pageLayout?: "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight" | null;
|
|
830
|
+
/**
|
|
831
|
+
* The window entries of `/ViewerPreferences`.
|
|
832
|
+
*/
|
|
833
|
+
preferences?: WindowPreferencesPatch;
|
|
834
|
+
}
|
|
350
835
|
|
|
351
836
|
/**
|
|
352
837
|
* Changes to the Info dictionary's text entries. For each field, `None` leaves the entry
|
|
@@ -355,6 +840,8 @@ export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: Ro
|
|
|
355
840
|
*
|
|
356
841
|
* On the wire an absent field is left alone and `null` clears: `{ "title": "Report",
|
|
357
842
|
* "author": null }`.
|
|
843
|
+
*
|
|
844
|
+
* Added in 0.2.0.
|
|
358
845
|
*/
|
|
359
846
|
export interface InfoPatch {
|
|
360
847
|
/**
|
|
@@ -384,116 +871,717 @@ export interface InfoPatch {
|
|
|
384
871
|
}
|
|
385
872
|
|
|
386
873
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
874
|
+
* Changes to the document's metadata. For each field, `None` leaves it alone, `Some(None)`
|
|
875
|
+
* removes it and `Some(Some(value))` sets it, in Info and XMP alike.
|
|
876
|
+
*
|
|
877
|
+
* On the wire an absent field is left alone and `null` removes: `{ "title": "Report",
|
|
878
|
+
* "authors": ["Ada Lovelace", "Charles Babbage"], "keywords": null }`; dates are PDF date
|
|
879
|
+
* strings (`"D:20261110093000+01'00'"`).
|
|
880
|
+
*
|
|
881
|
+
* ```
|
|
882
|
+
* use laminapdf_ops::MetadataPatch;
|
|
883
|
+
*
|
|
884
|
+
* let patch = MetadataPatch::new().title(Some("Quarterly figures")).authors(&["Ada Lovelace", "Charles Babbage"]);
|
|
885
|
+
* assert_eq!(patch.authors, Some(Some(vec!["Ada Lovelace".to_owned(), "Charles Babbage".to_owned()])));
|
|
886
|
+
* assert_eq!(serde_json::to_string(&patch)?, r#"{"title":"Quarterly figures","authors":["Ada Lovelace","Charles Babbage"]}"#);
|
|
887
|
+
* # Ok::<(), serde_json::Error>(())
|
|
888
|
+
* ```
|
|
889
|
+
*
|
|
890
|
+
* Added in 0.2.0.
|
|
891
|
+
*/
|
|
892
|
+
export interface MetadataPatch {
|
|
893
|
+
/**
|
|
894
|
+
* `/Title`, `dc:title`.
|
|
895
|
+
*/
|
|
896
|
+
title?: string | null;
|
|
897
|
+
/**
|
|
898
|
+
* `/Author` (joined with `; `), `dc:creator` (in order). An empty list removes them.
|
|
899
|
+
*/
|
|
900
|
+
authors?: string[] | null;
|
|
901
|
+
/**
|
|
902
|
+
* `/Subject`, `dc:description`.
|
|
903
|
+
*/
|
|
904
|
+
subject?: string | null;
|
|
905
|
+
/**
|
|
906
|
+
* `/Keywords`, `pdf:Keywords`.
|
|
907
|
+
*/
|
|
908
|
+
keywords?: string | null;
|
|
909
|
+
/**
|
|
910
|
+
* `/Creator`, `xmp:CreatorTool`: the application the content came from.
|
|
911
|
+
*/
|
|
912
|
+
creator?: string | null;
|
|
913
|
+
/**
|
|
914
|
+
* `/Producer`, `pdf:Producer`: the application that wrote the PDF.
|
|
915
|
+
*/
|
|
916
|
+
producer?: string | null;
|
|
917
|
+
/**
|
|
918
|
+
* `/CreationDate`, `xmp:CreateDate`.
|
|
919
|
+
*/
|
|
920
|
+
created?: string | null;
|
|
921
|
+
/**
|
|
922
|
+
* `/ModDate`, `xmp:ModifyDate`.
|
|
923
|
+
*/
|
|
924
|
+
modified?: string | null;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Copies `pages` (each once, in the order given) to `at`. A copy shares its source's content
|
|
929
|
+
* streams and resources and shows what it shows, inherited attributes included (ISO 32000-2
|
|
930
|
+
* §7.7.3.4). Its annotations are new objects with a new `/NM`; a form field's widget becomes
|
|
931
|
+
* a new field named `<partial>#<n>` with its own value, and a signature's widget is not copied
|
|
932
|
+
* (both in [`Applied::fields`](crate::Applied::fields)). In a tagged document the copy gets
|
|
933
|
+
* its own `/StructParents` key and clones of the elements whose content lies only on its
|
|
934
|
+
* source; content of elements that span pages is left untagged and the copy is listed in
|
|
935
|
+
* [`Applied::tags_incomplete`](crate::Applied::tags_incomplete). Page labels continue the range
|
|
936
|
+
* each copy lands in.
|
|
937
|
+
*
|
|
938
|
+
* On the wire: `{ "op": "duplicatePages", "args": { "pages": ["p7.0"], "at": { "after": "p7.0" } } }`.
|
|
939
|
+
*
|
|
940
|
+
* Added in 0.3.0.
|
|
941
|
+
*/
|
|
942
|
+
export interface DuplicatePages {
|
|
943
|
+
/**
|
|
944
|
+
* The pages to copy.
|
|
945
|
+
*/
|
|
946
|
+
pages: string[];
|
|
947
|
+
/**
|
|
948
|
+
* Where the copies go.
|
|
949
|
+
*/
|
|
950
|
+
at: "start" | "end" | { before: string } | { after: string };
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Copies pages of a source document into this one at `at`, in the order given (each once).
|
|
955
|
+
* The copies are new objects with new IDs, sharing nothing with the source. Their
|
|
956
|
+
* annotations point at them and get a new `/NM`; a link to a page that didn't come along is
|
|
957
|
+
* removed ([`Applied::links_removed`](crate::Applied::links_removed)), and the named
|
|
958
|
+
* destinations the others use come along, renamed `<name>#<n>` on a clash. Form fields join
|
|
959
|
+
* the form under their own names, or per [`Carry::fields`] when the name is taken
|
|
960
|
+
* ([`Applied::fields`](crate::Applied::fields)); signature fields are left off. The copies
|
|
961
|
+
* lose their tags ([`Applied::tags_dropped`](crate::Applied::tags_dropped)), page labels
|
|
962
|
+
* continue the range each copy lands in, and the document's version rises to the source's
|
|
963
|
+
* when that is newer.
|
|
964
|
+
*
|
|
965
|
+
* On the wire: `{ "op": "insertPagesFrom", "args": { "source": "<64 hex digits>", "pages":
|
|
966
|
+
* ["p3.0"], "at": "end" } }`, with `carry` optional.
|
|
967
|
+
*
|
|
968
|
+
* Added in 0.3.0.
|
|
969
|
+
*/
|
|
970
|
+
export interface InsertPagesFrom {
|
|
971
|
+
/**
|
|
972
|
+
* The source document.
|
|
973
|
+
*/
|
|
974
|
+
source: string;
|
|
975
|
+
/**
|
|
976
|
+
* The source's pages to copy, by their IDs in the source.
|
|
977
|
+
*/
|
|
978
|
+
pages: string[];
|
|
979
|
+
/**
|
|
980
|
+
* Where the copies go.
|
|
981
|
+
*/
|
|
982
|
+
at: "start" | "end" | { before: string } | { after: string };
|
|
983
|
+
/**
|
|
984
|
+
* What comes along with the pages.
|
|
985
|
+
*/
|
|
986
|
+
carry?: Carry;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Deletes `pages` (each once; unknown pages are an error). Outline items, links and `GoTo`
|
|
991
|
+
* actions on surviving pages, named destinations and `/OpenAction` that named a deleted page
|
|
992
|
+
* follow `references` ([`ReferencePolicy`]); structure elements whose content was all on
|
|
993
|
+
* deleted pages are removed with their `/ParentTree` entries, and the widgets on deleted pages
|
|
994
|
+
* leave the form (a field left with none leaves it too). The page objects stay in the file's
|
|
995
|
+
* earlier revisions. Deleting every page is [`Error::NoPagesLeft`].
|
|
996
|
+
*
|
|
997
|
+
* On the wire: `{ "op": "deletePages", "args": { "pages": ["p7.0"], "references": "retarget" } }`.
|
|
998
|
+
*
|
|
999
|
+
* Added in 0.3.0.
|
|
1000
|
+
*/
|
|
1001
|
+
export interface DeletePages {
|
|
1002
|
+
/**
|
|
1003
|
+
* The pages.
|
|
1004
|
+
*/
|
|
1005
|
+
pages: string[];
|
|
1006
|
+
/**
|
|
1007
|
+
* What happens to destinations that name them; `retarget` when left out.
|
|
1008
|
+
*/
|
|
1009
|
+
references?: ReferencePolicy;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Deletes a bookmark, and its children with it or moved up into its place.
|
|
1014
|
+
*
|
|
1015
|
+
* On the wire: `{ "op": "deleteOutlineItem", "args": { "item": "o12.0", "children":
|
|
1016
|
+
* "promote" } }`.
|
|
1017
|
+
*
|
|
1018
|
+
* Added in 0.3.0.
|
|
1019
|
+
*/
|
|
1020
|
+
export interface DeleteOutlineItem {
|
|
1021
|
+
/**
|
|
1022
|
+
* The item.
|
|
1023
|
+
*/
|
|
1024
|
+
item: string;
|
|
1025
|
+
/**
|
|
1026
|
+
* What happens to its children.
|
|
1027
|
+
*/
|
|
1028
|
+
children: ChildItems;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Deletes a named destination, from both stores when both hold it. Its uses in this file are left as they are and reported
|
|
1033
|
+
* ([`Applied::destination_uses`](crate::Applied::destination_uses)): a bookmark or link that
|
|
1034
|
+
* names it no longer goes anywhere.
|
|
1035
|
+
*
|
|
1036
|
+
* On the wire: `{ "op": "deleteNamedDestination", "args": { "name": "draft-notes" } }`.
|
|
1037
|
+
*
|
|
1038
|
+
* Added in 0.3.0.
|
|
1039
|
+
*/
|
|
1040
|
+
export interface DeleteNamedDestination {
|
|
1041
|
+
/**
|
|
1042
|
+
* The name.
|
|
1043
|
+
*/
|
|
1044
|
+
name: string;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Deletes an annotation with what belongs to it: its Popup, every reply whose `/IRT` chain
|
|
1049
|
+
* reaches it, and, for a member of a group (`/RT /Group`, §12.5.6.2), the whole group, which
|
|
1050
|
+
* is one unit. Chains are followed through cycles once. In a tagged document, the structure
|
|
1051
|
+
* element's object reference to each deleted annotation is removed, and so is an element left
|
|
1052
|
+
* with nothing in it. Each deleted object is freed.
|
|
1053
|
+
*
|
|
1054
|
+
* A `Locked` annotation is refused (`annotation-locked`), and so are widgets and direct
|
|
1055
|
+
* dictionaries (`annotation-not-editable`). Deleting a Popup alone removes the `/Popup` entry
|
|
1056
|
+
* that names it.
|
|
1057
|
+
*
|
|
1058
|
+
* On the wire: `{ "op": "deleteAnnot", "args": { "id": "a12.0" } }`.
|
|
1059
|
+
*
|
|
1060
|
+
* Added in 0.3.0.
|
|
1061
|
+
*/
|
|
1062
|
+
export interface DeleteAnnot {
|
|
1063
|
+
/**
|
|
1064
|
+
* The annotation.
|
|
1065
|
+
*/
|
|
1066
|
+
id: string;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Edits the Info dictionary: applies `patch` and, when `at` is given, sets `/ModDate` to it.
|
|
1071
|
+
*
|
|
1072
|
+
* **Deprecated:** use [`SetMetadata`](crate::SetMetadata), which writes authors as a list and
|
|
1073
|
+
* the dates, and edits files whose metadata is in XMP alone. `SetInfo` stays, with its v1 wire
|
|
1074
|
+
* form (`setInfo`) and meaning, so op logs already written still apply (ADR 0006 §6). It now
|
|
1075
|
+
* goes through the same writer, so a document's XMP packet, when it has one, changes with it.
|
|
1076
|
+
* It adds a packet only to a PDF 2.0 file, where the fields other than the dates belong in XMP.
|
|
1077
|
+
* The date is part of the op, never read from a clock, so the same op gives the same bytes
|
|
1078
|
+
* everywhere (ADR 0006 §1).
|
|
390
1079
|
*
|
|
391
1080
|
* An Info dictionary written directly in the trailer, or missing, becomes a new indirect
|
|
392
1081
|
* object that the trailer's `/Info` points to (the first time the op changes something).
|
|
1082
|
+
*
|
|
1083
|
+
* Added in 0.2.0.
|
|
393
1084
|
*/
|
|
394
1085
|
export interface SetInfo {
|
|
395
1086
|
/**
|
|
396
|
-
* The entries to set or clear.
|
|
1087
|
+
* The entries to set or clear.
|
|
1088
|
+
*/
|
|
1089
|
+
patch?: InfoPatch;
|
|
1090
|
+
/**
|
|
1091
|
+
* The modification date to record as `/ModDate`.
|
|
1092
|
+
*/
|
|
1093
|
+
at?: string;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Edits the document's metadata: applies `patch` to the Info dictionary and the XMP packet
|
|
1098
|
+
* together and, when `at` is given, records it as the modification date (`/ModDate`,
|
|
1099
|
+
* `xmp:ModifyDate`) and as `xmp:MetadataDate`, unless the patch sets the modification date
|
|
1100
|
+
* itself. The date is part of the op, never read from a clock (ADR 0006 §1).
|
|
1101
|
+
*
|
|
1102
|
+
* ```
|
|
1103
|
+
* use laminapdf_ops::{MetadataPatch, Op, SetMetadata};
|
|
1104
|
+
*
|
|
1105
|
+
* let op = Op::from(SetMetadata::new(MetadataPatch::new().title(Some("Minutes")), Some("D:20261110093000Z".parse()?)));
|
|
1106
|
+
* assert_eq!(
|
|
1107
|
+
* serde_json::to_string(&op)?,
|
|
1108
|
+
* r#"{"op":"setMetadata","args":{"patch":{"title":"Minutes"},"at":"D:20261110093000Z"}}"#
|
|
1109
|
+
* );
|
|
1110
|
+
* # Ok::<(), Box<dyn std::error::Error>>(())
|
|
1111
|
+
* ```
|
|
1112
|
+
*
|
|
1113
|
+
* Added in 0.2.0.
|
|
1114
|
+
*/
|
|
1115
|
+
export interface SetMetadata {
|
|
1116
|
+
/**
|
|
1117
|
+
* The fields to set or remove.
|
|
1118
|
+
*/
|
|
1119
|
+
patch?: MetadataPatch;
|
|
1120
|
+
/**
|
|
1121
|
+
* The modification date the edit writes.
|
|
1122
|
+
*/
|
|
1123
|
+
at?: string;
|
|
1124
|
+
/**
|
|
1125
|
+
* Replace an XMP packet that can't be read with a new one, losing whatever it held.
|
|
1126
|
+
* Without it, such a packet makes the op fail with `malformed-xmp`, so nothing is lost
|
|
1127
|
+
* without the user saying so.
|
|
1128
|
+
*/
|
|
1129
|
+
replaceMalformed?: boolean;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* How [`RotatePages`] reads its angle.
|
|
1134
|
+
*
|
|
1135
|
+
* Added in 0.3.0.
|
|
1136
|
+
*/
|
|
1137
|
+
export type RotateMode = "set" | "turn";
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* How [`images_to_pdf`] sizes its pages.
|
|
1141
|
+
*/
|
|
1142
|
+
export interface ImagesOptionsInit {
|
|
1143
|
+
/**
|
|
1144
|
+
* Each page this size, `[width, height]` in points, turned the image's way, the image fitted
|
|
1145
|
+
* inside the margins and centred. Without it, each page is its image's size at the image's
|
|
1146
|
+
* resolution.
|
|
1147
|
+
*/
|
|
1148
|
+
fit?: [number, number];
|
|
1149
|
+
/**
|
|
1150
|
+
* The space around each image, in points (0 by default).
|
|
1151
|
+
*/
|
|
1152
|
+
margin?: number;
|
|
1153
|
+
/**
|
|
1154
|
+
* The resolution of an image whose file gives none, in dots per inch (72 by default).
|
|
1155
|
+
*/
|
|
1156
|
+
defaultDpi?: number;
|
|
1157
|
+
/**
|
|
1158
|
+
* The new document's version, file ID, producer, creation date and compression.
|
|
1159
|
+
*/
|
|
1160
|
+
build?: BuildOptionsInit;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* How a destination shows its page (§12.3.2.2).
|
|
1165
|
+
*/
|
|
1166
|
+
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" };
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* How a destination shows its page (§12.3.2.2, Table 149), in the page's user space. A `None`
|
|
1170
|
+
* coordinate keeps the viewer's current one (`null` in the file).
|
|
1171
|
+
*
|
|
1172
|
+
* Every number must be finite: the ops refuse any other with `view-not-finite`.
|
|
1173
|
+
*
|
|
1174
|
+
* Added in 0.3.0.
|
|
1175
|
+
*/
|
|
1176
|
+
export type DestinationView = { kind: "xyz"; left: number | undefined; top: number | undefined; zoom: number | undefined } | { kind: "fit" } | { kind: "fitH"; top: number | undefined } | { kind: "fitV"; left: number | undefined } | { kind: "fitR"; left: number; bottom: number; right: number; top: number } | { kind: "fitB" } | { kind: "fitBH"; top: number | undefined } | { kind: "fitBV"; left: number | undefined };
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* How a document asks to be shown when it opens.
|
|
1180
|
+
*/
|
|
1181
|
+
export interface InitialViewJs {
|
|
1182
|
+
/**
|
|
1183
|
+
* Where it opens.
|
|
1184
|
+
*/
|
|
1185
|
+
open: OpenTargetJs;
|
|
1186
|
+
/**
|
|
1187
|
+
* The panel to show; left out when the file leaves it to the reader.
|
|
1188
|
+
*/
|
|
1189
|
+
pageMode?: "none" | "outlines" | "thumbnails" | "fullScreen" | "optionalContent" | "attachments";
|
|
1190
|
+
/**
|
|
1191
|
+
* How to lay the pages out; left out when the file leaves it to the reader.
|
|
1192
|
+
*/
|
|
1193
|
+
pageLayout?: "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight";
|
|
1194
|
+
/**
|
|
1195
|
+
* The window's viewer preferences.
|
|
1196
|
+
*/
|
|
1197
|
+
preferences: WindowPreferencesJs;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* How a file is encrypted, and what its author permits.
|
|
1202
|
+
*/
|
|
1203
|
+
export interface EncryptionJs {
|
|
1204
|
+
/**
|
|
1205
|
+
* `/V`.
|
|
1206
|
+
*/
|
|
1207
|
+
version: number;
|
|
1208
|
+
/**
|
|
1209
|
+
* `/R`.
|
|
1210
|
+
*/
|
|
1211
|
+
revision: number;
|
|
1212
|
+
/**
|
|
1213
|
+
* The key length in bits.
|
|
1214
|
+
*/
|
|
1215
|
+
keyBits: number;
|
|
1216
|
+
/**
|
|
1217
|
+
* The cipher streams use.
|
|
1218
|
+
*/
|
|
1219
|
+
cipher: CipherJs;
|
|
1220
|
+
/**
|
|
1221
|
+
* What `/P` permits; absent when the handler gives no permissions.
|
|
1222
|
+
*/
|
|
1223
|
+
permissions?: PermissionsJs;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* How a merge brings in what the sources hold besides their pages.
|
|
1228
|
+
*
|
|
1229
|
+
* Added in 0.3.0.
|
|
1230
|
+
*/
|
|
1231
|
+
export interface MergeOptions {
|
|
1232
|
+
/**
|
|
1233
|
+
* What becomes of the sources' bookmarks; `perFile` when left out.
|
|
1234
|
+
*/
|
|
1235
|
+
outline?: OutlineMerge;
|
|
1236
|
+
/**
|
|
1237
|
+
* What happens to a form field whose name is already used; `rename` when left out.
|
|
1238
|
+
*/
|
|
1239
|
+
fields?: FieldClash;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* How a save would go (`laminapdf::PlannedSave`).
|
|
1244
|
+
*/
|
|
1245
|
+
export interface PlannedSaveJs {
|
|
1246
|
+
/**
|
|
1247
|
+
* The mode the save resolves to; absent when it would be refused.
|
|
1248
|
+
*/
|
|
1249
|
+
mode?: SaveModeJs;
|
|
1250
|
+
/**
|
|
1251
|
+
* The code the save would be refused with.
|
|
1252
|
+
*/
|
|
1253
|
+
refusal?: string;
|
|
1254
|
+
/**
|
|
1255
|
+
* `free`, `appendOnly`, `requiresRewrite` or `conflict`.
|
|
1256
|
+
*/
|
|
1257
|
+
constraint: string;
|
|
1258
|
+
/**
|
|
1259
|
+
* Every signature, in the order found.
|
|
1260
|
+
*/
|
|
1261
|
+
signatures: SignatureJs[];
|
|
1262
|
+
/**
|
|
1263
|
+
* The certification's `/P` (1, 2 or 3), when the document is certified.
|
|
1264
|
+
*/
|
|
1265
|
+
docMdp?: number;
|
|
1266
|
+
/**
|
|
1267
|
+
* Why only a full rewrite is safe: `repairedBase`, `encryptedBase`, `noBase`,
|
|
1268
|
+
* `opRequiresRewrite`.
|
|
1269
|
+
*/
|
|
1270
|
+
rewriteReasons: string[];
|
|
1271
|
+
/**
|
|
1272
|
+
* The pending changes a signature's restriction forbids.
|
|
1273
|
+
*/
|
|
1274
|
+
violations: ViolationJs[];
|
|
1275
|
+
/**
|
|
1276
|
+
* The signatures the save would invalidate (only with `invalidateSignatures`).
|
|
1277
|
+
*/
|
|
1278
|
+
wouldInvalidate: SignatureJs[];
|
|
1279
|
+
/**
|
|
1280
|
+
* Whether the save writes an encrypted document as plaintext.
|
|
1281
|
+
*/
|
|
1282
|
+
removesEncryption: boolean;
|
|
1283
|
+
/**
|
|
1284
|
+
* What the save does with the save-time metadata: `none`, `stamp` or `skipped`.
|
|
1285
|
+
*/
|
|
1286
|
+
metadata: string;
|
|
1287
|
+
/**
|
|
1288
|
+
* Whether an edit to save rewrote the XMP packet whole.
|
|
1289
|
+
*/
|
|
1290
|
+
packetRewritten: boolean;
|
|
1291
|
+
/**
|
|
1292
|
+
* The PDF/A and PDF/UA claims the edited metadata breaks (warnings that never block).
|
|
1293
|
+
*/
|
|
1294
|
+
conformanceWarnings: Diagnostic[];
|
|
1295
|
+
/**
|
|
1296
|
+
* The document has no changes.
|
|
1297
|
+
*/
|
|
1298
|
+
unchanged: boolean;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
1303
|
+
*/
|
|
1304
|
+
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 };
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* How a viewer lays pages out.
|
|
1308
|
+
*/
|
|
1309
|
+
export type PageLayoutInit = "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight";
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* How an attached file relates to the document (`/AFRelationship`).
|
|
1313
|
+
*/
|
|
1314
|
+
export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement" | "unspecified";
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* How an undo or redo went (`laminapdf::UndoOutcome`).
|
|
1318
|
+
*/
|
|
1319
|
+
export type UndoOutcomeJs = "applied" | "partial" | "skipped";
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* How the Markdown is cut into chunks.
|
|
1323
|
+
*/
|
|
1324
|
+
export interface ChunkInit {
|
|
1325
|
+
/**
|
|
1326
|
+
* A chunk's budget in approximate tokens (characters / 4); 512 by default.
|
|
1327
|
+
*/
|
|
1328
|
+
maxTokens?: number;
|
|
1329
|
+
/**
|
|
1330
|
+
* Approximate tokens of whole blocks repeated from the chunk before; 0 by default.
|
|
1331
|
+
*/
|
|
1332
|
+
overlap?: number;
|
|
1333
|
+
/**
|
|
1334
|
+
* Where chunks may start; `"headings"` by default.
|
|
1335
|
+
*/
|
|
1336
|
+
splitOn?: SplitOnName;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* How viewers present the document when it opens.
|
|
1341
|
+
*/
|
|
1342
|
+
export interface ViewerPreferencesInit {
|
|
1343
|
+
/**
|
|
1344
|
+
* Show the title, not the file name.
|
|
1345
|
+
*/
|
|
1346
|
+
displayDocTitle?: boolean;
|
|
1347
|
+
/**
|
|
1348
|
+
* The panel shown.
|
|
1349
|
+
*/
|
|
1350
|
+
pageMode?: PageModeInit;
|
|
1351
|
+
/**
|
|
1352
|
+
* The page layout.
|
|
1353
|
+
*/
|
|
1354
|
+
pageLayout?: PageLayoutInit;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Inserts `count` blank pages of `size` at `at`, each showing at `rotate`. Each new page
|
|
1359
|
+
* gets a new object and [`PageId`] (ADR 0005 §5), an empty `/Resources` and no content; in
|
|
1360
|
+
* a labelled document they continue the label range they land in. A count outside 1 to
|
|
1361
|
+
* 10,000, or a side that isn't above 0 and at most 14,400 points, is
|
|
1362
|
+
* [`Error::InvalidOp`](crate::Error::InvalidOp).
|
|
1363
|
+
*
|
|
1364
|
+
* On the wire: `{ "op": "insertBlankPages", "args": { "at": { "after": "p3.0" }, "count": 2,
|
|
1365
|
+
* "size": { "width": 612, "height": 792 }, "rotate": 0 } }`.
|
|
1366
|
+
*
|
|
1367
|
+
* Added in 0.3.0.
|
|
1368
|
+
*/
|
|
1369
|
+
export interface InsertBlankPages {
|
|
1370
|
+
/**
|
|
1371
|
+
* Where the pages go.
|
|
1372
|
+
*/
|
|
1373
|
+
at: "start" | "end" | { before: string } | { after: string };
|
|
1374
|
+
/**
|
|
1375
|
+
* How many pages, at least 1.
|
|
1376
|
+
*/
|
|
1377
|
+
count: number;
|
|
1378
|
+
/**
|
|
1379
|
+
* Their `/MediaBox` size, in points: `{ "width": 612, "height": 792 }`.
|
|
1380
|
+
*/
|
|
1381
|
+
size: { width: number; height: number };
|
|
1382
|
+
/**
|
|
1383
|
+
* Their rotation in degrees clockwise: 0, 90, 180 or 270.
|
|
1384
|
+
*/
|
|
1385
|
+
rotate: 0 | 90 | 180 | 270;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Merges source documents into this one at `at`, one after another, as one edit. Each
|
|
1390
|
+
* source's pages come in as [`InsertPagesFrom`](crate::InsertPagesFrom) brings them (their
|
|
1391
|
+
* annotations, links and the named destinations those use, form fields under the clash rule
|
|
1392
|
+
* of `options.fields`, signature fields left off, tags dropped), and with them what belongs to
|
|
1393
|
+
* the whole source:
|
|
1394
|
+
*
|
|
1395
|
+
* - its bookmarks, per `options.outline`, going to the copies of their pages; a bookmark whose
|
|
1396
|
+
* page didn't come along is left out unless one of its children came
|
|
1397
|
+
* ([`Applied::bookmarks_dropped`](crate::Applied::bookmarks_dropped));
|
|
1398
|
+
* - its layers (optional content groups the copied pages use), added to this document's list
|
|
1399
|
+
* in the source's order and visible or hidden as the source showed them;
|
|
1400
|
+
* - its page labels: each copy keeps the label it had in its source, and this document's
|
|
1401
|
+
* pages keep theirs (a document without labels numbers its pages from 1);
|
|
1402
|
+
* - its form's default appearance and `/NeedAppearances`, and its PDF version when newer.
|
|
1403
|
+
*
|
|
1404
|
+
* Named destinations that clash are renamed `<name>#<n>`
|
|
1405
|
+
* ([`Applied::renamed_destinations`](crate::Applied::renamed_destinations)).
|
|
1406
|
+
*
|
|
1407
|
+
* On the wire: `{ "op": "mergeDocuments", "args": { "sources": [{ "source": "<64 hex
|
|
1408
|
+
* digits>" }], "at": "end" } }`, with each source's `pages` and `title`, and `options`,
|
|
1409
|
+
* optional.
|
|
1410
|
+
*
|
|
1411
|
+
* Added in 0.3.0.
|
|
1412
|
+
*/
|
|
1413
|
+
export interface MergeDocuments {
|
|
1414
|
+
/**
|
|
1415
|
+
* The documents to bring in, in order.
|
|
1416
|
+
*/
|
|
1417
|
+
sources: MergeSource[];
|
|
1418
|
+
/**
|
|
1419
|
+
* Where their pages go.
|
|
1420
|
+
*/
|
|
1421
|
+
at: "start" | "end" | { before: string } | { after: string };
|
|
1422
|
+
/**
|
|
1423
|
+
* What comes along besides the pages.
|
|
1424
|
+
*/
|
|
1425
|
+
options?: MergeOptions;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Moves `pages` to `to`. They keep their order among themselves (the order given, each page
|
|
1430
|
+
* once) and their IDs; an anchor that is itself moved is replaced by the nearest page that
|
|
1431
|
+
* stays.
|
|
1432
|
+
*
|
|
1433
|
+
* On the wire: `{ "op": "movePages", "args": { "pages": ["p7.0", "p8.0"], "to": "start" } }`.
|
|
1434
|
+
*
|
|
1435
|
+
* Added in 0.3.0.
|
|
1436
|
+
*/
|
|
1437
|
+
export interface MovePages {
|
|
1438
|
+
/**
|
|
1439
|
+
* The pages, in the order they take at `to`.
|
|
1440
|
+
*/
|
|
1441
|
+
pages: string[];
|
|
1442
|
+
/**
|
|
1443
|
+
* Where they go.
|
|
1444
|
+
*/
|
|
1445
|
+
to: "start" | "end" | { before: string } | { after: string };
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Moves a bookmark, with its children, under `parent` (`null`: the top level) at `at`. The
|
|
1450
|
+
* item keeps its ID.
|
|
1451
|
+
*
|
|
1452
|
+
* On the wire: `{ "op": "moveOutlineItem", "args": { "item": "o12.0", "parent": "o9.0", "at":
|
|
1453
|
+
* { "after": "o10.0" } } }`.
|
|
1454
|
+
*
|
|
1455
|
+
* Added in 0.3.0.
|
|
1456
|
+
*/
|
|
1457
|
+
export interface MoveOutlineItem {
|
|
1458
|
+
/**
|
|
1459
|
+
* The item.
|
|
1460
|
+
*/
|
|
1461
|
+
item: string;
|
|
1462
|
+
/**
|
|
1463
|
+
* The new parent; `None` for the top level.
|
|
1464
|
+
*/
|
|
1465
|
+
parent?: string | null;
|
|
1466
|
+
/**
|
|
1467
|
+
* Where among the new parent's children.
|
|
1468
|
+
*/
|
|
1469
|
+
at: "first" | "last" | { before: string } | { after: string };
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* Object numbering in a full rewrite.
|
|
1474
|
+
*/
|
|
1475
|
+
export type RenumberJs = "keep" | "compact";
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* One annotation on a page, in page space.
|
|
1479
|
+
*/
|
|
1480
|
+
export interface PageAnnotationJs {
|
|
1481
|
+
/**
|
|
1482
|
+
* Its ID (`a12.0`), as `updateAnnot` and `deleteAnnot` take it.
|
|
1483
|
+
*/
|
|
1484
|
+
id: string;
|
|
1485
|
+
/**
|
|
1486
|
+
* Its position in the page's `/Annots`.
|
|
1487
|
+
*/
|
|
1488
|
+
index: number;
|
|
1489
|
+
/**
|
|
1490
|
+
* Its subtype as written (`Highlight`, `Text`, …).
|
|
1491
|
+
*/
|
|
1492
|
+
subtype: string;
|
|
1493
|
+
/**
|
|
1494
|
+
* Its rectangle: `[x0, y0, x1, y1]`, top-left and bottom-right; left out when it has none.
|
|
1495
|
+
*/
|
|
1496
|
+
rect?: [number, number, number, number];
|
|
1497
|
+
/**
|
|
1498
|
+
* `/Contents` (document text).
|
|
1499
|
+
*/
|
|
1500
|
+
contents?: string;
|
|
1501
|
+
/**
|
|
1502
|
+
* `/NM` (document text), only a hint.
|
|
1503
|
+
*/
|
|
1504
|
+
name?: string;
|
|
1505
|
+
/**
|
|
1506
|
+
* `/T`, the author.
|
|
1507
|
+
*/
|
|
1508
|
+
author?: string;
|
|
1509
|
+
/**
|
|
1510
|
+
* `/Subj`.
|
|
1511
|
+
*/
|
|
1512
|
+
subject?: string;
|
|
1513
|
+
/**
|
|
1514
|
+
* `/CreationDate` as stored.
|
|
397
1515
|
*/
|
|
398
|
-
|
|
1516
|
+
created?: string;
|
|
399
1517
|
/**
|
|
400
|
-
*
|
|
1518
|
+
* `/M` as stored.
|
|
401
1519
|
*/
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* How a destination shows its page (§12.3.2.2).
|
|
407
|
-
*/
|
|
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" };
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* How a file is encrypted, and what its author permits.
|
|
412
|
-
*/
|
|
413
|
-
export interface EncryptionJs {
|
|
1520
|
+
modified?: string;
|
|
414
1521
|
/**
|
|
415
|
-
* `/
|
|
1522
|
+
* `/F`, the flags.
|
|
416
1523
|
*/
|
|
417
|
-
|
|
1524
|
+
flags: number;
|
|
418
1525
|
/**
|
|
419
|
-
* `/
|
|
1526
|
+
* `/C`: no components (transparent), one (gray), three (RGB) or four (CMYK).
|
|
420
1527
|
*/
|
|
421
|
-
|
|
1528
|
+
color: number[];
|
|
422
1529
|
/**
|
|
423
|
-
*
|
|
1530
|
+
* `/CA`, the opacity.
|
|
424
1531
|
*/
|
|
425
|
-
|
|
1532
|
+
opacity?: number;
|
|
426
1533
|
/**
|
|
427
|
-
* The
|
|
1534
|
+
* The ID of the annotation this one replies to or is grouped with.
|
|
428
1535
|
*/
|
|
429
|
-
|
|
1536
|
+
inReplyTo?: string;
|
|
430
1537
|
/**
|
|
431
|
-
*
|
|
1538
|
+
* Whether `inReplyTo` is a group rather than a reply.
|
|
432
1539
|
*/
|
|
433
|
-
|
|
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
|
-
|
|
441
|
-
/**
|
|
442
|
-
* How a viewer lays pages out.
|
|
443
|
-
*/
|
|
444
|
-
export type PageLayoutInit = "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight";
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* How an attached file relates to the document (`/AFRelationship`).
|
|
448
|
-
*/
|
|
449
|
-
export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement" | "unspecified";
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* How an undo or redo went (`laminapdf::UndoOutcome`).
|
|
453
|
-
*/
|
|
454
|
-
export type UndoOutcomeJs = "applied" | "partial" | "skipped";
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* How the Markdown is cut into chunks.
|
|
458
|
-
*/
|
|
459
|
-
export interface ChunkInit {
|
|
1540
|
+
grouped: boolean;
|
|
460
1541
|
/**
|
|
461
|
-
*
|
|
1542
|
+
* The ID of its Popup.
|
|
462
1543
|
*/
|
|
463
|
-
|
|
1544
|
+
popup?: string;
|
|
464
1545
|
/**
|
|
465
|
-
*
|
|
1546
|
+
* For a Popup, the ID of the annotation it belongs to.
|
|
466
1547
|
*/
|
|
467
|
-
|
|
1548
|
+
parent?: string;
|
|
468
1549
|
/**
|
|
469
|
-
*
|
|
1550
|
+
* Whether it has a normal appearance stream.
|
|
470
1551
|
*/
|
|
471
|
-
|
|
1552
|
+
hasAppearance: boolean;
|
|
1553
|
+
/**
|
|
1554
|
+
* Whether it has rich-text contents.
|
|
1555
|
+
*/
|
|
1556
|
+
hasRichText: boolean;
|
|
1557
|
+
/**
|
|
1558
|
+
* The subtype's own geometry, as flat `[x, y, …]` lists in page space.
|
|
1559
|
+
*/
|
|
1560
|
+
geometry: GeometryJs;
|
|
472
1561
|
}
|
|
473
1562
|
|
|
474
1563
|
/**
|
|
475
|
-
*
|
|
1564
|
+
* One document a merge brings in.
|
|
1565
|
+
*
|
|
1566
|
+
* Added in 0.3.0.
|
|
476
1567
|
*/
|
|
477
|
-
export interface
|
|
1568
|
+
export interface MergeSource {
|
|
478
1569
|
/**
|
|
479
|
-
*
|
|
1570
|
+
* The source document, added with [`Document::add_source`](crate::Document::add_source).
|
|
480
1571
|
*/
|
|
481
|
-
|
|
1572
|
+
source: string;
|
|
482
1573
|
/**
|
|
483
|
-
* The
|
|
1574
|
+
* The source's pages to bring in, by their IDs in the source, in order; all of them when
|
|
1575
|
+
* left out.
|
|
484
1576
|
*/
|
|
485
|
-
|
|
1577
|
+
pages?: string[];
|
|
486
1578
|
/**
|
|
487
|
-
* The
|
|
1579
|
+
* The name of the bookmark [`OutlineMerge::PerFile`] gives the source's bookmarks (a file
|
|
1580
|
+
* name, say); the source's own title when left out.
|
|
488
1581
|
*/
|
|
489
|
-
|
|
1582
|
+
title?: string;
|
|
490
1583
|
}
|
|
491
1584
|
|
|
492
|
-
/**
|
|
493
|
-
* Object numbering in a full rewrite.
|
|
494
|
-
*/
|
|
495
|
-
export type RenumberJs = "keep" | "compact";
|
|
496
|
-
|
|
497
1585
|
/**
|
|
498
1586
|
* One element of the structure tree (`laminapdf::StructureNode`; its strings are document text).
|
|
499
1587
|
*/
|
|
@@ -520,6 +1608,14 @@ export interface StructureNodeJs {
|
|
|
520
1608
|
kids: StructureKidJs[];
|
|
521
1609
|
}
|
|
522
1610
|
|
|
1611
|
+
/**
|
|
1612
|
+
* One entry of a language alternative, under the name TypeScript gives it.
|
|
1613
|
+
*/
|
|
1614
|
+
export interface XmpLangText {
|
|
1615
|
+
lang: string;
|
|
1616
|
+
text: string;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
523
1619
|
/**
|
|
524
1620
|
* One font the document uses.
|
|
525
1621
|
*/
|
|
@@ -546,6 +1642,20 @@ export interface FontJs {
|
|
|
546
1642
|
encoding?: EncodingJs;
|
|
547
1643
|
}
|
|
548
1644
|
|
|
1645
|
+
/**
|
|
1646
|
+
* One named destination and where it goes.
|
|
1647
|
+
*/
|
|
1648
|
+
export interface NamedDestinationJs {
|
|
1649
|
+
/**
|
|
1650
|
+
* The name.
|
|
1651
|
+
*/
|
|
1652
|
+
name: string;
|
|
1653
|
+
/**
|
|
1654
|
+
* Where it goes, when it names a page of this document.
|
|
1655
|
+
*/
|
|
1656
|
+
target?: TargetJs;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
549
1659
|
/**
|
|
550
1660
|
* One outline item and its children.
|
|
551
1661
|
*/
|
|
@@ -584,6 +1694,10 @@ export interface OutlineEntryInit {
|
|
|
584
1694
|
* One outline item.
|
|
585
1695
|
*/
|
|
586
1696
|
export interface OutlineNodeJs {
|
|
1697
|
+
/**
|
|
1698
|
+
* Its ID (`o12.0`), which the outline ops take.
|
|
1699
|
+
*/
|
|
1700
|
+
id: string;
|
|
587
1701
|
/**
|
|
588
1702
|
* Its title (document text).
|
|
589
1703
|
*/
|
|
@@ -596,6 +1710,30 @@ export interface OutlineNodeJs {
|
|
|
596
1710
|
* Where it goes, when its destination names a page of this document.
|
|
597
1711
|
*/
|
|
598
1712
|
target?: TargetJs;
|
|
1713
|
+
/**
|
|
1714
|
+
* The named destination it goes to, when it names one.
|
|
1715
|
+
*/
|
|
1716
|
+
destinationName?: string;
|
|
1717
|
+
/**
|
|
1718
|
+
* The web address it opens, when it has one.
|
|
1719
|
+
*/
|
|
1720
|
+
uri?: string;
|
|
1721
|
+
/**
|
|
1722
|
+
* Its action's type when that is neither `GoTo` nor `URI` (`JavaScript`, `Launch`, …).
|
|
1723
|
+
*/
|
|
1724
|
+
otherAction?: string;
|
|
1725
|
+
/**
|
|
1726
|
+
* Its colour as `"#rrggbb"`, when it isn't the default black.
|
|
1727
|
+
*/
|
|
1728
|
+
color?: string;
|
|
1729
|
+
/**
|
|
1730
|
+
* Shown in bold.
|
|
1731
|
+
*/
|
|
1732
|
+
bold: boolean;
|
|
1733
|
+
/**
|
|
1734
|
+
* Shown in italic.
|
|
1735
|
+
*/
|
|
1736
|
+
italic: boolean;
|
|
599
1737
|
/**
|
|
600
1738
|
* Its children, in order.
|
|
601
1739
|
*/
|
|
@@ -654,6 +1792,73 @@ export interface PageLabelInit {
|
|
|
654
1792
|
first?: number;
|
|
655
1793
|
}
|
|
656
1794
|
|
|
1795
|
+
/**
|
|
1796
|
+
* One part of an article thread.
|
|
1797
|
+
*/
|
|
1798
|
+
export interface ThreadPartJs {
|
|
1799
|
+
/**
|
|
1800
|
+
* The page's 0-based index; left out when the part names a page the document lacks.
|
|
1801
|
+
*/
|
|
1802
|
+
page?: number;
|
|
1803
|
+
/**
|
|
1804
|
+
* Its rectangle, `[x0, y0, x1, y1]` in page space; left out when unreadable.
|
|
1805
|
+
*/
|
|
1806
|
+
rect?: [number, number, number, number];
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* One range of [`SetPageLabels`]: the labels from `page` up to the next range's page.
|
|
1811
|
+
*
|
|
1812
|
+
* Added in 0.3.0.
|
|
1813
|
+
*/
|
|
1814
|
+
export interface PageLabelRange {
|
|
1815
|
+
/**
|
|
1816
|
+
* The range's first page.
|
|
1817
|
+
*/
|
|
1818
|
+
page: string;
|
|
1819
|
+
/**
|
|
1820
|
+
* The numbering style; without one, each label is the prefix alone. On the wire:
|
|
1821
|
+
* `decimal`, `upperRoman`, `lowerRoman`, `upperLetters` or `lowerLetters`.
|
|
1822
|
+
*/
|
|
1823
|
+
style?: "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
|
|
1824
|
+
/**
|
|
1825
|
+
* Text before each number (`A-` in `A-1`).
|
|
1826
|
+
*/
|
|
1827
|
+
prefix?: string;
|
|
1828
|
+
/**
|
|
1829
|
+
* The number of the range's first page, 1 or more (a `u32`, as the builder's page labels
|
|
1830
|
+
* take).
|
|
1831
|
+
*/
|
|
1832
|
+
first?: number;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
/**
|
|
1836
|
+
* One reference to a deleted page and what the deletion did to it.
|
|
1837
|
+
*/
|
|
1838
|
+
export interface ReferenceEditJs {
|
|
1839
|
+
/**
|
|
1840
|
+
* The deleted page it named.
|
|
1841
|
+
*/
|
|
1842
|
+
page: string;
|
|
1843
|
+
/**
|
|
1844
|
+
* `outlineItem`, `link`, `namedDestination`, `openAction`, `structureElement`,
|
|
1845
|
+
* `structureKid` or `widget`.
|
|
1846
|
+
*/
|
|
1847
|
+
kind: "outlineItem" | "link" | "namedDestination" | "openAction" | "structureElement" | "structureKid" | "widget";
|
|
1848
|
+
/**
|
|
1849
|
+
* The named destination's name, for a `namedDestination`.
|
|
1850
|
+
*/
|
|
1851
|
+
name?: string;
|
|
1852
|
+
/**
|
|
1853
|
+
* `retargeted` or `removed`.
|
|
1854
|
+
*/
|
|
1855
|
+
outcome: "retargeted" | "removed";
|
|
1856
|
+
/**
|
|
1857
|
+
* The surviving page it now names, when retargeted.
|
|
1858
|
+
*/
|
|
1859
|
+
to?: string;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
657
1862
|
/**
|
|
658
1863
|
* One text run (`laminapdf::extract::PageTextRun`): glyphs of one font, size, direction and marked
|
|
659
1864
|
* content on one baseline, in logical order.
|
|
@@ -821,17 +2026,237 @@ export interface SaveOptionsInit {
|
|
|
821
2026
|
*/
|
|
822
2027
|
removeEncryption?: boolean;
|
|
823
2028
|
/**
|
|
824
|
-
* What an incremental save returns.
|
|
2029
|
+
* What an incremental save returns.
|
|
2030
|
+
*/
|
|
2031
|
+
output?: OutputJs;
|
|
2032
|
+
/**
|
|
2033
|
+
* Numbering in a full rewrite.
|
|
2034
|
+
*/
|
|
2035
|
+
renumber?: RenumberJs;
|
|
2036
|
+
/**
|
|
2037
|
+
* The cross-reference form.
|
|
2038
|
+
*/
|
|
2039
|
+
xref?: XrefJs;
|
|
2040
|
+
/**
|
|
2041
|
+
* When the save happens, as the app's clock reads it: a PDF date (`D:20261110093000Z`)
|
|
2042
|
+
* or an ISO 8601 date-time. A save that writes changes stamps it as the modification and
|
|
2043
|
+
* metadata dates and gives the XMP packet a new instance ID.
|
|
2044
|
+
*/
|
|
2045
|
+
metadataDate?: string;
|
|
2046
|
+
/**
|
|
2047
|
+
* The XMP instance ID the save writes, a UUID (`uuid:` optional); without it, one is
|
|
2048
|
+
* derived from the content.
|
|
2049
|
+
*/
|
|
2050
|
+
instanceId?: string;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* Removes an XMP property, every copy of it in the packet; a property the Info dictionary
|
|
2055
|
+
* mirrors is removed from both. The value stays in the file's earlier revisions until a full
|
|
2056
|
+
* rewrite ([`Applied::still_in_earlier_revisions`](crate::Applied::still_in_earlier_revisions)).
|
|
2057
|
+
*
|
|
2058
|
+
* ```
|
|
2059
|
+
* use laminapdf_ops::{Op, RemoveXmpProperty};
|
|
2060
|
+
*
|
|
2061
|
+
* let op = Op::from(RemoveXmpProperty::new("http://example.com/ns/", "batch"));
|
|
2062
|
+
* assert_eq!(
|
|
2063
|
+
* serde_json::to_string(&op)?,
|
|
2064
|
+
* r#"{"op":"removeXmpProperty","args":{"namespace":"http://example.com/ns/","name":"batch"}}"#
|
|
2065
|
+
* );
|
|
2066
|
+
* # Ok::<(), serde_json::Error>(())
|
|
2067
|
+
* ```
|
|
2068
|
+
*
|
|
2069
|
+
* Added in 0.3.0.
|
|
2070
|
+
*/
|
|
2071
|
+
export interface RemoveXmpProperty {
|
|
2072
|
+
/**
|
|
2073
|
+
* The property's namespace URI.
|
|
2074
|
+
*/
|
|
2075
|
+
namespace: string;
|
|
2076
|
+
/**
|
|
2077
|
+
* The property's local name.
|
|
2078
|
+
*/
|
|
2079
|
+
name: string;
|
|
2080
|
+
/**
|
|
2081
|
+
* As [`SetMetadata::replace_malformed`](crate::SetMetadata::replace_malformed).
|
|
2082
|
+
*/
|
|
2083
|
+
replaceMalformed?: boolean;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* Removes metadata fields from the Info dictionary and the XMP packet; the packet's other
|
|
2088
|
+
* properties stay (J.10).
|
|
2089
|
+
*
|
|
2090
|
+
* The values stay in the file's earlier revisions until a full rewrite: an incremental save
|
|
2091
|
+
* appends the change and keeps the original bytes. When it removed anything, the op's result
|
|
2092
|
+
* says so ([`Applied::still_in_earlier_revisions`](crate::Applied::still_in_earlier_revisions)),
|
|
2093
|
+
* so the caller can offer a full rewrite (on a signed file, the override that removes the
|
|
2094
|
+
* signatures).
|
|
2095
|
+
*
|
|
2096
|
+
* ```
|
|
2097
|
+
* use laminapdf_ops::{MetadataKey, Op, RemoveMetadata};
|
|
2098
|
+
*
|
|
2099
|
+
* let op = Op::from(RemoveMetadata::new(vec![MetadataKey::Authors, MetadataKey::Creator]));
|
|
2100
|
+
* assert_eq!(serde_json::to_string(&op)?, r#"{"op":"removeMetadata","args":{"keys":["authors","creator"]}}"#);
|
|
2101
|
+
* # Ok::<(), serde_json::Error>(())
|
|
2102
|
+
* ```
|
|
2103
|
+
*
|
|
2104
|
+
* Added in 0.2.0.
|
|
2105
|
+
*/
|
|
2106
|
+
export interface RemoveMetadata {
|
|
2107
|
+
/**
|
|
2108
|
+
* The fields to remove.
|
|
2109
|
+
*/
|
|
2110
|
+
keys: MetadataKey[];
|
|
2111
|
+
/**
|
|
2112
|
+
* As [`SetMetadata::replace_malformed`].
|
|
2113
|
+
*/
|
|
2114
|
+
replaceMalformed?: boolean;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* Renames a named destination, keeping it where it is. With `links: follow` (the default) the
|
|
2119
|
+
* bookmarks, links and `GoTo` actions of this file that name it are renamed too, in the form
|
|
2120
|
+
* they named it in.
|
|
2121
|
+
*
|
|
2122
|
+
* On the wire: `{ "op": "renameNamedDestination", "args": { "from": "sec2", "to": "methods" } }`.
|
|
2123
|
+
*
|
|
2124
|
+
* Added in 0.3.0.
|
|
2125
|
+
*/
|
|
2126
|
+
export interface RenameNamedDestination {
|
|
2127
|
+
/**
|
|
2128
|
+
* The current name.
|
|
2129
|
+
*/
|
|
2130
|
+
from: string;
|
|
2131
|
+
/**
|
|
2132
|
+
* The new name; no destination may have it yet.
|
|
2133
|
+
*/
|
|
2134
|
+
to: string;
|
|
2135
|
+
/**
|
|
2136
|
+
* Whether the uses follow.
|
|
2137
|
+
*/
|
|
2138
|
+
links?: RenameLinks;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* Replaces pages of this document with pages of a source document, pair by pair: the first
|
|
2143
|
+
* source page takes the first target's place, and so on. What pointed at a replaced page
|
|
2144
|
+
* (outline items, links, named destinations, `GoTo` actions, `/OpenAction`) now points at
|
|
2145
|
+
* the page that took its place, with the view `/Fit`, since coordinates on the old page mean
|
|
2146
|
+
* nothing on the new one. Targets left over are deleted (their references retargeted to the
|
|
2147
|
+
* nearest surviving page); source pages left over go after the last copy. The copies come
|
|
2148
|
+
* in as with [`InsertPagesFrom`]; the replaced pages are deleted as with
|
|
2149
|
+
* [`DeletePages`](crate::DeletePages), structure, widgets and earlier revisions included.
|
|
2150
|
+
*
|
|
2151
|
+
* On the wire: `{ "op": "replacePages", "args": { "targets": ["p7.0"], "source": "<64 hex
|
|
2152
|
+
* digits>", "pages": ["p3.0"] } }`, with `carry` optional.
|
|
2153
|
+
*
|
|
2154
|
+
* Added in 0.3.0.
|
|
2155
|
+
*/
|
|
2156
|
+
export interface ReplacePages {
|
|
2157
|
+
/**
|
|
2158
|
+
* The pages to replace, in order.
|
|
2159
|
+
*/
|
|
2160
|
+
targets: string[];
|
|
2161
|
+
/**
|
|
2162
|
+
* The source document.
|
|
2163
|
+
*/
|
|
2164
|
+
source: string;
|
|
2165
|
+
/**
|
|
2166
|
+
* The source's pages that take their places, by their IDs in the source.
|
|
2167
|
+
*/
|
|
2168
|
+
pages: string[];
|
|
2169
|
+
/**
|
|
2170
|
+
* What comes along with the pages.
|
|
2171
|
+
*/
|
|
2172
|
+
carry?: Carry;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* Replaces the document's page labels with `ranges`; an empty list removes them, so viewers
|
|
2177
|
+
* show page numbers again.
|
|
2178
|
+
*
|
|
2179
|
+
* Each range starts at a page, named by its ID, and labels that page and the ones after it up
|
|
2180
|
+
* to the next range. The ranges must be in page order, two never on one page, the first on
|
|
2181
|
+
* the document's first page (the number tree must have an entry for page 0, §12.4.2), and
|
|
2182
|
+
* each numbered from 1 or more; otherwise the op fails with `invalid-label-ranges`. Nothing
|
|
2183
|
+
* is written when the catalog already holds exactly these labels
|
|
2184
|
+
* ([`PageLabels::is_written`]); any other tree, a damaged one included, is replaced.
|
|
2185
|
+
*
|
|
2186
|
+
* On the wire:
|
|
2187
|
+
* `{ "op": "setPageLabels", "args": { "ranges": [{ "page": "p3.0", "style": "lowerRoman" }] } }`.
|
|
2188
|
+
*
|
|
2189
|
+
* Added in 0.3.0.
|
|
2190
|
+
*/
|
|
2191
|
+
export interface SetPageLabels {
|
|
2192
|
+
/**
|
|
2193
|
+
* The ranges, in page order.
|
|
2194
|
+
*/
|
|
2195
|
+
ranges: PageLabelRange[];
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
/**
|
|
2199
|
+
* Replaces the whole XMP packet with `xml`, for what the property ops can't write
|
|
2200
|
+
* (structures, qualifiers, comments). The packet is parsed before it applies and refused if it
|
|
2201
|
+
* doesn't parse (`invalid-xmp-packet`) or changes the PDF/A or PDF/UA identification
|
|
2202
|
+
* (`xmp-claim-read-only`). Info's mirrored entries follow the new packet; in a file that
|
|
2203
|
+
* claims PDF/A, the extension schema entries its properties lack are added and reported
|
|
2204
|
+
* ([`Applied::declared`](crate::Applied::declared)). The old packet stays in the file's
|
|
2205
|
+
* earlier revisions until a full rewrite.
|
|
2206
|
+
*
|
|
2207
|
+
* ```
|
|
2208
|
+
* use laminapdf_ops::{Op, ReplaceXmpPacket};
|
|
2209
|
+
*
|
|
2210
|
+
* let op = Op::from(ReplaceXmpPacket::new("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">…</x:xmpmeta>"));
|
|
2211
|
+
* assert!(serde_json::to_string(&op)?.starts_with(r#"{"op":"replaceXmpPacket","args":{"xml":"<x:xmpmeta"#));
|
|
2212
|
+
* # Ok::<(), serde_json::Error>(())
|
|
2213
|
+
* ```
|
|
2214
|
+
*
|
|
2215
|
+
* Added in 0.3.0.
|
|
2216
|
+
*/
|
|
2217
|
+
export interface ReplaceXmpPacket {
|
|
2218
|
+
/**
|
|
2219
|
+
* The new packet's XML, with or without its `<?xpacket … ?>` wrapper.
|
|
2220
|
+
*/
|
|
2221
|
+
xml: string;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* Reverses the order of `pages` within the places they hold: the first of them (in page
|
|
2226
|
+
* order) takes the last one's place, and so on; the other pages don't move.
|
|
2227
|
+
*
|
|
2228
|
+
* On the wire: `{ "op": "reversePages", "args": { "pages": ["p3.0", "p4.0", "p5.0"] } }`.
|
|
2229
|
+
*
|
|
2230
|
+
* Added in 0.3.0.
|
|
2231
|
+
*/
|
|
2232
|
+
export interface ReversePages {
|
|
2233
|
+
/**
|
|
2234
|
+
* The pages; their order here doesn't matter.
|
|
2235
|
+
*/
|
|
2236
|
+
pages: string[];
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
/**
|
|
2240
|
+
* Rotates `pages` by `angle`, set or turned ([`RotateMode`]); each page as
|
|
2241
|
+
* [`RotatePage`] does, keeping its object and [`PageId`].
|
|
2242
|
+
*
|
|
2243
|
+
* On the wire: `{ "op": "rotatePages", "args": { "pages": ["p3.0"], "angle": 90, "mode": "turn" } }`.
|
|
2244
|
+
*
|
|
2245
|
+
* Added in 0.3.0.
|
|
2246
|
+
*/
|
|
2247
|
+
export interface RotatePages {
|
|
2248
|
+
/**
|
|
2249
|
+
* The pages.
|
|
825
2250
|
*/
|
|
826
|
-
|
|
2251
|
+
pages: string[];
|
|
827
2252
|
/**
|
|
828
|
-
*
|
|
2253
|
+
* The angle in degrees clockwise: 0, 90, 180 or 270.
|
|
829
2254
|
*/
|
|
830
|
-
|
|
2255
|
+
angle: 0 | 90 | 180 | 270;
|
|
831
2256
|
/**
|
|
832
|
-
*
|
|
2257
|
+
* Whether the angle is set or added; `set` when left out.
|
|
833
2258
|
*/
|
|
834
|
-
|
|
2259
|
+
mode?: RotateMode;
|
|
835
2260
|
}
|
|
836
2261
|
|
|
837
2262
|
/**
|
|
@@ -846,6 +2271,8 @@ export interface SaveOptionsInit {
|
|
|
846
2271
|
* On the wire: `{ "op": "rotatePage", "args": { "page": "p12.0", "rotate": 90 } }`.
|
|
847
2272
|
*
|
|
848
2273
|
* [ADR 0005]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0005-document-model.md
|
|
2274
|
+
*
|
|
2275
|
+
* Added in 0.2.0.
|
|
849
2276
|
*/
|
|
850
2277
|
export interface RotatePage {
|
|
851
2278
|
/**
|
|
@@ -858,6 +2285,60 @@ export interface RotatePage {
|
|
|
858
2285
|
rotate: 0 | 90 | 180 | 270;
|
|
859
2286
|
}
|
|
860
2287
|
|
|
2288
|
+
/**
|
|
2289
|
+
* Sets any XMP property: text, a URI, a number, a boolean, a date, a language alternative,
|
|
2290
|
+
* or an ordered or unordered array of simple values. A file without a packet gets one.
|
|
2291
|
+
*
|
|
2292
|
+
* `prefix` names the namespace when the packet binds no prefix to it. A property the Info
|
|
2293
|
+
* dictionary mirrors (`dc:title`, `pdf:Producer`, …) is set in both, as
|
|
2294
|
+
* [`SetMetadata`](crate::SetMetadata) sets it, and must have its shape: text, or a language
|
|
2295
|
+
* alternative of the `x-default` entry alone, for `dc:title` and `dc:description`; an array of
|
|
2296
|
+
* text for `dc:creator`; a date for the dates.
|
|
2297
|
+
*
|
|
2298
|
+
* ```
|
|
2299
|
+
* use laminapdf_ops::{Op, SetXmpProperty};
|
|
2300
|
+
* use laminapdf_model::xmp::XmpValue;
|
|
2301
|
+
*
|
|
2302
|
+
* let op = Op::from(SetXmpProperty::new("http://example.com/ns/", "acme", "batch", XmpValue::Integer(42)));
|
|
2303
|
+
* assert_eq!(
|
|
2304
|
+
* serde_json::to_string(&op)?,
|
|
2305
|
+
* r#"{"op":"setXmpProperty","args":{"namespace":"http://example.com/ns/","prefix":"acme","name":"batch","value":{"type":"integer","value":42}}}"#
|
|
2306
|
+
* );
|
|
2307
|
+
* # Ok::<(), serde_json::Error>(())
|
|
2308
|
+
* ```
|
|
2309
|
+
*
|
|
2310
|
+
* Added in 0.3.0.
|
|
2311
|
+
*/
|
|
2312
|
+
export interface SetXmpProperty {
|
|
2313
|
+
/**
|
|
2314
|
+
* The property's namespace URI.
|
|
2315
|
+
*/
|
|
2316
|
+
namespace: string;
|
|
2317
|
+
/**
|
|
2318
|
+
* The prefix to write the namespace with when the packet binds none.
|
|
2319
|
+
*/
|
|
2320
|
+
prefix: string;
|
|
2321
|
+
/**
|
|
2322
|
+
* The property's local name.
|
|
2323
|
+
*/
|
|
2324
|
+
name: string;
|
|
2325
|
+
/**
|
|
2326
|
+
* The new value.
|
|
2327
|
+
*/
|
|
2328
|
+
value: XmpValue;
|
|
2329
|
+
/**
|
|
2330
|
+
* As [`SetMetadata::replace_malformed`](crate::SetMetadata::replace_malformed).
|
|
2331
|
+
*/
|
|
2332
|
+
replaceMalformed?: boolean;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
/**
|
|
2336
|
+
* Something in the file that names a destination.
|
|
2337
|
+
*
|
|
2338
|
+
* Added in 0.3.0.
|
|
2339
|
+
*/
|
|
2340
|
+
export type DestinationUse = { kind: "outlineItem"; item: string } | { kind: "annotation"; page: string; annot: string } | { kind: "catalog" };
|
|
2341
|
+
|
|
861
2342
|
/**
|
|
862
2343
|
* The Info dictionary's text entries; absent ones are left out (document text).
|
|
863
2344
|
*/
|
|
@@ -941,11 +2422,31 @@ export interface MetadataInit {
|
|
|
941
2422
|
modDate?: string;
|
|
942
2423
|
}
|
|
943
2424
|
|
|
2425
|
+
/**
|
|
2426
|
+
* The document's XMP packet as text (`laminapdf::XmpText`).
|
|
2427
|
+
*/
|
|
2428
|
+
export interface XmpTextJs {
|
|
2429
|
+
/**
|
|
2430
|
+
* Whether there is a packet, and whether it was read.
|
|
2431
|
+
*/
|
|
2432
|
+
status: PacketStatus;
|
|
2433
|
+
/**
|
|
2434
|
+
* The packet's XML, with the edits made so far.
|
|
2435
|
+
*/
|
|
2436
|
+
xml?: string;
|
|
2437
|
+
/**
|
|
2438
|
+
* The PDF/A part and conformance the packet claims, e.g. `"2B"`.
|
|
2439
|
+
*/
|
|
2440
|
+
pdfa?: string;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
944
2443
|
/**
|
|
945
2444
|
* The kind of change an op makes. The save planner checks it against `DocMDP` / `FieldMDP`
|
|
946
2445
|
* permissions and the document's `SaveConstraint` ([ADR 0007]).
|
|
947
2446
|
*
|
|
948
2447
|
* [ADR 0007]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0007-save-planner.md
|
|
2448
|
+
*
|
|
2449
|
+
* Added in 0.2.0.
|
|
949
2450
|
*/
|
|
950
2451
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
951
2452
|
|
|
@@ -971,6 +2472,22 @@ export interface ModelsInit {
|
|
|
971
2472
|
langs?: string[];
|
|
972
2473
|
}
|
|
973
2474
|
|
|
2475
|
+
/**
|
|
2476
|
+
* The page and zoom a document opens at.
|
|
2477
|
+
*
|
|
2478
|
+
* Added in 0.3.0.
|
|
2479
|
+
*/
|
|
2480
|
+
export interface OpenAt {
|
|
2481
|
+
/**
|
|
2482
|
+
* The page.
|
|
2483
|
+
*/
|
|
2484
|
+
page: string;
|
|
2485
|
+
/**
|
|
2486
|
+
* The zoom.
|
|
2487
|
+
*/
|
|
2488
|
+
zoom?: "default" | "fitPage" | "fitWidth" | number;
|
|
2489
|
+
}
|
|
2490
|
+
|
|
974
2491
|
/**
|
|
975
2492
|
* The pages an edit touched.
|
|
976
2493
|
*/
|
|
@@ -979,11 +2496,80 @@ export interface EditedJs {
|
|
|
979
2496
|
* IDs of the pages whose content or attributes changed.
|
|
980
2497
|
*/
|
|
981
2498
|
touchedPages: string[];
|
|
2499
|
+
/**
|
|
2500
|
+
* A metadata edit rewrote the XMP packet whole (UTF-16, or marked read-only).
|
|
2501
|
+
*/
|
|
2502
|
+
packetRewritten: boolean;
|
|
2503
|
+
/**
|
|
2504
|
+
* A metadata edit removed values the file's earlier revisions still hold, which only a
|
|
2505
|
+
* full rewrite drops.
|
|
2506
|
+
*/
|
|
2507
|
+
stillInEarlierRevisions: boolean;
|
|
2508
|
+
/**
|
|
2509
|
+
* IDs of annotations an annotation op deleted besides the one it names (Popups, replies,
|
|
2510
|
+
* the rest of a group); left out when there are none.
|
|
2511
|
+
*/
|
|
2512
|
+
alsoDeleted?: string[];
|
|
982
2513
|
/**
|
|
983
2514
|
* Whether the edit changed the document: one that only set values they already had leaves
|
|
984
2515
|
* no step to undo.
|
|
985
2516
|
*/
|
|
986
2517
|
changed: boolean;
|
|
2518
|
+
/**
|
|
2519
|
+
* The IDs of the bookmarks the edit added, in order.
|
|
2520
|
+
*/
|
|
2521
|
+
createdOutlineItems: string[];
|
|
2522
|
+
/**
|
|
2523
|
+
* An outline edit found the outline's links broken and rewrote them whole; bookmarks
|
|
2524
|
+
* stored inside others have new IDs.
|
|
2525
|
+
*/
|
|
2526
|
+
outlineRepaired: boolean;
|
|
2527
|
+
/**
|
|
2528
|
+
* What still names a named destination the edit deleted.
|
|
2529
|
+
*/
|
|
2530
|
+
destinationUses: DestinationUse[];
|
|
2531
|
+
/**
|
|
2532
|
+
* The XMP properties the edit declared in a PDF/A file's extension schemas.
|
|
2533
|
+
*/
|
|
2534
|
+
declared: ExtensionPropertyJs[];
|
|
2535
|
+
/**
|
|
2536
|
+
* The page IDs in order after the edit, when it changed the page list.
|
|
2537
|
+
*/
|
|
2538
|
+
pageOrder?: string[];
|
|
2539
|
+
/**
|
|
2540
|
+
* What a page deletion did to the references to the deleted pages.
|
|
2541
|
+
*/
|
|
2542
|
+
references: ReferenceEditJs[];
|
|
2543
|
+
/**
|
|
2544
|
+
* What a page duplication did to the form fields whose widgets the copied pages show;
|
|
2545
|
+
* left out when there are none.
|
|
2546
|
+
*/
|
|
2547
|
+
fields?: FieldEditJs[];
|
|
2548
|
+
/**
|
|
2549
|
+
* The copies a page duplication made whose tags couldn't all be cloned; left out when
|
|
2550
|
+
* there are none.
|
|
2551
|
+
*/
|
|
2552
|
+
tagsIncomplete?: string[];
|
|
2553
|
+
/**
|
|
2554
|
+
* The page holding each link a page copied in from another document lost, one entry per
|
|
2555
|
+
* link; left out when there are none.
|
|
2556
|
+
*/
|
|
2557
|
+
linksRemoved?: string[];
|
|
2558
|
+
/**
|
|
2559
|
+
* The pages copied in from another document without the tags their source gave them; left
|
|
2560
|
+
* out when there are none.
|
|
2561
|
+
*/
|
|
2562
|
+
tagsDropped?: string[];
|
|
2563
|
+
/**
|
|
2564
|
+
* The named destinations a merge or a page import brought in under another name, because
|
|
2565
|
+
* the document already used theirs; left out when there are none.
|
|
2566
|
+
*/
|
|
2567
|
+
renamedDestinations?: RenamedDestinationJs[];
|
|
2568
|
+
/**
|
|
2569
|
+
* The bookmarks a merge left out because the pages they went to didn't come along; left
|
|
2570
|
+
* out when there are none.
|
|
2571
|
+
*/
|
|
2572
|
+
bookmarksDropped?: number;
|
|
987
2573
|
}
|
|
988
2574
|
|
|
989
2575
|
/**
|
|
@@ -996,6 +2582,55 @@ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "
|
|
|
996
2582
|
*/
|
|
997
2583
|
export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
998
2584
|
|
|
2585
|
+
/**
|
|
2586
|
+
* The wire form, under the name TypeScript gives it.
|
|
2587
|
+
*/
|
|
2588
|
+
export type XmpValue = { type: "text"; value: string } | { type: "uri"; value: string } | { type: "integer"; value: number } | { type: "real"; value: number } | { type: "boolean"; value: boolean } | { type: "date"; value: string } | { type: "langAlt"; value: XmpLangText[] } | { type: "seq"; value: XmpValue[] } | { type: "bag"; value: XmpValue[] };
|
|
2589
|
+
|
|
2590
|
+
/**
|
|
2591
|
+
* The yes-or-no window entries of the viewer preferences.
|
|
2592
|
+
*/
|
|
2593
|
+
export interface WindowPreferencesJs {
|
|
2594
|
+
/**
|
|
2595
|
+
* Hide the reader's toolbars.
|
|
2596
|
+
*/
|
|
2597
|
+
hideToolbar: boolean;
|
|
2598
|
+
/**
|
|
2599
|
+
* Hide the reader's menu bar.
|
|
2600
|
+
*/
|
|
2601
|
+
hideMenubar: boolean;
|
|
2602
|
+
/**
|
|
2603
|
+
* Hide the scroll bars and navigation controls.
|
|
2604
|
+
*/
|
|
2605
|
+
hideWindowUi: boolean;
|
|
2606
|
+
/**
|
|
2607
|
+
* Resize the window to fit the first page.
|
|
2608
|
+
*/
|
|
2609
|
+
fitWindow: boolean;
|
|
2610
|
+
/**
|
|
2611
|
+
* Put the window in the middle of the screen.
|
|
2612
|
+
*/
|
|
2613
|
+
centerWindow: boolean;
|
|
2614
|
+
/**
|
|
2615
|
+
* Show the document's title in the title bar.
|
|
2616
|
+
*/
|
|
2617
|
+
displayDocTitle: boolean;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* What [`DeleteOutlineItem`](super::DeleteOutlineItem) does with the item's children.
|
|
2622
|
+
*
|
|
2623
|
+
* Added in 0.3.0.
|
|
2624
|
+
*/
|
|
2625
|
+
export type ChildItems = "delete" | "promote";
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* What [`DeletePages`] does with a destination that names a deleted page.
|
|
2629
|
+
*
|
|
2630
|
+
* Added in 0.3.0.
|
|
2631
|
+
*/
|
|
2632
|
+
export type ReferencePolicy = "retarget" | "remove";
|
|
2633
|
+
|
|
999
2634
|
/**
|
|
1000
2635
|
* What `WasmDocument.extract` returns.
|
|
1001
2636
|
*/
|
|
@@ -1062,6 +2697,33 @@ export interface PermissionsJs {
|
|
|
1062
2697
|
assemble: boolean;
|
|
1063
2698
|
}
|
|
1064
2699
|
|
|
2700
|
+
/**
|
|
2701
|
+
* What a page duplication or a page copied in did to one form field.
|
|
2702
|
+
*/
|
|
2703
|
+
export interface FieldEditJs {
|
|
2704
|
+
/**
|
|
2705
|
+
* The field on the source page (in the source document, for a page copied in).
|
|
2706
|
+
*/
|
|
2707
|
+
field: string;
|
|
2708
|
+
/**
|
|
2709
|
+
* The copy whose widget it concerns.
|
|
2710
|
+
*/
|
|
2711
|
+
page: string;
|
|
2712
|
+
/**
|
|
2713
|
+
* `renamed` (the copy's widget belongs to a new field), `linked` (it joined the field of
|
|
2714
|
+
* the same name) or `notCopied` (a signature's widget).
|
|
2715
|
+
*/
|
|
2716
|
+
outcome: "renamed" | "linked" | "notCopied";
|
|
2717
|
+
/**
|
|
2718
|
+
* The new field's ID, when renamed; the field it joined, when linked.
|
|
2719
|
+
*/
|
|
2720
|
+
to?: string;
|
|
2721
|
+
/**
|
|
2722
|
+
* The new field's fully qualified name, when renamed.
|
|
2723
|
+
*/
|
|
2724
|
+
name?: string;
|
|
2725
|
+
}
|
|
2726
|
+
|
|
1065
2727
|
/**
|
|
1066
2728
|
* What a save wrote (`laminapdf::SaveReport`).
|
|
1067
2729
|
*/
|
|
@@ -1090,6 +2752,24 @@ export interface SaveReportJs {
|
|
|
1090
2752
|
* Whether encryption was removed.
|
|
1091
2753
|
*/
|
|
1092
2754
|
encryptionRemoved: boolean;
|
|
2755
|
+
/**
|
|
2756
|
+
* Whether the save stamped the save-time metadata (`metadataDate`, `instanceId`).
|
|
2757
|
+
*/
|
|
2758
|
+
metadataUpdated: boolean;
|
|
2759
|
+
/**
|
|
2760
|
+
* Whether the options asked for the stamp and the save left it out, because it would have
|
|
2761
|
+
* broken a signature's restriction the saved changes keep.
|
|
2762
|
+
*/
|
|
2763
|
+
metadataNotUpdated: boolean;
|
|
2764
|
+
/**
|
|
2765
|
+
* Whether an edit saved here rewrote the XMP packet whole.
|
|
2766
|
+
*/
|
|
2767
|
+
packetRewritten: boolean;
|
|
2768
|
+
/**
|
|
2769
|
+
* Whether the save emptied the undo history (a full rewrite, or an incremental save that
|
|
2770
|
+
* freed objects); for a copy, whether adopting it would.
|
|
2771
|
+
*/
|
|
2772
|
+
historyCleared: boolean;
|
|
1093
2773
|
}
|
|
1094
2774
|
|
|
1095
2775
|
/**
|
|
@@ -1111,11 +2791,44 @@ export interface RevertedJs {
|
|
|
1111
2791
|
touchedPages: string[];
|
|
1112
2792
|
}
|
|
1113
2793
|
|
|
2794
|
+
/**
|
|
2795
|
+
* What becomes of the sources' outlines (bookmarks) in a merge.
|
|
2796
|
+
*
|
|
2797
|
+
* Added in 0.3.0.
|
|
2798
|
+
*/
|
|
2799
|
+
export type OutlineMerge = "perFile" | "keep" | "none";
|
|
2800
|
+
|
|
2801
|
+
/**
|
|
2802
|
+
* What comes along with pages copied from another document.
|
|
2803
|
+
*
|
|
2804
|
+
* Added in 0.3.0.
|
|
2805
|
+
*/
|
|
2806
|
+
export interface Carry {
|
|
2807
|
+
/**
|
|
2808
|
+
* Whether the pages' annotations other than form fields come along (links, comments,
|
|
2809
|
+
* markup); `true` when left out.
|
|
2810
|
+
*/
|
|
2811
|
+
annotations?: boolean;
|
|
2812
|
+
/**
|
|
2813
|
+
* What happens to a form field whose name the target already uses; `rename` when left
|
|
2814
|
+
* out.
|
|
2815
|
+
*/
|
|
2816
|
+
fields?: FieldClash;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
1114
2819
|
/**
|
|
1115
2820
|
* What following a link does, by `kind`.
|
|
1116
2821
|
*/
|
|
1117
2822
|
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 };
|
|
1118
2823
|
|
|
2824
|
+
/**
|
|
2825
|
+
* What happens to a copied form field whose fully qualified name the target already uses
|
|
2826
|
+
* (E2 plan §11).
|
|
2827
|
+
*
|
|
2828
|
+
* Added in 0.3.0.
|
|
2829
|
+
*/
|
|
2830
|
+
export type FieldClash = "rename" | "link";
|
|
2831
|
+
|
|
1119
2832
|
/**
|
|
1120
2833
|
* What happens to hidden text and page furniture.
|
|
1121
2834
|
*/
|
|
@@ -1131,6 +2844,25 @@ export interface DropInit {
|
|
|
1131
2844
|
furniture?: boolean;
|
|
1132
2845
|
}
|
|
1133
2846
|
|
|
2847
|
+
/**
|
|
2848
|
+
* What the document's `/Metadata` holds.
|
|
2849
|
+
*
|
|
2850
|
+
* Added in 0.2.0.
|
|
2851
|
+
*/
|
|
2852
|
+
export type PacketStatus = "absent" | "parsed" | "malformed";
|
|
2853
|
+
|
|
2854
|
+
/**
|
|
2855
|
+
* Where a bookmark goes.
|
|
2856
|
+
*
|
|
2857
|
+
* Added in 0.3.0.
|
|
2858
|
+
*/
|
|
2859
|
+
export type OutlineTarget = { destination: ExplicitDestination } | { named: string } | { uri: string };
|
|
2860
|
+
|
|
2861
|
+
/**
|
|
2862
|
+
* Where a document opens, by `kind`.
|
|
2863
|
+
*/
|
|
2864
|
+
export type OpenTargetJs = { kind: "default" } | { kind: "page"; target: TargetJs } | { kind: "action"; action: string };
|
|
2865
|
+
|
|
1134
2866
|
/**
|
|
1135
2867
|
* Where a link or outline item goes.
|
|
1136
2868
|
*/
|
|
@@ -1146,6 +2878,21 @@ export type SplitOnName = "headings" | "blocks" | "pages";
|
|
|
1146
2878
|
*/
|
|
1147
2879
|
export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
|
|
1148
2880
|
|
|
2881
|
+
/**
|
|
2882
|
+
* Whether [`RenameNamedDestination`](super::RenameNamedDestination) renames the uses of the
|
|
2883
|
+
* name in this file too.
|
|
2884
|
+
*
|
|
2885
|
+
* Added in 0.3.0.
|
|
2886
|
+
*/
|
|
2887
|
+
export type RenameLinks = "keep" | "follow";
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* Which side [`DocumentMetadata`]'s values come from.
|
|
2891
|
+
*
|
|
2892
|
+
* Added in 0.2.0.
|
|
2893
|
+
*/
|
|
2894
|
+
export type MetadataSource = "info" | "xmp";
|
|
2895
|
+
|
|
1149
2896
|
/**
|
|
1150
2897
|
* Which table detectors run.
|
|
1151
2898
|
*/
|
|
@@ -1305,6 +3052,24 @@ export class WasmDocument {
|
|
|
1305
3052
|
private constructor();
|
|
1306
3053
|
free(): void;
|
|
1307
3054
|
[Symbol.dispose](): void;
|
|
3055
|
+
/**
|
|
3056
|
+
* Adds another PDF as a source document: `{ id, pages }`, its ID (64 hex digits, the
|
|
3057
|
+
* SHA-256 of `bytes`) and its page IDs in order. An encrypted one opens with `password`,
|
|
3058
|
+
* which no op ever holds.
|
|
3059
|
+
*
|
|
3060
|
+
* # Errors
|
|
3061
|
+
* `wrong-password`, `password-required`, and the errors of a file that doesn't open.
|
|
3062
|
+
*/
|
|
3063
|
+
addSource(bytes: Uint8Array, password?: string | null): { id: string; pages: string[] };
|
|
3064
|
+
/**
|
|
3065
|
+
* Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
|
|
3066
|
+
* them), once they are written where the document lives; `historyCleared` is the copy's
|
|
3067
|
+
* report's.
|
|
3068
|
+
*
|
|
3069
|
+
* # Errors
|
|
3070
|
+
* `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
|
|
3071
|
+
*/
|
|
3072
|
+
adoptCopy(bytes: Uint8Array, historyCleared: boolean): void;
|
|
1308
3073
|
/**
|
|
1309
3074
|
* Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
|
|
1310
3075
|
*
|
|
@@ -1320,6 +3085,14 @@ export class WasmDocument {
|
|
|
1320
3085
|
* error (nothing is applied).
|
|
1321
3086
|
*/
|
|
1322
3087
|
apply(ops: Op[]): EditedJs;
|
|
3088
|
+
/**
|
|
3089
|
+
* `view` (page space) on page `page` as the destination the outline and named-destination
|
|
3090
|
+
* ops take, in the page's user space (the extract and text modules).
|
|
3091
|
+
*
|
|
3092
|
+
* # Errors
|
|
3093
|
+
* `invalid-argument` for a view that isn't one; `page-index-out-of-range`; reading errors.
|
|
3094
|
+
*/
|
|
3095
|
+
destinationAt(page: number, view: TargetViewJs): ExplicitDestination;
|
|
1323
3096
|
/**
|
|
1324
3097
|
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
1325
3098
|
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
@@ -1330,6 +3103,14 @@ export class WasmDocument {
|
|
|
1330
3103
|
* As `extract`, for the options and the pages asked for.
|
|
1331
3104
|
*/
|
|
1332
3105
|
extractJob(options: ExtractInit): WasmExtractJob;
|
|
3106
|
+
/**
|
|
3107
|
+
* A new document of `pages` of this one, in the order given.
|
|
3108
|
+
*
|
|
3109
|
+
* # Errors
|
|
3110
|
+
* `invalid-argument` for a value that isn't a list of page IDs, `unknown-page`; reading
|
|
3111
|
+
* errors.
|
|
3112
|
+
*/
|
|
3113
|
+
extractPages(pages: string[]): WasmDocument;
|
|
1333
3114
|
/**
|
|
1334
3115
|
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
1335
3116
|
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
@@ -1350,6 +3131,13 @@ export class WasmDocument {
|
|
|
1350
3131
|
* Reading errors.
|
|
1351
3132
|
*/
|
|
1352
3133
|
info(): DocumentInfoJs;
|
|
3134
|
+
/**
|
|
3135
|
+
* How the document asks to be shown when it opens (the extract and text modules).
|
|
3136
|
+
*
|
|
3137
|
+
* # Errors
|
|
3138
|
+
* `data-pending` and the reading errors.
|
|
3139
|
+
*/
|
|
3140
|
+
initialView(): InitialViewJs;
|
|
1353
3141
|
/**
|
|
1354
3142
|
* Whether the file is encrypted (it opened with its password, or the empty one).
|
|
1355
3143
|
*/
|
|
@@ -1361,6 +3149,24 @@ export class WasmDocument {
|
|
|
1361
3149
|
* Reading errors.
|
|
1362
3150
|
*/
|
|
1363
3151
|
isTagged(): boolean;
|
|
3152
|
+
/**
|
|
3153
|
+
* A new document of `inputs` (each `{ bytes, password?, title? }`) one after another,
|
|
3154
|
+
* with their bookmarks, named destinations, form fields, layers and page labels; `options`
|
|
3155
|
+
* as `mergeDocuments`' (`outline`, `fields`).
|
|
3156
|
+
*
|
|
3157
|
+
* # Errors
|
|
3158
|
+
* `invalid-argument` / `unknown-option` for bad values, `wrong-password`,
|
|
3159
|
+
* `password-required`, and the errors of a file that doesn't open.
|
|
3160
|
+
*/
|
|
3161
|
+
static merge(inputs: { bytes: Uint8Array; password?: string; title?: string }[], options: MergeOptions | undefined): WasmDocument;
|
|
3162
|
+
/**
|
|
3163
|
+
* The document's metadata, read from Info and XMP together, with the fields where they
|
|
3164
|
+
* disagree.
|
|
3165
|
+
*
|
|
3166
|
+
* # Errors
|
|
3167
|
+
* Reading errors.
|
|
3168
|
+
*/
|
|
3169
|
+
metadata(): DocumentMetadata;
|
|
1364
3170
|
/**
|
|
1365
3171
|
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1366
3172
|
* it names no page here (the extract and text modules).
|
|
@@ -1369,6 +3175,13 @@ export class WasmDocument {
|
|
|
1369
3175
|
* `data-pending` and the reading errors.
|
|
1370
3176
|
*/
|
|
1371
3177
|
namedDestination(name: string): TargetJs | undefined;
|
|
3178
|
+
/**
|
|
3179
|
+
* Every named destination, sorted by name (the extract and text modules).
|
|
3180
|
+
*
|
|
3181
|
+
* # Errors
|
|
3182
|
+
* `data-pending` and the reading errors.
|
|
3183
|
+
*/
|
|
3184
|
+
namedDestinations(): NamedDestinationJs[];
|
|
1372
3185
|
/**
|
|
1373
3186
|
* Opens a document from its bytes.
|
|
1374
3187
|
*
|
|
@@ -1394,6 +3207,14 @@ export class WasmDocument {
|
|
|
1394
3207
|
* `data-pending` and the reading errors.
|
|
1395
3208
|
*/
|
|
1396
3209
|
outline(): OutlineNodeJs[];
|
|
3210
|
+
/**
|
|
3211
|
+
* The annotations on page `index`, in the order of its `/Annots`, every subtype included
|
|
3212
|
+
* (the extract and text modules).
|
|
3213
|
+
*
|
|
3214
|
+
* # Errors
|
|
3215
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
3216
|
+
*/
|
|
3217
|
+
pageAnnotations(index: number): PageAnnotationJs[];
|
|
1397
3218
|
/**
|
|
1398
3219
|
* A handle on the page with `id` (`p12.0`).
|
|
1399
3220
|
*
|
|
@@ -1436,6 +3257,13 @@ export class WasmDocument {
|
|
|
1436
3257
|
* `page-index-out-of-range`; reading errors.
|
|
1437
3258
|
*/
|
|
1438
3259
|
page(index: number): WasmPage;
|
|
3260
|
+
/**
|
|
3261
|
+
* How a save with `options` would go, without saving.
|
|
3262
|
+
*
|
|
3263
|
+
* # Errors
|
|
3264
|
+
* `invalid-argument` / `unknown-option` for bad options; reading errors.
|
|
3265
|
+
*/
|
|
3266
|
+
plan(options: SaveOptionsInit | undefined): PlannedSaveJs;
|
|
1439
3267
|
/**
|
|
1440
3268
|
* The document's properties (the extract and text modules). Reads every object once.
|
|
1441
3269
|
*
|
|
@@ -1467,6 +3295,14 @@ export class WasmDocument {
|
|
|
1467
3295
|
* `data-pending` and the reading errors.
|
|
1468
3296
|
*/
|
|
1469
3297
|
reflow(): string;
|
|
3298
|
+
/**
|
|
3299
|
+
* Writes what `save` would and leaves the document as it was: not rebased, its changes
|
|
3300
|
+
* still unsaved, the save-time stamp in the copy only (Save a copy).
|
|
3301
|
+
*
|
|
3302
|
+
* # Errors
|
|
3303
|
+
* As `save`; the document is unchanged either way.
|
|
3304
|
+
*/
|
|
3305
|
+
saveCopy(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1470
3306
|
/**
|
|
1471
3307
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
1472
3308
|
*
|
|
@@ -1481,6 +3317,17 @@ export class WasmDocument {
|
|
|
1481
3317
|
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
1482
3318
|
*/
|
|
1483
3319
|
save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
3320
|
+
/**
|
|
3321
|
+
* This document cut into new ones: `{ count: n }` parts of `n` pages, `{ ranges: [[id, …],
|
|
3322
|
+
* …] }` one part per list of page IDs, or `{ bookmarks: level }` a part from each bookmark
|
|
3323
|
+
* at that depth (1: the top level). Each part carries what its pages reach and the
|
|
3324
|
+
* bookmarks that go to them.
|
|
3325
|
+
*
|
|
3326
|
+
* # Errors
|
|
3327
|
+
* `invalid-argument` / `unknown-option` for a value that isn't one of those, `unknown-page`,
|
|
3328
|
+
* `no-pages-left` for an empty list; reading errors.
|
|
3329
|
+
*/
|
|
3330
|
+
split(by: { readonly count: number } | { readonly ranges: readonly (readonly string[])[] } | { readonly bookmarks: number }): WasmDocument[];
|
|
1484
3331
|
/**
|
|
1485
3332
|
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
1486
3333
|
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
@@ -1489,6 +3336,13 @@ export class WasmDocument {
|
|
|
1489
3336
|
* Reading errors.
|
|
1490
3337
|
*/
|
|
1491
3338
|
structureTree(): StructureNodeJs[] | undefined;
|
|
3339
|
+
/**
|
|
3340
|
+
* The document's article threads; empty without any (the extract and text modules).
|
|
3341
|
+
*
|
|
3342
|
+
* # Errors
|
|
3343
|
+
* `data-pending` and the reading errors.
|
|
3344
|
+
*/
|
|
3345
|
+
threads(): ThreadJs[];
|
|
1492
3346
|
/**
|
|
1493
3347
|
* Undoes the newest transaction: how it went and the pages it touched; `undefined` when
|
|
1494
3348
|
* there is nothing to undo.
|
|
@@ -1501,6 +3355,20 @@ export class WasmDocument {
|
|
|
1501
3355
|
* A cursor over the warnings so far (build warnings first), each as the §1 object.
|
|
1502
3356
|
*/
|
|
1503
3357
|
warnings(): WasmWarningCursor;
|
|
3358
|
+
/**
|
|
3359
|
+
* The signature restrictions `op` would break if it were applied and saved.
|
|
3360
|
+
*
|
|
3361
|
+
* # Errors
|
|
3362
|
+
* `invalid-argument` for a value that isn't an op; reading errors.
|
|
3363
|
+
*/
|
|
3364
|
+
wouldViolate(op: Op): ViolationJs[];
|
|
3365
|
+
/**
|
|
3366
|
+
* The document's XMP packet as text, with the edits made so far.
|
|
3367
|
+
*
|
|
3368
|
+
* # Errors
|
|
3369
|
+
* Reading errors.
|
|
3370
|
+
*/
|
|
3371
|
+
xmpPacket(): XmpTextJs;
|
|
1504
3372
|
}
|
|
1505
3373
|
|
|
1506
3374
|
/**
|
|
@@ -1573,6 +3441,23 @@ export class WasmImage {
|
|
|
1573
3441
|
readonly width: number;
|
|
1574
3442
|
}
|
|
1575
3443
|
|
|
3444
|
+
/**
|
|
3445
|
+
* The images of [`images_to_pdf`], in page order. Images are JavaScript-owned objects, which a
|
|
3446
|
+
* record can't carry, so they are added one by one.
|
|
3447
|
+
*/
|
|
3448
|
+
export class WasmImageList {
|
|
3449
|
+
free(): void;
|
|
3450
|
+
[Symbol.dispose](): void;
|
|
3451
|
+
/**
|
|
3452
|
+
* An empty list.
|
|
3453
|
+
*/
|
|
3454
|
+
constructor();
|
|
3455
|
+
/**
|
|
3456
|
+
* Adds `image` as the next page. The image stays usable: the list holds its own copy.
|
|
3457
|
+
*/
|
|
3458
|
+
push(image: WasmImage): void;
|
|
3459
|
+
}
|
|
3460
|
+
|
|
1576
3461
|
/**
|
|
1577
3462
|
* A page of a [`WasmDocument`], held by its ID (F2): moving pages doesn't retarget it.
|
|
1578
3463
|
*/
|
|
@@ -1879,6 +3764,16 @@ export function allocationFailed(): boolean;
|
|
|
1879
3764
|
*/
|
|
1880
3765
|
export function hasText(): boolean;
|
|
1881
3766
|
|
|
3767
|
+
/**
|
|
3768
|
+
* A new document with one page per image of `images`, in order: a JPEG embedded as it is, a PNG
|
|
3769
|
+
* with its transparency, each drawn the way up its EXIF orientation says.
|
|
3770
|
+
*
|
|
3771
|
+
* # Errors
|
|
3772
|
+
* `invalid-geometry` for no images, a negative margin or resolution, or a page too small for its
|
|
3773
|
+
* margins; `unknown-option`, `invalid-argument` for bad options.
|
|
3774
|
+
*/
|
|
3775
|
+
export function imagesToPdf(images: WasmImageList, options: ImagesOptionsInit | undefined): WasmDocument;
|
|
3776
|
+
|
|
1882
3777
|
/**
|
|
1883
3778
|
* The crate version (`@laminapdf/wasm`'s).
|
|
1884
3779
|
*/
|
|
@@ -1892,6 +3787,7 @@ export interface InitOutput {
|
|
|
1892
3787
|
readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
|
|
1893
3788
|
readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
|
|
1894
3789
|
readonly __wbg_wasmimage_free: (a: number, b: number) => void;
|
|
3790
|
+
readonly __wbg_wasmimagelist_free: (a: number, b: number) => void;
|
|
1895
3791
|
readonly __wbg_wasmpage_free: (a: number, b: number) => void;
|
|
1896
3792
|
readonly __wbg_wasmpagebuilder_free: (a: number, b: number) => void;
|
|
1897
3793
|
readonly __wbg_wasmsavejob_free: (a: number, b: number) => void;
|
|
@@ -1899,6 +3795,7 @@ export interface InitOutput {
|
|
|
1899
3795
|
readonly __wbg_wasmwarningcursor_free: (a: number, b: number) => void;
|
|
1900
3796
|
readonly allocationFailed: () => number;
|
|
1901
3797
|
readonly hasText: () => number;
|
|
3798
|
+
readonly imagesToPdf: (a: number, b: any) => [number, number, number];
|
|
1902
3799
|
readonly version: () => [number, number];
|
|
1903
3800
|
readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
|
|
1904
3801
|
readonly wasmbuilder_destination: (a: number, b: number, c: number, d: number, e: any) => [number, number];
|
|
@@ -1910,33 +3807,48 @@ export interface InitOutput {
|
|
|
1910
3807
|
readonly wasmbuilder_page: (a: number, b: number, c: number) => number;
|
|
1911
3808
|
readonly wasmbuilder_pageLabels: (a: number, b: any) => [number, number];
|
|
1912
3809
|
readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
|
|
3810
|
+
readonly wasmdocument_addSource: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
3811
|
+
readonly wasmdocument_adoptCopy: (a: number, b: number, c: number, d: number) => [number, number];
|
|
1913
3812
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1914
3813
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
3814
|
+
readonly wasmdocument_destinationAt: (a: number, b: number, c: any) => [number, number, number];
|
|
1915
3815
|
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
1916
3816
|
readonly wasmdocument_extractJob: (a: number, b: any) => [number, number, number];
|
|
3817
|
+
readonly wasmdocument_extractPages: (a: number, b: any) => [number, number, number];
|
|
1917
3818
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1918
3819
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
3820
|
+
readonly wasmdocument_initialView: (a: number) => [number, number, number];
|
|
1919
3821
|
readonly wasmdocument_isEncrypted: (a: number) => number;
|
|
1920
3822
|
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
3823
|
+
readonly wasmdocument_merge: (a: any, b: any) => [number, number, number];
|
|
3824
|
+
readonly wasmdocument_metadata: (a: number) => [number, number, number];
|
|
1921
3825
|
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
3826
|
+
readonly wasmdocument_namedDestinations: (a: number) => [number, number, number];
|
|
1922
3827
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1923
3828
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
1924
3829
|
readonly wasmdocument_outline: (a: number) => [number, number, number];
|
|
1925
3830
|
readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
|
|
3831
|
+
readonly wasmdocument_pageAnnotations: (a: number, b: number) => [number, number, number];
|
|
1926
3832
|
readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
|
|
1927
3833
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
1928
3834
|
readonly wasmdocument_pageInfo: (a: number, b: number) => [number, number, number];
|
|
1929
3835
|
readonly wasmdocument_pageInfos: (a: number) => [number, number, number];
|
|
1930
3836
|
readonly wasmdocument_pageLinks: (a: number, b: number) => [number, number, number];
|
|
3837
|
+
readonly wasmdocument_plan: (a: number, b: any) => [number, number, number];
|
|
1931
3838
|
readonly wasmdocument_properties: (a: number) => [number, number, number];
|
|
1932
3839
|
readonly wasmdocument_rebase: (a: number, b: number, c: number) => [number, number];
|
|
1933
3840
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1934
3841
|
readonly wasmdocument_reflow: (a: number) => [number, number, number, number];
|
|
1935
3842
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
3843
|
+
readonly wasmdocument_saveCopy: (a: number, b: any) => [number, number, number];
|
|
1936
3844
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
3845
|
+
readonly wasmdocument_split: (a: number, b: any) => [number, number, number];
|
|
1937
3846
|
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
3847
|
+
readonly wasmdocument_threads: (a: number) => [number, number, number];
|
|
1938
3848
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1939
3849
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
3850
|
+
readonly wasmdocument_wouldViolate: (a: number, b: any) => [number, number, number];
|
|
3851
|
+
readonly wasmdocument_xmpPacket: (a: number) => [number, number, number];
|
|
1940
3852
|
readonly wasmextractjob_cancel: (a: number) => void;
|
|
1941
3853
|
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
1942
3854
|
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|
|
@@ -1945,6 +3857,8 @@ export interface InitOutput {
|
|
|
1945
3857
|
readonly wasmimage_png: (a: number, b: number) => [number, number, number];
|
|
1946
3858
|
readonly wasmimage_rgba: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
1947
3859
|
readonly wasmimage_width: (a: number) => number;
|
|
3860
|
+
readonly wasmimagelist_new: () => number;
|
|
3861
|
+
readonly wasmimagelist_push: (a: number, b: number) => void;
|
|
1948
3862
|
readonly wasmpage_id: (a: number) => [number, number];
|
|
1949
3863
|
readonly wasmpage_index: (a: number) => [number, number, number];
|
|
1950
3864
|
readonly wasmpage_info: (a: number) => [number, number, number];
|
|
@@ -1985,8 +3899,8 @@ export interface InitOutput {
|
|
|
1985
3899
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
1986
3900
|
readonly __externref_table_alloc: () => number;
|
|
1987
3901
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
1988
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
1989
3902
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
3903
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
1990
3904
|
readonly __wbindgen_start: () => void;
|
|
1991
3905
|
}
|
|
1992
3906
|
|