@laminapdf/wasm 0.2.0 → 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.
@@ -14,6 +14,27 @@ export interface Diagnostic {
14
14
  }
15
15
 
16
16
 
17
+ /**
18
+ * A bookmark's look: its colour (`/C`; `None` is the viewer's default, black) and type style
19
+ * (`/F`: bit 1 italic, bit 2 bold).
20
+ *
21
+ * Added in 0.3.0.
22
+ */
23
+ export interface OutlineStyle {
24
+ /**
25
+ * The colour.
26
+ */
27
+ color?: string | null;
28
+ /**
29
+ * Bold.
30
+ */
31
+ bold?: boolean;
32
+ /**
33
+ * Italic.
34
+ */
35
+ italic?: boolean;
36
+ }
37
+
17
38
  /**
18
39
  * A change a signature's restriction forbids.
19
40
  */
@@ -41,12 +62,20 @@ export interface ViolationJs {
41
62
  field?: string;
42
63
  }
43
64
 
65
+ /**
66
+ * A colour of 8 bits a channel, `"#rrggbb"` on the wire. A bookmark's `/C` (§12.3.3,
67
+ * Table 151) holds it as three numbers from 0 to 1.
68
+ *
69
+ * Added in 0.3.0.
70
+ */
71
+ export type Rgb = string;
72
+
44
73
  /**
45
74
  * A conformance claim the document's metadata no longer meets.
46
75
  *
47
76
  * Added in 0.2.0.
48
77
  */
49
- export type ConformanceWarning = { code: "pdfa-one-author"; authors: number } | { code: "pdfua-title-missing" } | { code: "pdfa-info-mismatch"; keys: MetadataKey[] };
78
+ 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" };
50
79
 
51
80
  /**
52
81
  * A conformance profile.
@@ -185,11 +214,86 @@ export interface OpLog {
185
214
  */
186
215
  export type MetadataKey = "title" | "authors" | "subject" | "keywords" | "creator" | "producer" | "created" | "modified";
187
216
 
217
+ /**
218
+ * A move in user space (ISO 32000-2 §8.3.2.3: y up), in user-space units. Both distances are
219
+ * finite: [`Offset::new`] and the wire form refuse anything else, so a move never writes a
220
+ * coordinate a PDF can't hold.
221
+ *
222
+ * Added in 0.3.0.
223
+ */
224
+ export interface Offset {
225
+ dx: number;
226
+ dy: number;
227
+ }
228
+
229
+ /**
230
+ * A named destination brought in under another name.
231
+ */
232
+ export interface RenamedDestinationJs {
233
+ /**
234
+ * Its name in the source.
235
+ */
236
+ from: string;
237
+ /**
238
+ * Its name in this document.
239
+ */
240
+ to: string;
241
+ }
242
+
243
+ /**
244
+ * A page of this document and how to show it: what `/Dest [page /XYZ …]` holds.
245
+ *
246
+ * Added in 0.3.0.
247
+ */
248
+ export interface ExplicitDestination {
249
+ /**
250
+ * The page.
251
+ */
252
+ page: string;
253
+ /**
254
+ * How to show it.
255
+ */
256
+ view: DestinationView;
257
+ }
258
+
188
259
  /**
189
260
  * A page-label numbering style.
190
261
  */
191
262
  export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
192
263
 
264
+ /**
265
+ * A patch of the window entries of `/ViewerPreferences` ([`WindowPreferences`]): each field
266
+ * left out keeps what the file has, `true` sets the entry, `false` removes it.
267
+ *
268
+ * Added in 0.3.0.
269
+ */
270
+ export interface WindowPreferencesPatch {
271
+ /**
272
+ * `/HideToolbar`.
273
+ */
274
+ hideToolbar?: boolean;
275
+ /**
276
+ * `/HideMenubar`.
277
+ */
278
+ hideMenubar?: boolean;
279
+ /**
280
+ * `/HideWindowUI`.
281
+ */
282
+ hideWindowUi?: boolean;
283
+ /**
284
+ * `/FitWindow`.
285
+ */
286
+ fitWindow?: boolean;
287
+ /**
288
+ * `/CenterWindow`.
289
+ */
290
+ centerWindow?: boolean;
291
+ /**
292
+ * `/DisplayDocTitle`.
293
+ */
294
+ displayDocTitle?: boolean;
295
+ }
296
+
193
297
  /**
194
298
  * A signature the planner found.
195
299
  */
@@ -208,6 +312,82 @@ export interface SignatureJs {
208
312
  revision?: number;
209
313
  }
210
314
 
315
+ /**
316
+ * Adds a bookmark under `parent` (`null`: the top level) at `at`, with its title, target and
317
+ * style. It has no children, so it has no open state yet (`/Count`, §12.3.3): set it with
318
+ * [`UpdateOutlineItem::open`] once it has some. The new item's ID is in
319
+ * [`Applied::created_outline_items`](crate::Applied::created_outline_items).
320
+ *
321
+ * On the wire: `{ "op": "addOutlineItem", "args": { "parent": null, "at": "last", "title":
322
+ * "Chapter 1", "target": { "destination": { "page": "p3.0", "view": { "kind": "fit" } } } } }`.
323
+ *
324
+ * Added in 0.3.0.
325
+ */
326
+ export interface AddOutlineItem {
327
+ /**
328
+ * The parent item; `None` for the top level.
329
+ */
330
+ parent?: string | null;
331
+ /**
332
+ * Where among the parent's children.
333
+ */
334
+ at: "first" | "last" | { before: string } | { after: string };
335
+ /**
336
+ * The title.
337
+ */
338
+ title: string;
339
+ /**
340
+ * Where the bookmark goes.
341
+ */
342
+ target: OutlineTarget;
343
+ /**
344
+ * Its colour and type style.
345
+ */
346
+ style?: OutlineStyle;
347
+ }
348
+
349
+ /**
350
+ * Adds a named destination, or points an existing one at `destination`. A name the catalog's
351
+ * `/Dests` dictionary holds stays there; any other goes into the `/Names /Dests` tree.
352
+ *
353
+ * On the wire: `{ "op": "setNamedDestination", "args": { "name": "results", "destination": {
354
+ * "page": "p7.0", "view": { "kind": "fitH", "top": 700 } } } }`.
355
+ *
356
+ * Added in 0.3.0.
357
+ */
358
+ export interface SetNamedDestination {
359
+ /**
360
+ * The name.
361
+ */
362
+ name: string;
363
+ /**
364
+ * Where it points.
365
+ */
366
+ destination: ExplicitDestination;
367
+ }
368
+
369
+ /**
370
+ * An XMP property declared in a PDF/A file's extension schemas.
371
+ */
372
+ export interface ExtensionPropertyJs {
373
+ /**
374
+ * The schema's namespace URI.
375
+ */
376
+ namespace: string;
377
+ /**
378
+ * The prefix the packet writes the namespace with.
379
+ */
380
+ prefix: string;
381
+ /**
382
+ * The property's local name.
383
+ */
384
+ name: string;
385
+ /**
386
+ * Its declared type, e.g. `Text` or `Seq Integer`.
387
+ */
388
+ valueType: string;
389
+ }
390
+
211
391
  /**
212
392
  * An attached file's options.
213
393
  */
@@ -249,7 +429,146 @@ export interface AttachmentInit {
249
429
  *
250
430
  * Added in 0.2.0.
251
431
  */
252
- export type Op = { op: "setInfo"; args: SetInfo } | { op: "rotatePage"; args: RotatePage } | { op: "setMetadata"; args: SetMetadata } | { op: "removeMetadata"; args: RemoveMetadata };
432
+ 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 };
433
+
434
+ /**
435
+ * Changes a bookmark's title, target, style or open state. An absent field is left alone. A
436
+ * target held as another action (JavaScript, `Launch`, …) is replaced only when `target` is
437
+ * given; the item's other entries are kept.
438
+ *
439
+ * On the wire: `{ "op": "updateOutlineItem", "args": { "item": "o12.0", "title": "Results",
440
+ * "open": true } }`.
441
+ *
442
+ * Added in 0.3.0.
443
+ */
444
+ export interface UpdateOutlineItem {
445
+ /**
446
+ * The item.
447
+ */
448
+ item: string;
449
+ /**
450
+ * A new title.
451
+ */
452
+ title?: string;
453
+ /**
454
+ * A new target.
455
+ */
456
+ target?: OutlineTarget;
457
+ /**
458
+ * A new style (colour and type style together).
459
+ */
460
+ style?: OutlineStyle;
461
+ /**
462
+ * Open (children shown) or closed; a bookmark without children has nowhere to keep it
463
+ * (`/Count`, §12.3.3), so it writes nothing there.
464
+ */
465
+ open?: boolean;
466
+ }
467
+
468
+ /**
469
+ * Changes an annotation's common and markup entries and moves it.
470
+ *
471
+ * An absent field leaves the entry alone and `null` removes it. `translate` moves `/Rect` and
472
+ * the subtype's geometry (`/QuadPoints`, `/InkList`, `/Vertices`, `/L`, `/CL`) and the
473
+ * annotation's Popup with it, and keeps the appearance, which §12.5.5 maps onto the new
474
+ * `/Rect`. A `Locked` annotation refuses everything but a change of its flags and its
475
+ * contents; a `LockedContents` one refuses a change of its contents (`annotation-locked`).
476
+ * Widgets and annotations stored as direct dictionaries are refused (`annotation-not-editable`).
477
+ *
478
+ * On the wire: `{ "op": "updateAnnot", "args": { "id": "a12.0", "contents": "Checked",
479
+ * "translate": { "dx": 0, "dy": -10 } } }`.
480
+ *
481
+ * Added in 0.3.0.
482
+ */
483
+ export interface UpdateAnnot {
484
+ /**
485
+ * The annotation.
486
+ */
487
+ id: string;
488
+ /**
489
+ * `/Contents`: the comment, or the alternative description.
490
+ */
491
+ contents?: string | null;
492
+ /**
493
+ * `/T`: the author.
494
+ */
495
+ author?: string | null;
496
+ /**
497
+ * `/Subj`.
498
+ */
499
+ subject?: string | null;
500
+ /**
501
+ * `/M`, the modification date the edit writes.
502
+ */
503
+ modified?: string;
504
+ /**
505
+ * `/F`, all the flags at once (Table 167).
506
+ */
507
+ flags?: number;
508
+ /**
509
+ * A move in user space.
510
+ */
511
+ translate?: Offset;
512
+ }
513
+
514
+ /**
515
+ * Changes how the document asks to be shown when it opens. Each field is a patch: left out,
516
+ * it keeps what the file has; `null` removes the entry, so readers use their default; a value
517
+ * sets it.
518
+ *
519
+ * * `open`: the page and zoom to open at, written as an explicit destination in
520
+ * `/OpenAction` (§12.3.2.2). An `/OpenAction` that is an action other than `GoTo`
521
+ * (JavaScript, a named action, a link to another file) is never replaced or removed: the op
522
+ * fails with [`Error::OpenActionNotDestination`].
523
+ * * `page_mode`, `page_layout`: the panel to show and how to lay the pages out.
524
+ * * `preferences`: the window entries of `/ViewerPreferences` (§12.2, Table 147); `true` sets
525
+ * one, `false` removes it (its default), and other entries (`/Direction`, `/PrintScaling`, …)
526
+ * are kept.
527
+ *
528
+ * When a value needs a later PDF version than the file declares (`UseAttachments` 1.6,
529
+ * `UseOC` and the two-page layouts 1.5, `/DisplayDocTitle` 1.4), the catalog's `/Version` is
530
+ * raised to it. The op is class [`Document`](crate::ModificationClass::Document) and touches no
531
+ * page.
532
+ *
533
+ * On the wire:
534
+ * `{ "op": "setInitialView", "args": { "open": { "page": "p12.0", "zoom": "fitWidth" },
535
+ * "pageMode": "outlines", "pageLayout": null, "preferences": { "displayDocTitle": true } } }`.
536
+ *
537
+ * ```
538
+ * use laminapdf_ops::{OpenAt, OpenZoom, SetInitialView, WindowPreferencesPatch};
539
+ * use laminapdf_model::PageMode;
540
+ *
541
+ * let op = SetInitialView::default()
542
+ * .with_open(Some(OpenAt::new("p3.0".parse()?, OpenZoom::FitWidth)))
543
+ * .with_page_mode(Some(PageMode::Outlines))
544
+ * .with_preferences(WindowPreferencesPatch::default().with_display_doc_title(true));
545
+ * assert_eq!(
546
+ * serde_json::to_string(&op)?,
547
+ * r#"{"open":{"page":"p3.0","zoom":"fitWidth"},"pageMode":"outlines","preferences":{"displayDocTitle":true}}"#
548
+ * );
549
+ * # Ok::<(), Box<dyn std::error::Error>>(())
550
+ * ```
551
+ *
552
+ * Added in 0.3.0.
553
+ */
554
+ export interface SetInitialView {
555
+ /**
556
+ * The page and zoom to open at.
557
+ */
558
+ open?: OpenAt | null;
559
+ /**
560
+ * The panel to show (`/PageMode`).
561
+ */
562
+ pageMode?: "none" | "outlines" | "thumbnails" | "fullScreen" | "optionalContent" | "attachments" | null;
563
+ /**
564
+ * How to lay the pages out (`/PageLayout`).
565
+ */
566
+ pageLayout?: "singlePage" | "oneColumn" | "twoColumnLeft" | "twoColumnRight" | "twoPageLeft" | "twoPageRight" | null;
567
+ /**
568
+ * The window entries of `/ViewerPreferences`.
569
+ */
570
+ preferences?: WindowPreferencesPatch;
571
+ }
253
572
 
254
573
  /**
255
574
  * Changes to the Info dictionary's text entries. For each field, `None` leaves the entry
@@ -342,6 +661,148 @@ export interface MetadataPatch {
342
661
  modified?: string | null;
343
662
  }
344
663
 
664
+ /**
665
+ * Copies `pages` (each once, in the order given) to `at`. A copy shares its source's content
666
+ * streams and resources and shows what it shows, inherited attributes included (ISO 32000-2
667
+ * §7.7.3.4). Its annotations are new objects with a new `/NM`; a form field's widget becomes
668
+ * a new field named `<partial>#<n>` with its own value, and a signature's widget is not copied
669
+ * (both in [`Applied::fields`](crate::Applied::fields)). In a tagged document the copy gets
670
+ * its own `/StructParents` key and clones of the elements whose content lies only on its
671
+ * source; content of elements that span pages is left untagged and the copy is listed in
672
+ * [`Applied::tags_incomplete`](crate::Applied::tags_incomplete). Page labels continue the range
673
+ * each copy lands in.
674
+ *
675
+ * On the wire: `{ "op": "duplicatePages", "args": { "pages": ["p7.0"], "at": { "after": "p7.0" } } }`.
676
+ *
677
+ * Added in 0.3.0.
678
+ */
679
+ export interface DuplicatePages {
680
+ /**
681
+ * The pages to copy.
682
+ */
683
+ pages: string[];
684
+ /**
685
+ * Where the copies go.
686
+ */
687
+ at: "start" | "end" | { before: string } | { after: string };
688
+ }
689
+
690
+ /**
691
+ * Copies pages of a source document into this one at `at`, in the order given (each once).
692
+ * The copies are new objects with new IDs, sharing nothing with the source. Their
693
+ * annotations point at them and get a new `/NM`; a link to a page that didn't come along is
694
+ * removed ([`Applied::links_removed`](crate::Applied::links_removed)), and the named
695
+ * destinations the others use come along, renamed `<name>#<n>` on a clash. Form fields join
696
+ * the form under their own names, or per [`Carry::fields`] when the name is taken
697
+ * ([`Applied::fields`](crate::Applied::fields)); signature fields are left off. The copies
698
+ * lose their tags ([`Applied::tags_dropped`](crate::Applied::tags_dropped)), page labels
699
+ * continue the range each copy lands in, and the document's version rises to the source's
700
+ * when that is newer.
701
+ *
702
+ * On the wire: `{ "op": "insertPagesFrom", "args": { "source": "<64 hex digits>", "pages":
703
+ * ["p3.0"], "at": "end" } }`, with `carry` optional.
704
+ *
705
+ * Added in 0.3.0.
706
+ */
707
+ export interface InsertPagesFrom {
708
+ /**
709
+ * The source document.
710
+ */
711
+ source: string;
712
+ /**
713
+ * The source's pages to copy, by their IDs in the source.
714
+ */
715
+ pages: string[];
716
+ /**
717
+ * Where the copies go.
718
+ */
719
+ at: "start" | "end" | { before: string } | { after: string };
720
+ /**
721
+ * What comes along with the pages.
722
+ */
723
+ carry?: Carry;
724
+ }
725
+
726
+ /**
727
+ * Deletes `pages` (each once; unknown pages are an error). Outline items, links and `GoTo`
728
+ * actions on surviving pages, named destinations and `/OpenAction` that named a deleted page
729
+ * follow `references` ([`ReferencePolicy`]); structure elements whose content was all on
730
+ * deleted pages are removed with their `/ParentTree` entries, and the widgets on deleted pages
731
+ * leave the form (a field left with none leaves it too). The page objects stay in the file's
732
+ * earlier revisions. Deleting every page is [`Error::NoPagesLeft`].
733
+ *
734
+ * On the wire: `{ "op": "deletePages", "args": { "pages": ["p7.0"], "references": "retarget" } }`.
735
+ *
736
+ * Added in 0.3.0.
737
+ */
738
+ export interface DeletePages {
739
+ /**
740
+ * The pages.
741
+ */
742
+ pages: string[];
743
+ /**
744
+ * What happens to destinations that name them; `retarget` when left out.
745
+ */
746
+ references?: ReferencePolicy;
747
+ }
748
+
749
+ /**
750
+ * Deletes a bookmark, and its children with it or moved up into its place.
751
+ *
752
+ * On the wire: `{ "op": "deleteOutlineItem", "args": { "item": "o12.0", "children":
753
+ * "promote" } }`.
754
+ *
755
+ * Added in 0.3.0.
756
+ */
757
+ export interface DeleteOutlineItem {
758
+ /**
759
+ * The item.
760
+ */
761
+ item: string;
762
+ /**
763
+ * What happens to its children.
764
+ */
765
+ children: ChildItems;
766
+ }
767
+
768
+ /**
769
+ * Deletes a named destination, from both stores when both hold it. Its uses in this file are left as they are and reported
770
+ * ([`Applied::destination_uses`](crate::Applied::destination_uses)): a bookmark or link that
771
+ * names it no longer goes anywhere.
772
+ *
773
+ * On the wire: `{ "op": "deleteNamedDestination", "args": { "name": "draft-notes" } }`.
774
+ *
775
+ * Added in 0.3.0.
776
+ */
777
+ export interface DeleteNamedDestination {
778
+ /**
779
+ * The name.
780
+ */
781
+ name: string;
782
+ }
783
+
784
+ /**
785
+ * Deletes an annotation with what belongs to it: its Popup, every reply whose `/IRT` chain
786
+ * reaches it, and, for a member of a group (`/RT /Group`, §12.5.6.2), the whole group, which
787
+ * is one unit. Chains are followed through cycles once. In a tagged document, the structure
788
+ * element's object reference to each deleted annotation is removed, and so is an element left
789
+ * with nothing in it. Each deleted object is freed.
790
+ *
791
+ * A `Locked` annotation is refused (`annotation-locked`), and so are widgets and direct
792
+ * dictionaries (`annotation-not-editable`). Deleting a Popup alone removes the `/Popup` entry
793
+ * that names it.
794
+ *
795
+ * On the wire: `{ "op": "deleteAnnot", "args": { "id": "a12.0" } }`.
796
+ *
797
+ * Added in 0.3.0.
798
+ */
799
+ export interface DeleteAnnot {
800
+ /**
801
+ * The annotation.
802
+ */
803
+ id: string;
804
+ }
805
+
345
806
  /**
346
807
  * Edits the Info dictionary: applies `patch` and, when `at` is given, sets `/ModDate` to it.
347
808
  *
@@ -405,11 +866,44 @@ export interface SetMetadata {
405
866
  replaceMalformed?: boolean;
406
867
  }
407
868
 
869
+ /**
870
+ * How [`RotatePages`] reads its angle.
871
+ *
872
+ * Added in 0.3.0.
873
+ */
874
+ export type RotateMode = "set" | "turn";
875
+
408
876
  /**
409
877
  * How a destination shows its page (§12.3.2.2).
410
878
  */
411
879
  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" };
412
880
 
881
+ /**
882
+ * How a destination shows its page (§12.3.2.2, Table 149), in the page's user space. A `None`
883
+ * coordinate keeps the viewer's current one (`null` in the file).
884
+ *
885
+ * Every number must be finite: the ops refuse any other with `view-not-finite`.
886
+ *
887
+ * Added in 0.3.0.
888
+ */
889
+ 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 };
890
+
891
+ /**
892
+ * How a merge brings in what the sources hold besides their pages.
893
+ *
894
+ * Added in 0.3.0.
895
+ */
896
+ export interface MergeOptions {
897
+ /**
898
+ * What becomes of the sources' bookmarks; `perFile` when left out.
899
+ */
900
+ outline?: OutlineMerge;
901
+ /**
902
+ * What happens to a form field whose name is already used; `rename` when left out.
903
+ */
904
+ fields?: FieldClash;
905
+ }
906
+
413
907
  /**
414
908
  * How a save would go (`laminapdf::PlannedSave`).
415
909
  */
@@ -502,11 +996,156 @@ export interface ViewerPreferencesInit {
502
996
  pageLayout?: PageLayoutInit;
503
997
  }
504
998
 
999
+ /**
1000
+ * Inserts `count` blank pages of `size` at `at`, each showing at `rotate`. Each new page
1001
+ * gets a new object and [`PageId`] (ADR 0005 §5), an empty `/Resources` and no content; in
1002
+ * a labelled document they continue the label range they land in. A count outside 1 to
1003
+ * 10,000, or a side that isn't above 0 and at most 14,400 points, is
1004
+ * [`Error::InvalidOp`](crate::Error::InvalidOp).
1005
+ *
1006
+ * On the wire: `{ "op": "insertBlankPages", "args": { "at": { "after": "p3.0" }, "count": 2,
1007
+ * "size": { "width": 612, "height": 792 }, "rotate": 0 } }`.
1008
+ *
1009
+ * Added in 0.3.0.
1010
+ */
1011
+ export interface InsertBlankPages {
1012
+ /**
1013
+ * Where the pages go.
1014
+ */
1015
+ at: "start" | "end" | { before: string } | { after: string };
1016
+ /**
1017
+ * How many pages, at least 1.
1018
+ */
1019
+ count: number;
1020
+ /**
1021
+ * Their `/MediaBox` size, in points: `{ "width": 612, "height": 792 }`.
1022
+ */
1023
+ size: { width: number; height: number };
1024
+ /**
1025
+ * Their rotation in degrees clockwise: 0, 90, 180 or 270.
1026
+ */
1027
+ rotate: 0 | 90 | 180 | 270;
1028
+ }
1029
+
1030
+ /**
1031
+ * Merges source documents into this one at `at`, one after another, as one edit. Each
1032
+ * source's pages come in as [`InsertPagesFrom`](crate::InsertPagesFrom) brings them (their
1033
+ * annotations, links and the named destinations those use, form fields under the clash rule
1034
+ * of `options.fields`, signature fields left off, tags dropped), and with them what belongs to
1035
+ * the whole source:
1036
+ *
1037
+ * - its bookmarks, per `options.outline`, going to the copies of their pages; a bookmark whose
1038
+ * page didn't come along is left out unless one of its children came
1039
+ * ([`Applied::bookmarks_dropped`](crate::Applied::bookmarks_dropped));
1040
+ * - its layers (optional content groups the copied pages use), added to this document's list
1041
+ * in the source's order and visible or hidden as the source showed them;
1042
+ * - its page labels: each copy keeps the label it had in its source, and this document's
1043
+ * pages keep theirs (a document without labels numbers its pages from 1);
1044
+ * - its form's default appearance and `/NeedAppearances`, and its PDF version when newer.
1045
+ *
1046
+ * Named destinations that clash are renamed `<name>#<n>`
1047
+ * ([`Applied::renamed_destinations`](crate::Applied::renamed_destinations)).
1048
+ *
1049
+ * On the wire: `{ "op": "mergeDocuments", "args": { "sources": [{ "source": "<64 hex
1050
+ * digits>" }], "at": "end" } }`, with each source's `pages` and `title`, and `options`,
1051
+ * optional.
1052
+ *
1053
+ * Added in 0.3.0.
1054
+ */
1055
+ export interface MergeDocuments {
1056
+ /**
1057
+ * The documents to bring in, in order.
1058
+ */
1059
+ sources: MergeSource[];
1060
+ /**
1061
+ * Where their pages go.
1062
+ */
1063
+ at: "start" | "end" | { before: string } | { after: string };
1064
+ /**
1065
+ * What comes along besides the pages.
1066
+ */
1067
+ options?: MergeOptions;
1068
+ }
1069
+
1070
+ /**
1071
+ * Moves `pages` to `to`. They keep their order among themselves (the order given, each page
1072
+ * once) and their IDs; an anchor that is itself moved is replaced by the nearest page that
1073
+ * stays.
1074
+ *
1075
+ * On the wire: `{ "op": "movePages", "args": { "pages": ["p7.0", "p8.0"], "to": "start" } }`.
1076
+ *
1077
+ * Added in 0.3.0.
1078
+ */
1079
+ export interface MovePages {
1080
+ /**
1081
+ * The pages, in the order they take at `to`.
1082
+ */
1083
+ pages: string[];
1084
+ /**
1085
+ * Where they go.
1086
+ */
1087
+ to: "start" | "end" | { before: string } | { after: string };
1088
+ }
1089
+
1090
+ /**
1091
+ * Moves a bookmark, with its children, under `parent` (`null`: the top level) at `at`. The
1092
+ * item keeps its ID.
1093
+ *
1094
+ * On the wire: `{ "op": "moveOutlineItem", "args": { "item": "o12.0", "parent": "o9.0", "at":
1095
+ * { "after": "o10.0" } } }`.
1096
+ *
1097
+ * Added in 0.3.0.
1098
+ */
1099
+ export interface MoveOutlineItem {
1100
+ /**
1101
+ * The item.
1102
+ */
1103
+ item: string;
1104
+ /**
1105
+ * The new parent; `None` for the top level.
1106
+ */
1107
+ parent?: string | null;
1108
+ /**
1109
+ * Where among the new parent's children.
1110
+ */
1111
+ at: "first" | "last" | { before: string } | { after: string };
1112
+ }
1113
+
505
1114
  /**
506
1115
  * Object numbering in a full rewrite.
507
1116
  */
508
1117
  export type RenumberJs = "keep" | "compact";
509
1118
 
1119
+ /**
1120
+ * One document a merge brings in.
1121
+ *
1122
+ * Added in 0.3.0.
1123
+ */
1124
+ export interface MergeSource {
1125
+ /**
1126
+ * The source document, added with [`Document::add_source`](crate::Document::add_source).
1127
+ */
1128
+ source: string;
1129
+ /**
1130
+ * The source's pages to bring in, by their IDs in the source, in order; all of them when
1131
+ * left out.
1132
+ */
1133
+ pages?: string[];
1134
+ /**
1135
+ * The name of the bookmark [`OutlineMerge::PerFile`] gives the source's bookmarks (a file
1136
+ * name, say); the source's own title when left out.
1137
+ */
1138
+ title?: string;
1139
+ }
1140
+
1141
+ /**
1142
+ * One entry of a language alternative, under the name TypeScript gives it.
1143
+ */
1144
+ export interface XmpLangText {
1145
+ lang: string;
1146
+ text: string;
1147
+ }
1148
+
510
1149
  /**
511
1150
  * One outline item and its children.
512
1151
  */
@@ -562,35 +1201,88 @@ export interface PageInfoJs {
562
1201
  */
563
1202
  height: number;
564
1203
  /**
565
- * `/Rotate` in degrees.
1204
+ * `/Rotate` in degrees.
1205
+ */
1206
+ rotation: number;
1207
+ /**
1208
+ * The page label, when the document defines one (document text).
1209
+ */
1210
+ label?: string;
1211
+ }
1212
+
1213
+ /**
1214
+ * One page-label range, from page `start` (0-based) on.
1215
+ */
1216
+ export interface PageLabelInit {
1217
+ /**
1218
+ * The first page of the range.
1219
+ */
1220
+ start: number;
1221
+ /**
1222
+ * The numbering style (none: prefix only).
1223
+ */
1224
+ style?: LabelStyleInit;
1225
+ /**
1226
+ * A prefix.
1227
+ */
1228
+ prefix?: string;
1229
+ /**
1230
+ * The first number (default 1).
1231
+ */
1232
+ first?: number;
1233
+ }
1234
+
1235
+ /**
1236
+ * One range of [`SetPageLabels`]: the labels from `page` up to the next range's page.
1237
+ *
1238
+ * Added in 0.3.0.
1239
+ */
1240
+ export interface PageLabelRange {
1241
+ /**
1242
+ * The range's first page.
1243
+ */
1244
+ page: string;
1245
+ /**
1246
+ * The numbering style; without one, each label is the prefix alone. On the wire:
1247
+ * `decimal`, `upperRoman`, `lowerRoman`, `upperLetters` or `lowerLetters`.
1248
+ */
1249
+ style?: "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
1250
+ /**
1251
+ * Text before each number (`A-` in `A-1`).
566
1252
  */
567
- rotation: number;
1253
+ prefix?: string;
568
1254
  /**
569
- * The page label, when the document defines one (document text).
1255
+ * The number of the range's first page, 1 or more (a `u32`, as the builder's page labels
1256
+ * take).
570
1257
  */
571
- label?: string;
1258
+ first?: number;
572
1259
  }
573
1260
 
574
1261
  /**
575
- * One page-label range, from page `start` (0-based) on.
1262
+ * One reference to a deleted page and what the deletion did to it.
576
1263
  */
577
- export interface PageLabelInit {
1264
+ export interface ReferenceEditJs {
578
1265
  /**
579
- * The first page of the range.
1266
+ * The deleted page it named.
580
1267
  */
581
- start: number;
1268
+ page: string;
582
1269
  /**
583
- * The numbering style (none: prefix only).
1270
+ * `outlineItem`, `link`, `namedDestination`, `openAction`, `structureElement`,
1271
+ * `structureKid` or `widget`.
584
1272
  */
585
- style?: LabelStyleInit;
1273
+ kind: "outlineItem" | "link" | "namedDestination" | "openAction" | "structureElement" | "structureKid" | "widget";
586
1274
  /**
587
- * A prefix.
1275
+ * The named destination's name, for a `namedDestination`.
588
1276
  */
589
- prefix?: string;
1277
+ name?: string;
590
1278
  /**
591
- * The first number (default 1).
1279
+ * `retargeted` or `removed`.
592
1280
  */
593
- first?: number;
1281
+ outcome: "retargeted" | "removed";
1282
+ /**
1283
+ * The surviving page it now names, when retargeted.
1284
+ */
1285
+ to?: string;
594
1286
  }
595
1287
 
596
1288
  /**
@@ -689,6 +1381,39 @@ export interface SaveOptionsInit {
689
1381
  instanceId?: string;
690
1382
  }
691
1383
 
1384
+ /**
1385
+ * Removes an XMP property, every copy of it in the packet; a property the Info dictionary
1386
+ * mirrors is removed from both. The value stays in the file's earlier revisions until a full
1387
+ * rewrite ([`Applied::still_in_earlier_revisions`](crate::Applied::still_in_earlier_revisions)).
1388
+ *
1389
+ * ```
1390
+ * use laminapdf_ops::{Op, RemoveXmpProperty};
1391
+ *
1392
+ * let op = Op::from(RemoveXmpProperty::new("http://example.com/ns/", "batch"));
1393
+ * assert_eq!(
1394
+ * serde_json::to_string(&op)?,
1395
+ * r#"{"op":"removeXmpProperty","args":{"namespace":"http://example.com/ns/","name":"batch"}}"#
1396
+ * );
1397
+ * # Ok::<(), serde_json::Error>(())
1398
+ * ```
1399
+ *
1400
+ * Added in 0.3.0.
1401
+ */
1402
+ export interface RemoveXmpProperty {
1403
+ /**
1404
+ * The property's namespace URI.
1405
+ */
1406
+ namespace: string;
1407
+ /**
1408
+ * The property's local name.
1409
+ */
1410
+ name: string;
1411
+ /**
1412
+ * As [`SetMetadata::replace_malformed`](crate::SetMetadata::replace_malformed).
1413
+ */
1414
+ replaceMalformed?: boolean;
1415
+ }
1416
+
692
1417
  /**
693
1418
  * Removes metadata fields from the Info dictionary and the XMP packet; the packet's other
694
1419
  * properties stay (J.10).
@@ -720,6 +1445,151 @@ export interface RemoveMetadata {
720
1445
  replaceMalformed?: boolean;
721
1446
  }
722
1447
 
1448
+ /**
1449
+ * Renames a named destination, keeping it where it is. With `links: follow` (the default) the
1450
+ * bookmarks, links and `GoTo` actions of this file that name it are renamed too, in the form
1451
+ * they named it in.
1452
+ *
1453
+ * On the wire: `{ "op": "renameNamedDestination", "args": { "from": "sec2", "to": "methods" } }`.
1454
+ *
1455
+ * Added in 0.3.0.
1456
+ */
1457
+ export interface RenameNamedDestination {
1458
+ /**
1459
+ * The current name.
1460
+ */
1461
+ from: string;
1462
+ /**
1463
+ * The new name; no destination may have it yet.
1464
+ */
1465
+ to: string;
1466
+ /**
1467
+ * Whether the uses follow.
1468
+ */
1469
+ links?: RenameLinks;
1470
+ }
1471
+
1472
+ /**
1473
+ * Replaces pages of this document with pages of a source document, pair by pair: the first
1474
+ * source page takes the first target's place, and so on. What pointed at a replaced page
1475
+ * (outline items, links, named destinations, `GoTo` actions, `/OpenAction`) now points at
1476
+ * the page that took its place, with the view `/Fit`, since coordinates on the old page mean
1477
+ * nothing on the new one. Targets left over are deleted (their references retargeted to the
1478
+ * nearest surviving page); source pages left over go after the last copy. The copies come
1479
+ * in as with [`InsertPagesFrom`]; the replaced pages are deleted as with
1480
+ * [`DeletePages`](crate::DeletePages), structure, widgets and earlier revisions included.
1481
+ *
1482
+ * On the wire: `{ "op": "replacePages", "args": { "targets": ["p7.0"], "source": "<64 hex
1483
+ * digits>", "pages": ["p3.0"] } }`, with `carry` optional.
1484
+ *
1485
+ * Added in 0.3.0.
1486
+ */
1487
+ export interface ReplacePages {
1488
+ /**
1489
+ * The pages to replace, in order.
1490
+ */
1491
+ targets: string[];
1492
+ /**
1493
+ * The source document.
1494
+ */
1495
+ source: string;
1496
+ /**
1497
+ * The source's pages that take their places, by their IDs in the source.
1498
+ */
1499
+ pages: string[];
1500
+ /**
1501
+ * What comes along with the pages.
1502
+ */
1503
+ carry?: Carry;
1504
+ }
1505
+
1506
+ /**
1507
+ * Replaces the document's page labels with `ranges`; an empty list removes them, so viewers
1508
+ * show page numbers again.
1509
+ *
1510
+ * Each range starts at a page, named by its ID, and labels that page and the ones after it up
1511
+ * to the next range. The ranges must be in page order, two never on one page, the first on
1512
+ * the document's first page (the number tree must have an entry for page 0, §12.4.2), and
1513
+ * each numbered from 1 or more; otherwise the op fails with `invalid-label-ranges`. Nothing
1514
+ * is written when the catalog already holds exactly these labels
1515
+ * ([`PageLabels::is_written`]); any other tree, a damaged one included, is replaced.
1516
+ *
1517
+ * On the wire:
1518
+ * `{ "op": "setPageLabels", "args": { "ranges": [{ "page": "p3.0", "style": "lowerRoman" }] } }`.
1519
+ *
1520
+ * Added in 0.3.0.
1521
+ */
1522
+ export interface SetPageLabels {
1523
+ /**
1524
+ * The ranges, in page order.
1525
+ */
1526
+ ranges: PageLabelRange[];
1527
+ }
1528
+
1529
+ /**
1530
+ * Replaces the whole XMP packet with `xml`, for what the property ops can't write
1531
+ * (structures, qualifiers, comments). The packet is parsed before it applies and refused if it
1532
+ * doesn't parse (`invalid-xmp-packet`) or changes the PDF/A or PDF/UA identification
1533
+ * (`xmp-claim-read-only`). Info's mirrored entries follow the new packet; in a file that
1534
+ * claims PDF/A, the extension schema entries its properties lack are added and reported
1535
+ * ([`Applied::declared`](crate::Applied::declared)). The old packet stays in the file's
1536
+ * earlier revisions until a full rewrite.
1537
+ *
1538
+ * ```
1539
+ * use laminapdf_ops::{Op, ReplaceXmpPacket};
1540
+ *
1541
+ * let op = Op::from(ReplaceXmpPacket::new("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">…</x:xmpmeta>"));
1542
+ * assert!(serde_json::to_string(&op)?.starts_with(r#"{"op":"replaceXmpPacket","args":{"xml":"<x:xmpmeta"#));
1543
+ * # Ok::<(), serde_json::Error>(())
1544
+ * ```
1545
+ *
1546
+ * Added in 0.3.0.
1547
+ */
1548
+ export interface ReplaceXmpPacket {
1549
+ /**
1550
+ * The new packet's XML, with or without its `<?xpacket … ?>` wrapper.
1551
+ */
1552
+ xml: string;
1553
+ }
1554
+
1555
+ /**
1556
+ * Reverses the order of `pages` within the places they hold: the first of them (in page
1557
+ * order) takes the last one's place, and so on; the other pages don't move.
1558
+ *
1559
+ * On the wire: `{ "op": "reversePages", "args": { "pages": ["p3.0", "p4.0", "p5.0"] } }`.
1560
+ *
1561
+ * Added in 0.3.0.
1562
+ */
1563
+ export interface ReversePages {
1564
+ /**
1565
+ * The pages; their order here doesn't matter.
1566
+ */
1567
+ pages: string[];
1568
+ }
1569
+
1570
+ /**
1571
+ * Rotates `pages` by `angle`, set or turned ([`RotateMode`]); each page as
1572
+ * [`RotatePage`] does, keeping its object and [`PageId`].
1573
+ *
1574
+ * On the wire: `{ "op": "rotatePages", "args": { "pages": ["p3.0"], "angle": 90, "mode": "turn" } }`.
1575
+ *
1576
+ * Added in 0.3.0.
1577
+ */
1578
+ export interface RotatePages {
1579
+ /**
1580
+ * The pages.
1581
+ */
1582
+ pages: string[];
1583
+ /**
1584
+ * The angle in degrees clockwise: 0, 90, 180 or 270.
1585
+ */
1586
+ angle: 0 | 90 | 180 | 270;
1587
+ /**
1588
+ * Whether the angle is set or added; `set` when left out.
1589
+ */
1590
+ mode?: RotateMode;
1591
+ }
1592
+
723
1593
  /**
724
1594
  * Sets a page's rotation to `rotate` (absolute, not relative to the current value).
725
1595
  *
@@ -746,6 +1616,60 @@ export interface RotatePage {
746
1616
  rotate: 0 | 90 | 180 | 270;
747
1617
  }
748
1618
 
1619
+ /**
1620
+ * Sets any XMP property: text, a URI, a number, a boolean, a date, a language alternative,
1621
+ * or an ordered or unordered array of simple values. A file without a packet gets one.
1622
+ *
1623
+ * `prefix` names the namespace when the packet binds no prefix to it. A property the Info
1624
+ * dictionary mirrors (`dc:title`, `pdf:Producer`, …) is set in both, as
1625
+ * [`SetMetadata`](crate::SetMetadata) sets it, and must have its shape: text, or a language
1626
+ * alternative of the `x-default` entry alone, for `dc:title` and `dc:description`; an array of
1627
+ * text for `dc:creator`; a date for the dates.
1628
+ *
1629
+ * ```
1630
+ * use laminapdf_ops::{Op, SetXmpProperty};
1631
+ * use laminapdf_model::xmp::XmpValue;
1632
+ *
1633
+ * let op = Op::from(SetXmpProperty::new("http://example.com/ns/", "acme", "batch", XmpValue::Integer(42)));
1634
+ * assert_eq!(
1635
+ * serde_json::to_string(&op)?,
1636
+ * r#"{"op":"setXmpProperty","args":{"namespace":"http://example.com/ns/","prefix":"acme","name":"batch","value":{"type":"integer","value":42}}}"#
1637
+ * );
1638
+ * # Ok::<(), serde_json::Error>(())
1639
+ * ```
1640
+ *
1641
+ * Added in 0.3.0.
1642
+ */
1643
+ export interface SetXmpProperty {
1644
+ /**
1645
+ * The property's namespace URI.
1646
+ */
1647
+ namespace: string;
1648
+ /**
1649
+ * The prefix to write the namespace with when the packet binds none.
1650
+ */
1651
+ prefix: string;
1652
+ /**
1653
+ * The property's local name.
1654
+ */
1655
+ name: string;
1656
+ /**
1657
+ * The new value.
1658
+ */
1659
+ value: XmpValue;
1660
+ /**
1661
+ * As [`SetMetadata::replace_malformed`](crate::SetMetadata::replace_malformed).
1662
+ */
1663
+ replaceMalformed?: boolean;
1664
+ }
1665
+
1666
+ /**
1667
+ * Something in the file that names a destination.
1668
+ *
1669
+ * Added in 0.3.0.
1670
+ */
1671
+ export type DestinationUse = { kind: "outlineItem"; item: string } | { kind: "annotation"; page: string; annot: string } | { kind: "catalog" };
1672
+
749
1673
  /**
750
1674
  * The Info dictionary's text entries; absent ones are left out (document text).
751
1675
  */
@@ -824,6 +1748,24 @@ export interface MetadataInit {
824
1748
  modDate?: string;
825
1749
  }
826
1750
 
1751
+ /**
1752
+ * The document's XMP packet as text (`laminapdf::XmpText`).
1753
+ */
1754
+ export interface XmpTextJs {
1755
+ /**
1756
+ * Whether there is a packet, and whether it was read.
1757
+ */
1758
+ status: PacketStatus;
1759
+ /**
1760
+ * The packet's XML, with the edits made so far.
1761
+ */
1762
+ xml?: string;
1763
+ /**
1764
+ * The PDF/A part and conformance the packet claims, e.g. `"2B"`.
1765
+ */
1766
+ pdfa?: string;
1767
+ }
1768
+
827
1769
  /**
828
1770
  * The kind of change an op makes. The save planner checks it against `DocMDP` / `FieldMDP`
829
1771
  * permissions and the document's `SaveConstraint` ([ADR 0007]).
@@ -834,6 +1776,22 @@ export interface MetadataInit {
834
1776
  */
835
1777
  export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
836
1778
 
1779
+ /**
1780
+ * The page and zoom a document opens at.
1781
+ *
1782
+ * Added in 0.3.0.
1783
+ */
1784
+ export interface OpenAt {
1785
+ /**
1786
+ * The page.
1787
+ */
1788
+ page: string;
1789
+ /**
1790
+ * The zoom.
1791
+ */
1792
+ zoom?: "default" | "fitPage" | "fitWidth" | number;
1793
+ }
1794
+
837
1795
  /**
838
1796
  * The pages an edit touched.
839
1797
  */
@@ -851,11 +1809,71 @@ export interface EditedJs {
851
1809
  * full rewrite drops.
852
1810
  */
853
1811
  stillInEarlierRevisions: boolean;
1812
+ /**
1813
+ * IDs of annotations an annotation op deleted besides the one it names (Popups, replies,
1814
+ * the rest of a group); left out when there are none.
1815
+ */
1816
+ alsoDeleted?: string[];
854
1817
  /**
855
1818
  * Whether the edit changed the document: one that only set values they already had leaves
856
1819
  * no step to undo.
857
1820
  */
858
1821
  changed: boolean;
1822
+ /**
1823
+ * The IDs of the bookmarks the edit added, in order.
1824
+ */
1825
+ createdOutlineItems: string[];
1826
+ /**
1827
+ * An outline edit found the outline's links broken and rewrote them whole; bookmarks
1828
+ * stored inside others have new IDs.
1829
+ */
1830
+ outlineRepaired: boolean;
1831
+ /**
1832
+ * What still names a named destination the edit deleted.
1833
+ */
1834
+ destinationUses: DestinationUse[];
1835
+ /**
1836
+ * The XMP properties the edit declared in a PDF/A file's extension schemas.
1837
+ */
1838
+ declared: ExtensionPropertyJs[];
1839
+ /**
1840
+ * The page IDs in order after the edit, when it changed the page list.
1841
+ */
1842
+ pageOrder?: string[];
1843
+ /**
1844
+ * What a page deletion did to the references to the deleted pages.
1845
+ */
1846
+ references: ReferenceEditJs[];
1847
+ /**
1848
+ * What a page duplication did to the form fields whose widgets the copied pages show;
1849
+ * left out when there are none.
1850
+ */
1851
+ fields?: FieldEditJs[];
1852
+ /**
1853
+ * The copies a page duplication made whose tags couldn't all be cloned; left out when
1854
+ * there are none.
1855
+ */
1856
+ tagsIncomplete?: string[];
1857
+ /**
1858
+ * The page holding each link a page copied in from another document lost, one entry per
1859
+ * link; left out when there are none.
1860
+ */
1861
+ linksRemoved?: string[];
1862
+ /**
1863
+ * The pages copied in from another document without the tags their source gave them; left
1864
+ * out when there are none.
1865
+ */
1866
+ tagsDropped?: string[];
1867
+ /**
1868
+ * The named destinations a merge or a page import brought in under another name, because
1869
+ * the document already used theirs; left out when there are none.
1870
+ */
1871
+ renamedDestinations?: RenamedDestinationJs[];
1872
+ /**
1873
+ * The bookmarks a merge left out because the pages they went to didn't come along; left
1874
+ * out when there are none.
1875
+ */
1876
+ bookmarksDropped?: number;
859
1877
  }
860
1878
 
861
1879
  /**
@@ -868,6 +1886,52 @@ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "
868
1886
  */
869
1887
  export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
870
1888
 
1889
+ /**
1890
+ * The wire form, under the name TypeScript gives it.
1891
+ */
1892
+ 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[] };
1893
+
1894
+ /**
1895
+ * What [`DeleteOutlineItem`](super::DeleteOutlineItem) does with the item's children.
1896
+ *
1897
+ * Added in 0.3.0.
1898
+ */
1899
+ export type ChildItems = "delete" | "promote";
1900
+
1901
+ /**
1902
+ * What [`DeletePages`] does with a destination that names a deleted page.
1903
+ *
1904
+ * Added in 0.3.0.
1905
+ */
1906
+ export type ReferencePolicy = "retarget" | "remove";
1907
+
1908
+ /**
1909
+ * What a page duplication or a page copied in did to one form field.
1910
+ */
1911
+ export interface FieldEditJs {
1912
+ /**
1913
+ * The field on the source page (in the source document, for a page copied in).
1914
+ */
1915
+ field: string;
1916
+ /**
1917
+ * The copy whose widget it concerns.
1918
+ */
1919
+ page: string;
1920
+ /**
1921
+ * `renamed` (the copy's widget belongs to a new field), `linked` (it joined the field of
1922
+ * the same name) or `notCopied` (a signature's widget).
1923
+ */
1924
+ outcome: "renamed" | "linked" | "notCopied";
1925
+ /**
1926
+ * The new field's ID, when renamed; the field it joined, when linked.
1927
+ */
1928
+ to?: string;
1929
+ /**
1930
+ * The new field's fully qualified name, when renamed.
1931
+ */
1932
+ name?: string;
1933
+ }
1934
+
871
1935
  /**
872
1936
  * What a save wrote (`laminapdf::SaveReport`).
873
1937
  */
@@ -935,6 +1999,39 @@ export interface RevertedJs {
935
1999
  touchedPages: string[];
936
2000
  }
937
2001
 
2002
+ /**
2003
+ * What becomes of the sources' outlines (bookmarks) in a merge.
2004
+ *
2005
+ * Added in 0.3.0.
2006
+ */
2007
+ export type OutlineMerge = "perFile" | "keep" | "none";
2008
+
2009
+ /**
2010
+ * What comes along with pages copied from another document.
2011
+ *
2012
+ * Added in 0.3.0.
2013
+ */
2014
+ export interface Carry {
2015
+ /**
2016
+ * Whether the pages' annotations other than form fields come along (links, comments,
2017
+ * markup); `true` when left out.
2018
+ */
2019
+ annotations?: boolean;
2020
+ /**
2021
+ * What happens to a form field whose name the target already uses; `rename` when left
2022
+ * out.
2023
+ */
2024
+ fields?: FieldClash;
2025
+ }
2026
+
2027
+ /**
2028
+ * What happens to a copied form field whose fully qualified name the target already uses
2029
+ * (E2 plan §11).
2030
+ *
2031
+ * Added in 0.3.0.
2032
+ */
2033
+ export type FieldClash = "rename" | "link";
2034
+
938
2035
  /**
939
2036
  * What the document's `/Metadata` holds.
940
2037
  *
@@ -942,11 +2039,26 @@ export interface RevertedJs {
942
2039
  */
943
2040
  export type PacketStatus = "absent" | "parsed" | "malformed";
944
2041
 
2042
+ /**
2043
+ * Where a bookmark goes.
2044
+ *
2045
+ * Added in 0.3.0.
2046
+ */
2047
+ export type OutlineTarget = { destination: ExplicitDestination } | { named: string } | { uri: string };
2048
+
945
2049
  /**
946
2050
  * Where a link or outline item goes.
947
2051
  */
948
2052
  export type LinkTargetInit = { type: "uri"; uri: string } | { type: "page"; index: number; fit?: FitInit } | { type: "named"; name: string };
949
2053
 
2054
+ /**
2055
+ * Whether [`RenameNamedDestination`](super::RenameNamedDestination) renames the uses of the
2056
+ * name in this file too.
2057
+ *
2058
+ * Added in 0.3.0.
2059
+ */
2060
+ export type RenameLinks = "keep" | "follow";
2061
+
950
2062
  /**
951
2063
  * Which side [`DocumentMetadata`]'s values come from.
952
2064
  *
@@ -1108,6 +2220,15 @@ export class WasmDocument {
1108
2220
  private constructor();
1109
2221
  free(): void;
1110
2222
  [Symbol.dispose](): void;
2223
+ /**
2224
+ * Adds another PDF as a source document: `{ id, pages }`, its ID (64 hex digits, the
2225
+ * SHA-256 of `bytes`) and its page IDs in order. An encrypted one opens with `password`,
2226
+ * which no op ever holds.
2227
+ *
2228
+ * # Errors
2229
+ * `wrong-password`, `password-required`, and the errors of a file that doesn't open.
2230
+ */
2231
+ addSource(bytes: Uint8Array, password?: string | null): { id: string; pages: string[] };
1111
2232
  /**
1112
2233
  * Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
1113
2234
  * them), once they are written where the document lives; `historyCleared` is the copy's
@@ -1132,6 +2253,14 @@ export class WasmDocument {
1132
2253
  * error (nothing is applied).
1133
2254
  */
1134
2255
  apply(ops: Op[]): EditedJs;
2256
+ /**
2257
+ * A new document of `pages` of this one, in the order given.
2258
+ *
2259
+ * # Errors
2260
+ * `invalid-argument` for a value that isn't a list of page IDs, `unknown-page`; reading
2261
+ * errors.
2262
+ */
2263
+ extractPages(pages: string[]): WasmDocument;
1135
2264
  /**
1136
2265
  * Whether there are changes no save has written yet.
1137
2266
  */
@@ -1147,6 +2276,16 @@ export class WasmDocument {
1147
2276
  * Whether the file is encrypted (it opened with its password, or the empty one).
1148
2277
  */
1149
2278
  isEncrypted(): boolean;
2279
+ /**
2280
+ * A new document of `inputs` (each `{ bytes, password?, title? }`) one after another,
2281
+ * with their bookmarks, named destinations, form fields, layers and page labels; `options`
2282
+ * as `mergeDocuments`' (`outline`, `fields`).
2283
+ *
2284
+ * # Errors
2285
+ * `invalid-argument` / `unknown-option` for bad values, `wrong-password`,
2286
+ * `password-required`, and the errors of a file that doesn't open.
2287
+ */
2288
+ static merge(inputs: { bytes: Uint8Array; password?: string; title?: string }[], options: MergeOptions | undefined): WasmDocument;
1150
2289
  /**
1151
2290
  * The document's metadata, read from Info and XMP together, with the fields where they
1152
2291
  * disagree.
@@ -1251,6 +2390,17 @@ export class WasmDocument {
1251
2390
  * The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
1252
2391
  */
1253
2392
  save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
2393
+ /**
2394
+ * This document cut into new ones: `{ count: n }` parts of `n` pages, `{ ranges: [[id, …],
2395
+ * …] }` one part per list of page IDs, or `{ bookmarks: level }` a part from each bookmark
2396
+ * at that depth (1: the top level). Each part carries what its pages reach and the
2397
+ * bookmarks that go to them.
2398
+ *
2399
+ * # Errors
2400
+ * `invalid-argument` / `unknown-option` for a value that isn't one of those, `unknown-page`,
2401
+ * `no-pages-left` for an empty list; reading errors.
2402
+ */
2403
+ split(by: { readonly count: number } | { readonly ranges: readonly (readonly string[])[] } | { readonly bookmarks: number }): WasmDocument[];
1254
2404
  /**
1255
2405
  * Undoes the newest transaction: how it went and the pages it touched; `undefined` when
1256
2406
  * there is nothing to undo.
@@ -1270,6 +2420,13 @@ export class WasmDocument {
1270
2420
  * `invalid-argument` for a value that isn't an op; reading errors.
1271
2421
  */
1272
2422
  wouldViolate(op: Op): ViolationJs[];
2423
+ /**
2424
+ * The document's XMP packet as text, with the edits made so far.
2425
+ *
2426
+ * # Errors
2427
+ * Reading errors.
2428
+ */
2429
+ xmpPacket(): XmpTextJs;
1273
2430
  }
1274
2431
 
1275
2432
  /**
@@ -1637,12 +2794,15 @@ export interface InitOutput {
1637
2794
  readonly wasmbuilder_page: (a: number, b: number, c: number) => number;
1638
2795
  readonly wasmbuilder_pageLabels: (a: number, b: any) => [number, number];
1639
2796
  readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
2797
+ readonly wasmdocument_addSource: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
1640
2798
  readonly wasmdocument_adoptCopy: (a: number, b: number, c: number, d: number) => [number, number];
1641
2799
  readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
1642
2800
  readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
2801
+ readonly wasmdocument_extractPages: (a: number, b: any) => [number, number, number];
1643
2802
  readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
1644
2803
  readonly wasmdocument_info: (a: number) => [number, number, number];
1645
2804
  readonly wasmdocument_isEncrypted: (a: number) => number;
2805
+ readonly wasmdocument_merge: (a: any, b: any) => [number, number, number];
1646
2806
  readonly wasmdocument_metadata: (a: number) => [number, number, number];
1647
2807
  readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
1648
2808
  readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
@@ -1657,9 +2817,11 @@ export interface InitOutput {
1657
2817
  readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
1658
2818
  readonly wasmdocument_saveCopy: (a: number, b: any) => [number, number, number];
1659
2819
  readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
2820
+ readonly wasmdocument_split: (a: number, b: any) => [number, number, number];
1660
2821
  readonly wasmdocument_undo: (a: number) => [number, number, number];
1661
2822
  readonly wasmdocument_warnings: (a: number) => number;
1662
2823
  readonly wasmdocument_wouldViolate: (a: number, b: any) => [number, number, number];
2824
+ readonly wasmdocument_xmpPacket: (a: number) => [number, number, number];
1663
2825
  readonly wasmimage_height: (a: number) => number;
1664
2826
  readonly wasmimage_jpeg: (a: number, b: number) => [number, number, number];
1665
2827
  readonly wasmimage_png: (a: number, b: number) => [number, number, number];