@lpdfio/lpdf 0.31.0 → 0.32.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/dist/_shared.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface RenderOptions {
9
9
  * Optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`).
10
10
  * When provided, written as `/CreationDate` in the PDF info dictionary.
11
11
  * Omitting this keeps builds reproducible (no embedded timestamp).
12
- * Required for a document whose `output` asks for `pdfa`, which writes it as both dates of the file.
12
+ * Required for a document whose `output` asks for `pdfa`, `pdfua` or `pdfx`, which writes it as both dates of the file.
13
13
  */
14
14
  createdOn?: string;
15
15
  /**
package/dist/attrs.d.ts CHANGED
@@ -55,6 +55,19 @@ export interface ColumnAttr {
55
55
  */
56
56
  paginate?: string;
57
57
  debug?: boolean;
58
+ /**
59
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
60
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
61
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
62
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
63
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
64
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
65
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
66
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
67
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
68
+ * on in a layers panel.
69
+ */
70
+ ocg?: string;
58
71
  align?: string;
59
72
  justify?: string;
60
73
  /**
@@ -123,6 +136,19 @@ export interface RowAttr {
123
136
  */
124
137
  paginate?: string;
125
138
  debug?: boolean;
139
+ /**
140
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
141
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
142
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
143
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
144
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
145
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
146
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
147
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
148
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
149
+ * on in a layers panel.
150
+ */
151
+ ocg?: string;
126
152
  align?: string;
127
153
  justify?: string;
128
154
  /**
@@ -189,6 +215,19 @@ export interface GridAttr {
189
215
  */
190
216
  paginate?: string;
191
217
  debug?: boolean;
218
+ /**
219
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
220
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
221
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
222
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
223
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
224
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
225
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
226
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
227
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
228
+ * on in a layers panel.
229
+ */
230
+ ocg?: string;
192
231
  /**
193
232
  * Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
194
233
  * the other children, shared equally if several on the line use fill, and never moves to the next
@@ -257,6 +296,19 @@ export interface ListAttr {
257
296
  */
258
297
  paginate?: string;
259
298
  debug?: boolean;
299
+ /**
300
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
301
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
302
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
303
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
304
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
305
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
306
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
307
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
308
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
309
+ * on in a layers panel.
310
+ */
311
+ ocg?: string;
260
312
  /** bullet marks each item with a shape, number with a number. Default bullet. */
261
313
  type?: string;
262
314
  /**
@@ -359,6 +411,19 @@ export interface LiAttr {
359
411
  */
360
412
  paginate?: string;
361
413
  debug?: boolean;
414
+ /**
415
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
416
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
417
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
418
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
419
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
420
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
421
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
422
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
423
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
424
+ * on in a layers panel.
425
+ */
426
+ ocg?: string;
362
427
  /**
363
428
  * Makes the item's marker a checkbox in place of the bullet or the number: an outline in the line
364
429
  * color, with a tick in the color of the item's words when this is true, and empty when it is
@@ -424,6 +489,19 @@ export interface FrameAttr {
424
489
  */
425
490
  paginate?: string;
426
491
  debug?: boolean;
492
+ /**
493
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
494
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
495
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
496
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
497
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
498
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
499
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
500
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
501
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
502
+ * on in a layers panel.
503
+ */
504
+ ocg?: string;
427
505
  /**
428
506
  * Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
429
507
  * the other children, shared equally if several on the line use fill, and never moves to the next
@@ -449,6 +527,19 @@ export interface LinkAttr {
449
527
  width?: string;
450
528
  height?: string;
451
529
  debug?: boolean;
530
+ /**
531
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
532
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
533
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
534
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
535
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
536
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
537
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
538
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
539
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
540
+ * on in a layers panel.
541
+ */
542
+ ocg?: string;
452
543
  }
453
544
  /**
454
545
  * Attributes of the `divider` element.
@@ -464,6 +555,19 @@ export interface DividerAttr {
464
555
  */
465
556
  width?: string;
466
557
  debug?: boolean;
558
+ /**
559
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
560
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
561
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
562
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
563
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
564
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
565
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
566
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
567
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
568
+ * on in a layers panel.
569
+ */
570
+ ocg?: string;
467
571
  }
468
572
  /**
469
573
  * Attributes of the `span` element.
@@ -477,6 +581,17 @@ export interface SpanAttr {
477
581
  * table of contents, # alone jumps to that entry's bookmark.
478
582
  */
479
583
  href?: string;
584
+ /**
585
+ * Makes the span a cross-reference to the bookmark with this id: a link to it whose words say
586
+ * where it is. In the span's words, {bookmark-page} prints the page the bookmark is on, as the
587
+ * footer of that page prints it, and {bookmark-label} the bookmark's label, so "{bookmark-label},
588
+ * on page {bookmark-page}" shows "clause 4, on page 12". An id that no bookmark has, another {…}
589
+ * token in the words, and href beside it are errors. It works in a text, a footnote, a region, a
590
+ * text-at and a code. The document is laid out again until each reference shows the page its
591
+ * bookmark lands on, and a reference keeps room for the widest words it has shown, so a number
592
+ * that got narrower can leave a small gap after it.
593
+ */
594
+ bookmarkRef?: string;
480
595
  underline?: boolean;
481
596
  strike?: boolean;
482
597
  }
@@ -501,6 +616,12 @@ export interface CodeSpanAttr {
501
616
  */
502
617
  export interface ImgAttr {
503
618
  name: string;
619
+ /**
620
+ * What the image shows, which a screen reader reads in a PDF/UA document; alt="" marks it as
621
+ * decoration, which a reader skips. A PDF/UA document needs it on every image of the layout. A
622
+ * document without pdfua ignores it.
623
+ */
624
+ alt?: string;
504
625
  height?: string;
505
626
  /**
506
627
  * Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
@@ -517,6 +638,19 @@ export interface ImgAttr {
517
638
  radius?: string;
518
639
  paginate?: string;
519
640
  debug?: boolean;
641
+ /**
642
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
643
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
644
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
645
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
646
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
647
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
648
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
649
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
650
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
651
+ * on in a layers panel.
652
+ */
653
+ ocg?: string;
520
654
  }
521
655
  /**
522
656
  * A rectangle, a circle or an ellipse in the layout, for a status dot, a color swatch or a progress
@@ -549,6 +683,19 @@ export interface ShapeAttr {
549
683
  /** How opaque the shape is, from 0 to 1. Default 1. */
550
684
  opacity?: number;
551
685
  debug?: boolean;
686
+ /**
687
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
688
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
689
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
690
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
691
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
692
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
693
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
694
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
695
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
696
+ * on in a layers panel.
697
+ */
698
+ ocg?: string;
552
699
  }
553
700
  /**
554
701
  * A QR code, a Code 128 or an EAN-13. It is never stretched. With only a width or a height, the
@@ -580,8 +727,27 @@ export interface BarcodeAttr {
580
727
  * line; in a column it takes the full width.
581
728
  */
582
729
  width?: string;
730
+ /**
731
+ * What the barcode is for, which a screen reader reads in a PDF/UA document in place of its data,
732
+ * which means nothing read aloud: "QR code to pay this invoice". alt="" marks it as decoration. A
733
+ * PDF/UA document needs it on every barcode of the layout. A document without pdfua ignores it.
734
+ */
735
+ alt?: string;
583
736
  paginate?: string;
584
737
  debug?: boolean;
738
+ /**
739
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
740
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
741
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
742
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
743
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
744
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
745
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
746
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
747
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
748
+ * on in a layers panel.
749
+ */
750
+ ocg?: string;
585
751
  }
586
752
  /**
587
753
  * A block of wrapping text. Use span children to style parts of it, and fn children for footnotes.
@@ -623,6 +789,13 @@ export interface TextAttr {
623
789
  * line; in a column it takes the full width.
624
790
  */
625
791
  width?: string;
792
+ /**
793
+ * Makes the text a heading, h1 to h6, which a PDF/UA document tags as one: a screen reader lists
794
+ * the headings and moves between them. A text without role is a paragraph. A PDF/UA document's
795
+ * headings start at h1 and go down one level at a time. It changes nothing a page shows: set the
796
+ * size and the weight as on any text. A document without pdfua ignores it.
797
+ */
798
+ role?: string;
626
799
  /**
627
800
  * The fewest lines of the text that may stand alone at the top of the next page when it splits.
628
801
  * Default 2. If fewer would be left, lines move from the first page to the next; 1 turns the
@@ -663,6 +836,19 @@ export interface TextAttr {
663
836
  captureFallback?: string;
664
837
  paginate?: string;
665
838
  debug?: boolean;
839
+ /**
840
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
841
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
842
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
843
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
844
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
845
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
846
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
847
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
848
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
849
+ * on in a layers panel.
850
+ */
851
+ ocg?: string;
666
852
  }
667
853
  /**
668
854
  * Code, or any text whose spaces and lines matter, in a box. The text is kept as it is written:
@@ -727,6 +913,19 @@ export interface CodeAttr {
727
913
  */
728
914
  paginate?: string;
729
915
  debug?: boolean;
916
+ /**
917
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
918
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
919
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
920
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
921
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
922
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
923
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
924
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
925
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
926
+ * on in a layers panel.
927
+ */
928
+ ocg?: string;
730
929
  /**
731
930
  * Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
732
931
  * the other children, shared equally if several on the line use fill, and never moves to the next
@@ -812,6 +1011,19 @@ export interface TdAttr {
812
1011
  */
813
1012
  paginate?: string;
814
1013
  debug?: boolean;
1014
+ /**
1015
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1016
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1017
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1018
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1019
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1020
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1021
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1022
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1023
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1024
+ * on in a layers panel.
1025
+ */
1026
+ ocg?: string;
815
1027
  /**
816
1028
  * How many of the table's columns the cell spans. It is as wide as those columns and the gaps
817
1029
  * between them, and the cells after it in the row start at the column after its last. A row whose
@@ -838,6 +1050,19 @@ export interface TdAttr {
838
1050
  */
839
1051
  export interface TheadAttr {
840
1052
  background?: string;
1053
+ /**
1054
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1055
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1056
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1057
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1058
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1059
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1060
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1061
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1062
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1063
+ * on in a layers panel.
1064
+ */
1065
+ ocg?: string;
841
1066
  }
842
1067
  /**
843
1068
  * Attributes of the `tr` element.
@@ -852,6 +1077,19 @@ export interface TrAttr {
852
1077
  */
853
1078
  keep?: string;
854
1079
  background?: string;
1080
+ /**
1081
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1082
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1083
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1084
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1085
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1086
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1087
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1088
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1089
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1090
+ * on in a layers panel.
1091
+ */
1092
+ ocg?: string;
855
1093
  }
856
1094
  /**
857
1095
  * Rows and cells in columns whose widths are set by cols. The thead row repeats at the top of every
@@ -896,6 +1134,19 @@ export interface TableAttr {
896
1134
  height?: string;
897
1135
  paginate?: string;
898
1136
  debug?: boolean;
1137
+ /**
1138
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1139
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1140
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1141
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1142
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1143
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1144
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1145
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1146
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1147
+ * on in a layers panel.
1148
+ */
1149
+ ocg?: string;
899
1150
  }
900
1151
  /**
901
1152
  * Attributes of the `field` element.
@@ -922,12 +1173,25 @@ export interface FieldAttr {
922
1173
  background?: string;
923
1174
  border?: string;
924
1175
  debug?: boolean;
1176
+ /**
1177
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1178
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1179
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1180
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1181
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1182
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1183
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1184
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1185
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1186
+ * on in a layers panel.
1187
+ */
1188
+ ocg?: string;
925
1189
  }
926
1190
  /**
927
1191
  * An entry of the PDF's outline, the bookmark panel of a viewer, and a target for links with
928
- * href="#id". It draws nothing and marks the element that follows it, so it is never left at the
929
- * bottom of a page apart from that element. Directly inside a section, it marks the section's first
930
- * page.
1192
+ * href="#id" and for cross-references with bookmark-ref. It draws nothing and marks the element
1193
+ * that follows it, so it is never left at the bottom of a page apart from that element. Directly
1194
+ * inside a section, it marks the section's first page.
931
1195
  */
932
1196
  export interface BookmarkAttr {
933
1197
  /** The text of the entry, in the outline and in a table of contents. */
@@ -938,11 +1202,19 @@ export interface BookmarkAttr {
938
1202
  */
939
1203
  level?: number;
940
1204
  /**
941
- * The name links use to jump here, as href="#id". Leave it out to make it from the label:
942
- * lowercase, with other characters than letters and digits turned into hyphens, and -2, -3 added
943
- * when an earlier bookmark has it. Two bookmarks may not have the same id.
1205
+ * The name links use to jump here, as href="#id", and cross-references as bookmark-ref="id".
1206
+ * Leave it out to make it from the label: lowercase, with other characters than letters and
1207
+ * digits turned into hyphens, and -2, -3 added when an earlier bookmark has it. Two bookmarks may
1208
+ * not have the same id.
944
1209
  */
945
1210
  id?: string;
1211
+ /**
1212
+ * true leaves the bookmark out of the viewer's outline and out of the table of contents, for a
1213
+ * figure or a table: label="Table 3" ref-only="true". Links with href="#id" and cross-references
1214
+ * with bookmark-ref still reach it, and {bookmark-label} still shows its label. Defaults to
1215
+ * false.
1216
+ */
1217
+ refOnly?: boolean;
946
1218
  }
947
1219
  /**
948
1220
  * Pins content to the top or bottom edge of pages, outside the normal flow, for headers and
@@ -1287,6 +1559,26 @@ export interface LayerAttr {
1287
1559
  * The color of the text-at in the layer that sets none of its own. Defaults to the text token.
1288
1560
  */
1289
1561
  color?: string;
1562
+ /**
1563
+ * In a PDF/UA document, what the layer shows, which a screen reader reads as one figure at the
1564
+ * layer's place in the document: a layer before the layout before it, one after the layout after
1565
+ * it. Without alt a layer is decoration, as a header is, and a screen reader skips it with all
1566
+ * its text: a watermark, a running title, a logo's letters. A document without pdfua ignores it.
1567
+ */
1568
+ alt?: string;
1569
+ /**
1570
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1571
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1572
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1573
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1574
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1575
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1576
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1577
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1578
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1579
+ * on in a layers panel.
1580
+ */
1581
+ ocg?: string;
1290
1582
  }
1291
1583
  /**
1292
1584
  * Attributes of the `rect` element in a layer.
@@ -1309,6 +1601,19 @@ export interface RectAttr {
1309
1601
  * with no fill shows the shadow only outside it.
1310
1602
  */
1311
1603
  shadow?: string;
1604
+ /**
1605
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1606
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1607
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1608
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1609
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1610
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1611
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1612
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1613
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1614
+ * on in a layers panel.
1615
+ */
1616
+ ocg?: string;
1312
1617
  }
1313
1618
  /**
1314
1619
  * Attributes of the `circle` element in a layer.
@@ -1339,6 +1644,19 @@ export interface CircleAttr {
1339
1644
  * with no fill shows the shadow only outside it.
1340
1645
  */
1341
1646
  shadow?: string;
1647
+ /**
1648
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1649
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1650
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1651
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1652
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1653
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1654
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1655
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1656
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1657
+ * on in a layers panel.
1658
+ */
1659
+ ocg?: string;
1342
1660
  }
1343
1661
  /**
1344
1662
  * Attributes of the `ellipse` element in a layer.
@@ -1370,6 +1688,19 @@ export interface EllipseAttr {
1370
1688
  * with no fill shows the shadow only outside it.
1371
1689
  */
1372
1690
  shadow?: string;
1691
+ /**
1692
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1693
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1694
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1695
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1696
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1697
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1698
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1699
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1700
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1701
+ * on in a layers panel.
1702
+ */
1703
+ ocg?: string;
1373
1704
  }
1374
1705
  /**
1375
1706
  * Attributes of the `line` element in a layer.
@@ -1383,6 +1714,19 @@ export interface LineAttr {
1383
1714
  strokeWidth?: string;
1384
1715
  strokeDash?: string;
1385
1716
  lineCap?: string;
1717
+ /**
1718
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1719
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1720
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1721
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1722
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1723
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1724
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1725
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1726
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1727
+ * on in a layers panel.
1728
+ */
1729
+ ocg?: string;
1386
1730
  }
1387
1731
  /**
1388
1732
  * Attributes of the `path` element in a layer.
@@ -1395,13 +1739,27 @@ export interface PathAttr {
1395
1739
  strokeWidth?: string;
1396
1740
  strokeDash?: string;
1397
1741
  lineCap?: string;
1742
+ /**
1743
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1744
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1745
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1746
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1747
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1748
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1749
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1750
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1751
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1752
+ * on in a layers panel.
1753
+ */
1754
+ ocg?: string;
1398
1755
  }
1399
1756
  /**
1400
1757
  * Text at a fixed place on the page. It is the text of the layout, with the same defaults: the
1401
1758
  * document's font or Helvetica, 11pt and the text colour. It is one line unless told otherwise;
1402
1759
  * give width to cut it off at a width or to wrap it with max-lines. x and y place its box: the
1403
1760
  * top-left corner, or with anchor, an offset from that point of the page, where the box's matching
1404
- * point goes. {page} and {pages} in it count within the section, and a text that comes from data
1761
+ * point goes. {page} in it prints the page's number and {pages} how many pages its run has, as its
1762
+ * section's page-start, page-format and page-prefix number them, and a text that comes from data
1405
1763
  * belongs in the layout, since a longer text loses its end here without a warning.
1406
1764
  */
1407
1765
  export interface TextAtAttr {
@@ -1444,6 +1802,19 @@ export interface TextAtAttr {
1444
1802
  * and max-lines above 1 wraps the text within it.
1445
1803
  */
1446
1804
  width?: string;
1805
+ /**
1806
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1807
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1808
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1809
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1810
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1811
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1812
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1813
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1814
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1815
+ * on in a layers panel.
1816
+ */
1817
+ ocg?: string;
1447
1818
  }
1448
1819
  /**
1449
1820
  * An image at a fixed place on the page. It needs width or height, and the other follows the
@@ -1459,6 +1830,19 @@ export interface ImgAtAttr {
1459
1830
  anchor?: string;
1460
1831
  width?: string;
1461
1832
  height?: string;
1833
+ /**
1834
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1835
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1836
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1837
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1838
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1839
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1840
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1841
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1842
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1843
+ * on in a layers panel.
1844
+ */
1845
+ ocg?: string;
1462
1846
  }
1463
1847
  /**
1464
1848
  * A barcode at a fixed place on the page. It needs width or height, and the other follows the
@@ -1488,6 +1872,19 @@ export interface BarcodeAtAttr {
1488
1872
  y?: string;
1489
1873
  anchor?: string;
1490
1874
  width?: string;
1875
+ /**
1876
+ * Puts the element, and everything in it, in an optional content group, which the viewer shows or
1877
+ * hides. print: printed, and not shown on screen. screen: shown on screen, and not printed. The
1878
+ * element keeps its room either way, so nothing moves. An element with a group inside an element
1879
+ * with another shows only where both show. Acrobat, Chrome and Firefox switch the groups; Preview
1880
+ * and Safari show everything, on screen and in print. Hidden content is still in the file, where
1881
+ * it can be selected and copied: it is not a way to keep anything secret. A link in print content
1882
+ * is drawn and does nothing, and a form field can't be in print content: use a frame with a
1883
+ * border for a box filled in by hand. With pdfa or pdfua on the output, everything shows. With
1884
+ * pdfx, the file is the print version: screen content stays in it, off, and a reader can turn it
1885
+ * on in a layers panel.
1886
+ */
1887
+ ocg?: string;
1491
1888
  }
1492
1889
  /**
1493
1890
  * The flowing content of a section. Elements stack down the page, and a new page starts when one
@@ -1566,6 +1963,25 @@ export interface FileAttr {
1566
1963
  /** A line about the file, which a reader shows beside its name. */
1567
1964
  description?: string;
1568
1965
  }
1966
+ /**
1967
+ * Declares an ICC color profile that the profile attribute of output names: the profile of the
1968
+ * printing press a PDF/X file is made for, which the printer gives out. The SDK reads the file from
1969
+ * src, or the profile was loaded on the engine under ref or, with no ref, under its own name. The
1970
+ * engine bundles no press profile.
1971
+ */
1972
+ export interface ProfileAttr {
1973
+ /**
1974
+ * The name that the profile attribute of output uses to pick this profile: lowercase letters,
1975
+ * digits and -, starting with a letter.
1976
+ */
1977
+ name: string;
1978
+ /** The key the profile was loaded under on the engine, when that is not its name. */
1979
+ ref?: string;
1980
+ /**
1981
+ * A path the SDK reads the ICC profile from, when the profile was not loaded on the engine.
1982
+ */
1983
+ src?: string;
1984
+ }
1569
1985
  /**
1570
1986
  * One color of a gradient, at an offset along it.
1571
1987
  */
package/dist/browser.js CHANGED
@@ -66,6 +66,19 @@ var LpdfEngine = class {
66
66
  const len1 = WASM_VECTOR_LEN;
67
67
  wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
68
68
  }
69
+ /**
70
+ * Register the bytes of an ICC colour profile, for the `<profile>` of a document's `<assets>` whose `ref`, or with
71
+ * no ref whose name, is `name`: the press profile a PDF/X document names in `<output profile>`.
72
+ * @param {string} name
73
+ * @param {Uint8Array} bytes
74
+ */
75
+ load_profile(name, bytes) {
76
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
+ const len0 = WASM_VECTOR_LEN;
78
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
79
+ const len1 = WASM_VECTOR_LEN;
80
+ wasm.lpdfengine_load_profile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
81
+ }
69
82
  /**
70
83
  * @param {string} license_key
71
84
  */
@@ -517,6 +530,7 @@ async function initLpdf(wasmSource, licenseKey = "") {
517
530
  const fontMap = /* @__PURE__ */ new Map();
518
531
  const imageMap = /* @__PURE__ */ new Map();
519
532
  const fileMap = /* @__PURE__ */ new Map();
533
+ const profileMap = /* @__PURE__ */ new Map();
520
534
  const markdownStyles = /* @__PURE__ */ new Map();
521
535
  return {
522
536
  loadFont(name, bytes) {
@@ -528,6 +542,9 @@ async function initLpdf(wasmSource, licenseKey = "") {
528
542
  loadFile(name, bytes) {
529
543
  fileMap.set(name, bytes);
530
544
  },
545
+ loadProfile(name, bytes) {
546
+ profileMap.set(name, bytes);
547
+ },
531
548
  loadMarkdownStyles(src, text) {
532
549
  markdownStyles.set(src, text);
533
550
  },
@@ -546,6 +563,9 @@ async function initLpdf(wasmSource, licenseKey = "") {
546
563
  for (const [name, bytes] of fileMap) {
547
564
  engine.load_file(name, bytes);
548
565
  }
566
+ for (const [name, bytes] of profileMap) {
567
+ engine.load_profile(name, bytes);
568
+ }
549
569
  for (const [src, text] of markdownStyles) {
550
570
  engine.load_markdown_styles(src, text);
551
571
  }
package/dist/engine.d.ts CHANGED
@@ -31,6 +31,7 @@ export declare class PdfEngine {
31
31
  private readonly _fonts;
32
32
  private readonly _images;
33
33
  private readonly _files;
34
+ private readonly _profiles;
34
35
  private readonly _markdownStyles;
35
36
  private _disposed;
36
37
  constructor();
@@ -65,6 +66,12 @@ export declare class PdfEngine {
65
66
  * no ref whose name, is `name`. The PDF carries them as they are. Call before `render`. Returns `this` for chaining.
66
67
  */
67
68
  loadFile(name: string, bytes: Uint8Array): this;
69
+ /**
70
+ * Register the bytes of an ICC color profile, for the `<profile>` of the document's `<assets>` whose `ref`, or with
71
+ * no ref whose name, is `name`: the press profile a PDF/X document names in its output. Call before `render`.
72
+ * Returns `this` for chaining.
73
+ */
74
+ loadProfile(name: string, bytes: Uint8Array): this;
68
75
  /**
69
76
  * Register the text of a file of Markdown rules, the root of which is a `<markdown-styles>`, for the `src` that
70
77
  * names it, as `<markdown-styles src="…">` does. Call before `render`. Returns `this` for chaining.
@@ -86,6 +93,11 @@ export declare class PdfEngine {
86
93
  * that wasn't. A `src` that can't be read is an error that names the file and the path.
87
94
  */
88
95
  private _loadFiles;
96
+ /**
97
+ * Hand the engine the color profiles the document declares: the ones loaded here, and the ones read from the `src`
98
+ * of a profile that wasn't. A `src` that can't be read is an error that names the profile and the path.
99
+ */
100
+ private _loadProfiles;
89
101
  private _throwIfDisposed;
90
102
  /**
91
103
  * Render an lpdf XML string to PDF bytes (Node.js).
package/dist/engine.js CHANGED
@@ -40,6 +40,7 @@ class PdfEngine {
40
40
  this._fonts = new Map();
41
41
  this._images = new Map();
42
42
  this._files = new Map();
43
+ this._profiles = new Map();
43
44
  this._markdownStyles = new Map();
44
45
  this._disposed = false;
45
46
  }
@@ -93,6 +94,16 @@ class PdfEngine {
93
94
  this._files.set(name, bytes);
94
95
  return this;
95
96
  }
97
+ /**
98
+ * Register the bytes of an ICC color profile, for the `<profile>` of the document's `<assets>` whose `ref`, or with
99
+ * no ref whose name, is `name`: the press profile a PDF/X document names in its output. Call before `render`.
100
+ * Returns `this` for chaining.
101
+ */
102
+ loadProfile(name, bytes) {
103
+ this._throwIfDisposed();
104
+ this._profiles.set(name, bytes);
105
+ return this;
106
+ }
96
107
  /**
97
108
  * Register the text of a file of Markdown rules, the root of which is a `<markdown-styles>`, for the `src` that
98
109
  * names it, as `<markdown-styles src="…">` does. Call before `render`. Returns `this` for chaining.
@@ -148,6 +159,26 @@ class PdfEngine {
148
159
  engine.load_file(key, bytes);
149
160
  }
150
161
  }
162
+ /**
163
+ * Hand the engine the color profiles the document declares: the ones loaded here, and the ones read from the `src`
164
+ * of a profile that wasn't. A `src` that can't be read is an error that names the profile and the path.
165
+ */
166
+ _loadProfiles(engine, srcs) {
167
+ const profiles = new Map(this._profiles);
168
+ for (const [key, src] of srcs) {
169
+ if (profiles.has(key))
170
+ continue;
171
+ try {
172
+ profiles.set(key, (0, node_fs_1.readFileSync)(src));
173
+ }
174
+ catch (e) {
175
+ throw new LpdfRenderError(`profile '${key}' of <assets>: cannot read its src '${src}': ${e instanceof Error ? e.message : String(e)}`);
176
+ }
177
+ }
178
+ for (const [key, bytes] of profiles) {
179
+ engine.load_profile(key, bytes);
180
+ }
181
+ }
151
182
  _throwIfDisposed() {
152
183
  if (this._disposed)
153
184
  throw new Error('PdfEngine has been disposed.');
@@ -183,6 +214,7 @@ class PdfEngine {
183
214
  }
184
215
  this._loadMarkdownStyles(engine, markdownStylesSrcs(xml));
185
216
  this._loadFiles(engine, extractAssetSrcs(xml, 'file'));
217
+ this._loadProfiles(engine, extractAssetSrcs(xml, 'profile'));
186
218
  // Auto-load images declared via <image src="…"> that weren't pre-loaded.
187
219
  for (const [key, src] of extractAssetSrcs(xml, 'image')) {
188
220
  if (!this._images.has(key)) {
@@ -225,6 +257,7 @@ class PdfEngine {
225
257
  }
226
258
  this._loadMarkdownStyles(engine, markdownStylesSrcsOfDocument(input));
227
259
  this._loadFiles(engine, fileSrcsOfDocument(input));
260
+ this._loadProfiles(engine, assetSrcsOfDocument(input, 'profiles'));
228
261
  pdf = engine.render_tree_pdf(json, ...(0, _shared_1.encryptionArguments)(callOptions, secureRandomBytes));
229
262
  }
230
263
  }
@@ -269,7 +302,7 @@ function xmlElements(xml, tag) {
269
302
  }
270
303
  return elements;
271
304
  }
272
- /** The `ref ?? name → src` pairs of the `<font>`, `<image>` or `<file>` elements in XML. */
305
+ /** The `ref ?? name → src` pairs of the `<font>`, `<image>`, `<file>` or `<profile>` elements in XML. */
273
306
  function extractAssetSrcs(xml, tag) {
274
307
  const result = new Map();
275
308
  for (const attributes of xmlElements(xml, tag)) {
@@ -315,7 +348,7 @@ function fileSrcsOfDocument(document) {
315
348
  }
316
349
  return result;
317
350
  }
318
- /** The `ref ?? name → src` pairs of the fonts or images a document declares in `attrs.assets`. */
351
+ /** The `ref ?? name → src` pairs of the fonts, images or color profiles a document declares in `attrs.assets`. */
319
352
  function assetSrcsOfDocument(document, kind) {
320
353
  const result = new Map();
321
354
  const declared = document.attrs['assets']?.[kind] ?? [];
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { PdfEngine, LpdfRenderError } from './engine';
2
2
  export type { RenderOptions, EngineOptions } from './_shared';
3
3
  export { FieldType, Pin, Orientation, SectionType, FootnoteCounter, Cipher, Permission, FileRelationship, BuiltinFont, PageScope, } from './constants';
4
4
  export type { PdfDocument, LpdfSectionNode, LpdfSectionChild, LpdfLayoutBlock, DocumentTokens, TokenSlot, TokenRow, DocumentAssets, DocumentMeta, DocumentOutput, SectionAttr, DocumentAttr, } from './kit';
5
- export type { ColumnAttr, RowAttr, GridAttr, ListAttr, LiAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, CodeAttr, SpanAttr, CodeSpanAttr, DividerAttr, ImgAttr, ShapeAttr, BarcodeAttr, RegionAttr, FieldAttr, BookmarkAttr, LayerAttr, RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr, TextAtAttr, ImgAtAttr, BarcodeAtAttr, FontAttr, ImageAttr, FileAttr, LayoutAttr, GradientToken, GradientStop, MarkdownAttr, MarkdownStylesAttr, MarkdownH1Attr, MarkdownH2Attr, MarkdownH3Attr, MarkdownH4Attr, MarkdownH5Attr, MarkdownH6Attr, MarkdownPAttr, MarkdownCodeAttr, MarkdownQuoteAttr, MarkdownLiAttr, MarkdownAAttr, MarkdownStrongAttr, MarkdownEmAttr, MarkdownDelAttr, MarkdownTableAttr, MarkdownThAttr, MarkdownTdAttr, } from './attrs';
5
+ export type { ColumnAttr, RowAttr, GridAttr, ListAttr, LiAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, CodeAttr, SpanAttr, CodeSpanAttr, DividerAttr, ImgAttr, ShapeAttr, BarcodeAttr, RegionAttr, FieldAttr, BookmarkAttr, LayerAttr, RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr, TextAtAttr, ImgAtAttr, BarcodeAtAttr, FontAttr, ImageAttr, FileAttr, ProfileAttr, LayoutAttr, GradientToken, GradientStop, MarkdownAttr, MarkdownStylesAttr, MarkdownH1Attr, MarkdownH2Attr, MarkdownH3Attr, MarkdownH4Attr, MarkdownH5Attr, MarkdownH6Attr, MarkdownPAttr, MarkdownCodeAttr, MarkdownQuoteAttr, MarkdownLiAttr, MarkdownAAttr, MarkdownStrongAttr, MarkdownEmAttr, MarkdownDelAttr, MarkdownTableAttr, MarkdownThAttr, MarkdownTdAttr, } from './attrs';
6
6
  export type { LpdfNode, LpdfContainerNode, LpdfListNode, LpdfLiNode, LpdfTextNode, LpdfCodeNode, LpdfSpanNode, LpdfCodeSpanNode, LpdfFnNode, LpdfDividerNode, LpdfImgNode, LpdfShapeNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, LpdfFieldNode, LpdfBookmarkNode, } from './layout';
7
7
  export { LMarkdown } from './markdown';
8
8
  export type { LpdfMarkdownNode, LpdfMarkdownStylesNode, LpdfMarkdownContentNode, LpdfMarkdownRuleNode, } from './markdown';
package/dist/kit.d.ts CHANGED
@@ -22,7 +22,7 @@
22
22
  import type { LpdfBookmarkNode, LpdfNode } from './layout';
23
23
  import type { LpdfCanvasLayerNode } from './canvas';
24
24
  import type { LpdfMarkdownNode } from './markdown';
25
- import type { FileAttr, FontAttr, GradientToken, ImageAttr, LayoutAttr } from './attrs';
25
+ import type { FileAttr, FontAttr, GradientToken, ImageAttr, LayoutAttr, ProfileAttr } from './attrs';
26
26
  import { type AttrValue } from './_shared';
27
27
  /** A slot of a token row, from the smallest to the largest. */
28
28
  export type TokenSlot = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
@@ -49,12 +49,18 @@ export interface DocumentTokens {
49
49
  lineHeight?: TokenRow<number>;
50
50
  }
51
51
  /**
52
- * The fonts and images the document declares, as the `assets` element of the XML does. A font or image
53
- * is picked by its `name`: text sets `font` to a font's name, an `img` sets `name` to an image's.
52
+ * The fonts, images and color profiles the document declares, as the `assets` element of the XML does. A font or
53
+ * image is picked by its `name`: text sets `font` to a font's name, an `img` sets `name` to an image's, and the
54
+ * output's `profile` names a profile.
54
55
  */
55
56
  export interface DocumentAssets {
56
57
  fonts?: FontAttr[];
57
58
  images?: ImageAttr[];
59
+ /**
60
+ * ICC color profiles: the profile of the printing press a PDF/X document is made for, which the printer gives out.
61
+ * Each is read from its `src`, or loaded with `loadProfile` under its `ref` or name.
62
+ */
63
+ profiles?: ProfileAttr[];
58
64
  }
59
65
  export interface DocumentMeta {
60
66
  title?: string;
@@ -62,6 +68,8 @@ export interface DocumentMeta {
62
68
  subject?: string;
63
69
  keywords?: string;
64
70
  creator?: string;
71
+ /** The language the document is written in, as a language tag such as `en-US`. A PDF/UA document needs it. */
72
+ lang?: string;
65
73
  }
66
74
  /**
67
75
  * How the PDF file is written, as the `output` element of the XML is: whether it is encrypted, and what a reader
@@ -82,20 +90,62 @@ export interface DocumentOutput {
82
90
  * error that says what to change: a built-in font, a CMYK color, a form field, a barcode's digits, `encrypt`.
83
91
  */
84
92
  pdfa?: string;
93
+ /**
94
+ * Writes the PDF as PDF/UA-1, a tagged PDF a screen reader can read: `1`. It combines with `pdfa`. The render
95
+ * needs `createdOn`, the meta a `title` and a `lang`, every image and barcode of the layout an `alt`, and every
96
+ * text a font of `assets`. What PDF/UA cannot hold is an error that says what to change.
97
+ */
98
+ pdfua?: string;
99
+ /**
100
+ * Writes the PDF as PDF/X-4, for a commercial printer: `4`. It needs `profile`, and combines with `pdfua`. Every
101
+ * page gets a TrimBox and a BleedBox, RGB is tied to sRGB, and links print as text, as PDF/X allows nothing
102
+ * clickable. The render needs `createdOn`, the meta a `title`, and every text a font of `assets`. What PDF/X cannot
103
+ * hold is an error that says what to change: a profile that is not a printer profile, a built-in font, a form
104
+ * field, a CMYK color with a profile that is not a CMYK one, `encrypt`, `pdfa`, attachments.
105
+ */
106
+ pdfx?: string;
107
+ /** The profile of `assets` that a PDF/X file is made for: the ICC profile of the printing press. It needs `pdfx`. */
108
+ profile?: string;
109
+ /**
110
+ * Writes the PDF linearized, for fast web view: page 1 comes first in the file, with hints that say where every
111
+ * other page is, so a viewer that fetches the file by byte ranges, as a browser does, shows page 1 while the rest
112
+ * downloads. Each page then names only the fonts and images it draws. With `encrypt` the file is encrypted first
113
+ * and linearized last. Any change to the file afterwards, such as a stamp, ends the linearization.
114
+ */
115
+ linearize?: boolean;
85
116
  }
86
117
  export interface SectionAttr {
87
118
  size?: string;
88
119
  orientation?: string;
120
+ /** How far this section's pages reach past their trim edge, such as `5mm`. Overrides the document's; `0mm` takes it away. */
121
+ bleed?: string;
89
122
  background?: string;
90
123
  title?: string;
91
124
  debug?: boolean;
92
125
  type?: string;
93
126
  tocIndentStep?: string;
94
127
  footnoteCounter?: string;
128
+ /**
129
+ * The number of the section's first page, which starts a new run of pages: `1` restarts the count. Without it the
130
+ * pages count on from the section before. `{page}` prints a page's number, and `{pages}` how many pages its run has.
131
+ */
132
+ pageStart?: number;
133
+ /**
134
+ * How the section's page numbers are written: `decimal`, `lower-alpha`, `upper-alpha`, `lower-roman` or
135
+ * `upper-roman`. Without it the section keeps the format before.
136
+ */
137
+ pageFormat?: string;
138
+ /** Text before the section's page numbers, such as `A-`. Without it the section keeps the prefix before; `''` takes it away. */
139
+ pagePrefix?: string;
95
140
  }
96
141
  export interface DocumentAttr {
97
142
  size?: string;
98
143
  orientation?: string;
144
+ /**
145
+ * How far each page reaches past its trim edge, such as `3mm`, for a background or an image that runs off the page
146
+ * when it is cut. The page grows by it and its background fills it; the layout keeps to the trimmed page.
147
+ */
148
+ bleed?: string;
99
149
  background?: string;
100
150
  font?: string;
101
151
  assets?: DocumentAssets;
@@ -67,6 +67,19 @@ export class LpdfEngine {
67
67
  const len1 = WASM_VECTOR_LEN;
68
68
  wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
69
69
  }
70
+ /**
71
+ * Register the bytes of an ICC colour profile, for the `<profile>` of a document's `<assets>` whose `ref`, or with
72
+ * no ref whose name, is `name`: the press profile a PDF/X document names in `<output profile>`.
73
+ * @param {string} name
74
+ * @param {Uint8Array} bytes
75
+ */
76
+ load_profile(name, bytes) {
77
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ const len0 = WASM_VECTOR_LEN;
79
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
80
+ const len1 = WASM_VECTOR_LEN;
81
+ wasm.lpdfengine_load_profile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
82
+ }
70
83
  /**
71
84
  * @param {string} license_key
72
85
  */
package/dist/wasm/lpdf.js CHANGED
@@ -67,6 +67,19 @@ class LpdfEngine {
67
67
  const len1 = WASM_VECTOR_LEN;
68
68
  wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
69
69
  }
70
+ /**
71
+ * Register the bytes of an ICC colour profile, for the `<profile>` of a document's `<assets>` whose `ref`, or with
72
+ * no ref whose name, is `name`: the press profile a PDF/X document names in `<output profile>`.
73
+ * @param {string} name
74
+ * @param {Uint8Array} bytes
75
+ */
76
+ load_profile(name, bytes) {
77
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ const len0 = WASM_VECTOR_LEN;
79
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
80
+ const len1 = WASM_VECTOR_LEN;
81
+ wasm.lpdfengine_load_profile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
82
+ }
70
83
  /**
71
84
  * @param {string} license_key
72
85
  */
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdfio/lpdf",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Node.js SDK for Lpdf — PDF as Code on every platform. You describe a document as code or XML. Lpdf renders a compact, pixel-perfect PDF — identical across platforms.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",