@lpdfio/lpdf 0.27.0 → 0.28.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/attrs.d.ts CHANGED
@@ -5,6 +5,12 @@
5
5
  export interface ColumnAttr {
6
6
  font?: string;
7
7
  fontSize?: string;
8
+ /**
9
+ * The color of the text inside the box. A text that sets no color of its own takes the nearest
10
+ * box's, and the text token when no box sets one. A divider or a barcode in the box keeps its own
11
+ * color.
12
+ */
13
+ color?: string;
8
14
  gap?: string;
9
15
  /**
10
16
  * Space between the edge of the box and its content, written like CSS: one value for all sides,
@@ -21,6 +27,21 @@ export interface ColumnAttr {
21
27
  background?: string;
22
28
  border?: string;
23
29
  radius?: string;
30
+ /**
31
+ * How opaque the box and everything in it is, from 0 to 1. The box is faded as one, so children
32
+ * that overlap do not show through each other, and a box inside a faded box is faded further: 0.5
33
+ * inside 0.5 is drawn at 0.25. A form field in the box is not faded. Default 1.
34
+ */
35
+ opacity?: string;
36
+ /**
37
+ * A hard-edged shadow: a copy of the box, moved right and down by the first two lengths (negative
38
+ * is left and up) and filled with the color, drawn under the box with the same radius. An opacity
39
+ * from 0 to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur.
40
+ * The shadow takes no room in the layout, so it can run into the margin or a neighbor, and the
41
+ * siblings after the box are drawn over it. A box with no background shows the shadow only
42
+ * outside it. The box's own opacity fades the box and its shadow together.
43
+ */
44
+ shadow?: string;
24
45
  /**
25
46
  * Where the box falls in the page flow. no: never split the box, and move it whole to the next
26
47
  * page when it does not fit. break-before: start it on a new page. break-after: start the next
@@ -49,6 +70,12 @@ export interface ColumnAttr {
49
70
  export interface RowAttr {
50
71
  font?: string;
51
72
  fontSize?: string;
73
+ /**
74
+ * The color of the text inside the box. A text that sets no color of its own takes the nearest
75
+ * box's, and the text token when no box sets one. A divider or a barcode in the box keeps its own
76
+ * color.
77
+ */
78
+ color?: string;
52
79
  gap?: string;
53
80
  /**
54
81
  * Space between the edge of the box and its content, written like CSS: one value for all sides,
@@ -65,6 +92,21 @@ export interface RowAttr {
65
92
  background?: string;
66
93
  border?: string;
67
94
  radius?: string;
95
+ /**
96
+ * How opaque the box and everything in it is, from 0 to 1. The box is faded as one, so children
97
+ * that overlap do not show through each other, and a box inside a faded box is faded further: 0.5
98
+ * inside 0.5 is drawn at 0.25. A form field in the box is not faded. Default 1.
99
+ */
100
+ opacity?: string;
101
+ /**
102
+ * A hard-edged shadow: a copy of the box, moved right and down by the first two lengths (negative
103
+ * is left and up) and filled with the color, drawn under the box with the same radius. An opacity
104
+ * from 0 to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur.
105
+ * The shadow takes no room in the layout, so it can run into the margin or a neighbor, and the
106
+ * siblings after the box are drawn over it. A box with no background shows the shadow only
107
+ * outside it. The box's own opacity fades the box and its shadow together.
108
+ */
109
+ shadow?: string;
68
110
  /**
69
111
  * Where the box falls in the page flow. no: never split the box, and move it whole to the next
70
112
  * page when it does not fit. break-before: start it on a new page. break-after: start the next
@@ -91,6 +133,12 @@ export interface RowAttr {
91
133
  export interface GridAttr {
92
134
  font?: string;
93
135
  fontSize?: string;
136
+ /**
137
+ * The color of the text inside the box. A text that sets no color of its own takes the nearest
138
+ * box's, and the text token when no box sets one. A divider or a barcode in the box keeps its own
139
+ * color.
140
+ */
141
+ color?: string;
94
142
  gap?: string;
95
143
  /**
96
144
  * Space between the edge of the box and its content, written like CSS: one value for all sides,
@@ -107,6 +155,21 @@ export interface GridAttr {
107
155
  background?: string;
108
156
  border?: string;
109
157
  radius?: string;
158
+ /**
159
+ * How opaque the box and everything in it is, from 0 to 1. The box is faded as one, so children
160
+ * that overlap do not show through each other, and a box inside a faded box is faded further: 0.5
161
+ * inside 0.5 is drawn at 0.25. A form field in the box is not faded. Default 1.
162
+ */
163
+ opacity?: string;
164
+ /**
165
+ * A hard-edged shadow: a copy of the box, moved right and down by the first two lengths (negative
166
+ * is left and up) and filled with the color, drawn under the box with the same radius. An opacity
167
+ * from 0 to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur.
168
+ * The shadow takes no room in the layout, so it can run into the margin or a neighbor, and the
169
+ * siblings after the box are drawn over it. A box with no background shows the shadow only
170
+ * outside it. The box's own opacity fades the box and its shadow together.
171
+ */
172
+ shadow?: string;
110
173
  /**
111
174
  * Where the box falls in the page flow. no: never split the box, and move it whole to the next
112
175
  * page when it does not fit. break-before: start it on a new page. break-after: start the next
@@ -133,6 +196,12 @@ export interface GridAttr {
133
196
  export interface FrameAttr {
134
197
  font?: string;
135
198
  fontSize?: string;
199
+ /**
200
+ * The color of the text inside the box. A text that sets no color of its own takes the nearest
201
+ * box's, and the text token when no box sets one. A divider or a barcode in the box keeps its own
202
+ * color.
203
+ */
204
+ color?: string;
136
205
  /**
137
206
  * Space between the edge of the box and its content, written like CSS: one value for all sides,
138
207
  * two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
@@ -148,6 +217,21 @@ export interface FrameAttr {
148
217
  background?: string;
149
218
  border?: string;
150
219
  radius?: string;
220
+ /**
221
+ * How opaque the box and everything in it is, from 0 to 1. The box is faded as one, so children
222
+ * that overlap do not show through each other, and a box inside a faded box is faded further: 0.5
223
+ * inside 0.5 is drawn at 0.25. A form field in the box is not faded. Default 1.
224
+ */
225
+ opacity?: string;
226
+ /**
227
+ * A hard-edged shadow: a copy of the box, moved right and down by the first two lengths (negative
228
+ * is left and up) and filled with the color, drawn under the box with the same radius. An opacity
229
+ * from 0 to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur.
230
+ * The shadow takes no room in the layout, so it can run into the margin or a neighbor, and the
231
+ * siblings after the box are drawn over it. A box with no background shows the shadow only
232
+ * outside it. The box's own opacity fades the box and its shadow together.
233
+ */
234
+ shadow?: string;
151
235
  /**
152
236
  * Where the box falls in the page flow. no: never split the box, and move it whole to the next
153
237
  * page when it does not fit. break-before: start it on a new page. break-after: start the next
@@ -287,6 +371,25 @@ export interface TextAttr {
287
371
  bold?: string;
288
372
  color?: string;
289
373
  align?: string;
374
+ /**
375
+ * The distance between lines, as a factor of the font size: a number above 0, such as 1.5, or a
376
+ * name from the line-height row of the tokens. Default 1.2, which is the token m.
377
+ */
378
+ lineHeight?: string;
379
+ /**
380
+ * The most lines drawn. Only whole lines are drawn, and the rest of the text is dropped. A text
381
+ * in the layout has no cap by default and wraps at the width it has; the lines it drops take no
382
+ * room, and a text that splits across pages keeps the cap across them. A text-at is one line by
383
+ * default, and above 1 needs a width to wrap within.
384
+ */
385
+ maxLines?: string;
386
+ /**
387
+ * End the last line drawn in an ellipsis when max-lines drops text, shortened to fit the width.
388
+ * Off by default: the text stops at the end of a line. A text-at also ends a line in one when it
389
+ * is cut off at its width. A text in the layout without max-lines is never cut, so there it has
390
+ * no effect.
391
+ */
392
+ ellipsis?: string;
290
393
  /**
291
394
  * Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
292
395
  * the other children, shared equally if several on the line use fill, and never moves to the next
@@ -306,6 +409,31 @@ export interface TextAttr {
306
409
  * where the lines fit.
307
410
  */
308
411
  orphans?: string;
412
+ /**
413
+ * Records the words of this text under a name as the pages are filled, so a text with capture-ref
414
+ * in a header or a footer can show them. Put it on a heading in the flow. The page that holds the
415
+ * text counts it, the words above it on that page included, and a text that splits across pages
416
+ * is recorded on the page where it starts. A text cannot have both capture and capture-ref.
417
+ */
418
+ capture?: string;
419
+ /**
420
+ * Shows what was captured under this name, as of the page the text is drawn on, in place of words
421
+ * of its own. Put it in a region. It takes the lines it may use, one unless max-lines says more,
422
+ * whatever it shows, so a header or a footer does not grow with its value; a longer value is cut,
423
+ * and ends in dots with ellipsis. On a page where nothing was captured it shows the latest value
424
+ * of an earlier page of the section, and capture-fallback before any.
425
+ */
426
+ captureRef?: string;
427
+ /**
428
+ * Which of the texts captured under the name on this page the text shows: the first or the last.
429
+ * Default last. Only for a text with capture-ref.
430
+ */
431
+ captureMode?: string;
432
+ /**
433
+ * What the text shows until something has been captured in the section. Default: nothing. Only
434
+ * for a text with capture-ref.
435
+ */
436
+ captureFallback?: string;
309
437
  paginate?: string;
310
438
  debug?: string;
311
439
  }
@@ -315,6 +443,12 @@ export interface TextAttr {
315
443
  export interface TdAttr {
316
444
  font?: string;
317
445
  fontSize?: string;
446
+ /**
447
+ * The color of the text inside the box. A text that sets no color of its own takes the nearest
448
+ * box's, and the text token when no box sets one. A divider or a barcode in the box keeps its own
449
+ * color.
450
+ */
451
+ color?: string;
318
452
  gap?: string;
319
453
  /**
320
454
  * Space between the edge of the box and its content, written like CSS: one value for all sides,
@@ -331,6 +465,21 @@ export interface TdAttr {
331
465
  background?: string;
332
466
  border?: string;
333
467
  radius?: string;
468
+ /**
469
+ * How opaque the box and everything in it is, from 0 to 1. The box is faded as one, so children
470
+ * that overlap do not show through each other, and a box inside a faded box is faded further: 0.5
471
+ * inside 0.5 is drawn at 0.25. A form field in the box is not faded. Default 1.
472
+ */
473
+ opacity?: string;
474
+ /**
475
+ * A hard-edged shadow: a copy of the box, moved right and down by the first two lengths (negative
476
+ * is left and up) and filled with the color, drawn under the box with the same radius. An opacity
477
+ * from 0 to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur.
478
+ * The shadow takes no room in the layout, so it can run into the margin or a neighbor, and the
479
+ * siblings after the box are drawn over it. A box with no background shows the shadow only
480
+ * outside it. The box's own opacity fades the box and its shadow together.
481
+ */
482
+ shadow?: string;
334
483
  /**
335
484
  * Where the box falls in the page flow. no: never split the box, and move it whole to the next
336
485
  * page when it does not fit. break-before: start it on a new page. break-after: start the next
@@ -429,8 +578,9 @@ export interface BookmarkAttr {
429
578
  }
430
579
  /**
431
580
  * Pins content to the top or bottom edge of pages, outside the normal flow, for headers and
432
- * footers. It reserves that space on every page it appears on. Only allowed directly inside layout,
433
- * and one per pin on a page.
581
+ * footers. It reserves that space on every page it appears on. Only allowed directly inside layout.
582
+ * Where it is written among the flow does not matter: pin chooses the edge, and regions on one edge
583
+ * stack in the order written.
434
584
  */
435
585
  export interface RegionAttr {
436
586
  /**
@@ -451,7 +601,8 @@ export interface RegionAttr {
451
601
  * flowing layout: watermarks, stamps, page furniture. Coordinates start at the top left corner of
452
602
  * the whole page, not inside the layout's margin, and y grows downward. A layer before the
453
603
  * section's layout paints under it, and one after paints over it. It sets what applies to all of
454
- * its content: which pages it appears on, opacity, transform and clip. Layers cannot be nested.
604
+ * its content: which pages it appears on, opacity, transform and clip, and the font, size and color
605
+ * of its text. Layers cannot be nested.
455
606
  */
456
607
  export interface LayerAttr {
457
608
  page?: string;
@@ -466,6 +617,19 @@ export interface LayerAttr {
466
617
  * corner of the page.
467
618
  */
468
619
  clip?: string;
620
+ /**
621
+ * The font of the text-at in the layer that sets none of its own. Defaults to the font of the
622
+ * document.
623
+ */
624
+ font?: string;
625
+ /**
626
+ * The size of the text-at in the layer that sets none of its own. Defaults to 11pt.
627
+ */
628
+ fontSize?: string;
629
+ /**
630
+ * The color of the text-at in the layer that sets none of its own. Defaults to the text token.
631
+ */
632
+ color?: string;
469
633
  }
470
634
  /**
471
635
  * Attributes of the `rect` element in a layer.
@@ -481,6 +645,13 @@ export interface RectAttr {
481
645
  stroke?: string;
482
646
  strokeWidth?: string;
483
647
  strokeDash?: string;
648
+ /**
649
+ * A hard-edged shadow: a copy of the shape, moved right and down by the first two lengths
650
+ * (negative is left and up) and filled with the color, drawn under the shape. An opacity from 0
651
+ * to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur. A shape
652
+ * with no fill shows the shadow only outside it.
653
+ */
654
+ shadow?: string;
484
655
  }
485
656
  /**
486
657
  * Attributes of the `circle` element in a layer.
@@ -504,6 +675,13 @@ export interface CircleAttr {
504
675
  stroke?: string;
505
676
  strokeWidth?: string;
506
677
  strokeDash?: string;
678
+ /**
679
+ * A hard-edged shadow: a copy of the shape, moved right and down by the first two lengths
680
+ * (negative is left and up) and filled with the color, drawn under the shape. An opacity from 0
681
+ * to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur. A shape
682
+ * with no fill shows the shadow only outside it.
683
+ */
684
+ shadow?: string;
507
685
  }
508
686
  /**
509
687
  * Attributes of the `ellipse` element in a layer.
@@ -528,6 +706,13 @@ export interface EllipseAttr {
528
706
  stroke?: string;
529
707
  strokeWidth?: string;
530
708
  strokeDash?: string;
709
+ /**
710
+ * A hard-edged shadow: a copy of the shape, moved right and down by the first two lengths
711
+ * (negative is left and up) and filled with the color, drawn under the shape. An opacity from 0
712
+ * to 1 after the color fades the shadow alone: "2pt 3pt #000000 0.2". There is no blur. A shape
713
+ * with no fill shows the shadow only outside it.
714
+ */
715
+ shadow?: string;
531
716
  }
532
717
  /**
533
718
  * Attributes of the `line` element in a layer.
@@ -577,24 +762,31 @@ export interface TextAtAttr {
577
762
  color?: string;
578
763
  align?: string;
579
764
  /**
580
- * Width of the box. Without it the text is one line of the width its characters need, and align
581
- * has no effect; a long text runs on past the edge of the page, which cuts it off, but stays in
582
- * the PDF. With it, a line past the width is cut off at it, or ends in an ellipsis with ellipsis,
583
- * and max-lines above 1 wraps the text within it.
765
+ * The distance between lines, as a factor of the font size: a number above 0, such as 1.5, or a
766
+ * name from the line-height row of the tokens. Default 1.2, which is the token m.
584
767
  */
585
- width?: string;
768
+ lineHeight?: string;
586
769
  /**
587
- * The most lines drawn, 1 by default. Above 1 it needs a width to wrap at, and wraps the text
588
- * within it; only whole lines are drawn, and the rest of the text is dropped.
770
+ * The most lines drawn. Only whole lines are drawn, and the rest of the text is dropped. A text
771
+ * in the layout has no cap by default and wraps at the width it has; the lines it drops take no
772
+ * room, and a text that splits across pages keeps the cap across them. A text-at is one line by
773
+ * default, and above 1 needs a width to wrap within.
589
774
  */
590
775
  maxLines?: string;
591
776
  /**
592
- * End the last line drawn in an ellipsis when the text does not fit its width and max-lines. Off
593
- * by default: the line is cut off at the width.
777
+ * End the last line drawn in an ellipsis when max-lines drops text, shortened to fit the width.
778
+ * Off by default: the text stops at the end of a line. A text-at also ends a line in one when it
779
+ * is cut off at its width. A text in the layout without max-lines is never cut, so there it has
780
+ * no effect.
594
781
  */
595
782
  ellipsis?: string;
596
- /** The distance between lines, as a factor of the font size. Default 1.2. */
597
- lineHeight?: string;
783
+ /**
784
+ * Width of the box. Without it the text is one line of the width its characters need, and align
785
+ * has no effect; a long text runs on past the edge of the page, which cuts it off, but stays in
786
+ * the PDF. With it, a line past the width is cut off at it, or ends in an ellipsis with ellipsis,
787
+ * and max-lines above 1 wraps the text within it.
788
+ */
789
+ width?: string;
598
790
  }
599
791
  /**
600
792
  * An image at a fixed place on the page. It needs width or height, and the other follows the
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { PdfEngine, LpdfRenderError } from './engine';
2
2
  export type { EncryptPermissions, EncryptOptions } from './engine';
3
3
  export type { RenderOptions, EngineOptions } from './_shared';
4
4
  export { FieldType, Pin, Orientation, SectionType, BuiltinFont, PageScope } from './constants';
5
- export type { PdfDocument, LpdfSectionNode, LpdfSectionChild, LpdfLayoutBlock, DocumentTokens, DocumentAssets, DocumentMeta, SectionAttr, DocumentAttr, } from './kit';
5
+ export type { PdfDocument, LpdfSectionNode, LpdfSectionChild, LpdfLayoutBlock, DocumentTokens, GradientToken, GradientStop, DocumentAssets, DocumentMeta, SectionAttr, DocumentAttr, } from './kit';
6
6
  export type { ColumnAttr, RowAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, BarcodeAttr, RegionAttr, FieldAttr, BookmarkAttr, LayerAttr, RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr, TextAtAttr, ImgAtAttr, BarcodeAtAttr, FontAttr, ImageAttr, LayoutAttr, } from './attrs';
7
7
  export type { LpdfNode, LpdfContainerNode, LpdfTextNode, LpdfSpanNode, LpdfDividerNode, LpdfImgNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, LpdfFieldNode, LpdfBookmarkNode, } from './layout';
8
8
  export { CanvasTransform } from './canvas';
package/dist/kit.d.ts CHANGED
@@ -22,14 +22,33 @@
22
22
  import type { LpdfBookmarkNode, LpdfNode } from './layout';
23
23
  import type { LpdfCanvasLayerNode } from './canvas';
24
24
  import type { FontAttr, ImageAttr, LayoutAttr } from './attrs';
25
+ /** One color of a gradient: `color` is hex or a color token, at an `offset` from `'0%'` to `'100%'`. */
26
+ export interface GradientStop {
27
+ offset: string;
28
+ color: string;
29
+ }
30
+ /**
31
+ * A gradient of the tokens, which a background or a fill uses as `gradient:name`. Give `from` and `to` for two
32
+ * colors, or `stops` for more. `angle` is the direction of a linear gradient in degrees: 0 runs top to bottom
33
+ * and 90 left to right. A radial gradient runs from the center of the box out to its farthest corner.
34
+ */
35
+ export interface GradientToken {
36
+ type: 'linear' | 'radial';
37
+ from?: string;
38
+ to?: string;
39
+ angle?: number | string;
40
+ stops?: GradientStop[];
41
+ }
25
42
  export interface DocumentTokens {
26
43
  colors?: Record<string, string>;
44
+ gradients?: Record<string, GradientToken>;
27
45
  space?: Record<string, string>;
28
46
  grid?: Record<string, string>;
29
47
  border?: Record<string, string>;
30
48
  radius?: Record<string, string>;
31
49
  width?: Record<string, string>;
32
50
  textSize?: Record<string, string>;
51
+ lineHeight?: Record<string, string>;
33
52
  }
34
53
  /**
35
54
  * The fonts and images the document declares, as the `assets` element of the XML does. A font or image
package/dist/kit.js CHANGED
@@ -42,8 +42,12 @@ function document(attrs, nodes = []) {
42
42
  if (assets !== undefined)
43
43
  attrsObj['assets'] = assets;
44
44
  if (tokens !== undefined) {
45
- const { textSize, ...rest } = tokens;
46
- attrsObj['tokens'] = textSize !== undefined ? { 'text-size': textSize, ...rest } : rest;
45
+ const { textSize, lineHeight, ...rest } = tokens;
46
+ attrsObj['tokens'] = {
47
+ ...rest,
48
+ ...(textSize !== undefined ? { 'text-size': textSize } : {}),
49
+ ...(lineHeight !== undefined ? { 'line-height': lineHeight } : {}),
50
+ };
47
51
  }
48
52
  if (meta !== undefined)
49
53
  attrsObj['meta'] = meta;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdfio/lpdf",
3
- "version": "0.27.0",
3
+ "version": "0.28.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",