@lpdfio/lpdf 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,12 @@ const doc = L.document({ size: 'letter' }, [
41
41
  engine.render(doc).then((pdf) => require('node:fs').writeFileSync('proposal.pdf', pdf))
42
42
  ```
43
43
 
44
+ An ES module or a TypeScript file imports the same names, and gets the same classes:
45
+
46
+ ```js
47
+ import { L, NoAttr } from '@lpdfio/lpdf'
48
+ ```
49
+
44
50
  ## Requirements
45
51
 
46
52
  - Node.js 20+
package/dist/L.d.ts CHANGED
@@ -43,10 +43,12 @@ export declare const L: Readonly<{
43
43
  thead: (attrs: import("./attrs").TheadAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTheadNode;
44
44
  tr: (attrs: import("./attrs").TrAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTrNode;
45
45
  td: (attrs: import("./attrs").TdAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfTdNode;
46
- text: (attrs: import("./attrs").TextAttr | null, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfTextNode;
46
+ text: (attrs: import("./attrs").TextAttr | null, nodes?: (string | import("./layout").LpdfSpanNode | import("./layout").LpdfFnNode)[]) => import("./layout").LpdfTextNode;
47
47
  span: (attrs: import("./attrs").SpanAttr | null, nodes?: string[]) => import("./layout").LpdfSpanNode;
48
+ fn: (attrs: null, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfFnNode;
48
49
  divider: (attrs?: import("./attrs").DividerAttr | null) => import("./layout").LpdfDividerNode;
49
50
  img: (attrs: import("./attrs").ImgAttr) => import("./layout").LpdfImgNode;
51
+ shape: (attrs: import("./attrs").ShapeAttr) => import("./layout").LpdfShapeNode;
50
52
  barcode: (attrs: import("./attrs").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
51
53
  region: (attrs: import("./attrs").RegionAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
52
54
  field: (attrs: import("./attrs").FieldAttr) => import("./layout").LpdfFieldNode;
package/dist/L.js CHANGED
@@ -53,8 +53,10 @@ exports.L = Object.freeze({
53
53
  td: layout_1.LpdfLayout.td,
54
54
  text: layout_1.LpdfLayout.text,
55
55
  span: layout_1.LpdfLayout.span,
56
+ fn: layout_1.LpdfLayout.fn,
56
57
  divider: layout_1.LpdfLayout.divider,
57
58
  img: layout_1.LpdfLayout.img,
59
+ shape: layout_1.LpdfLayout.shape,
58
60
  barcode: layout_1.LpdfLayout.barcode,
59
61
  region: layout_1.LpdfLayout.region,
60
62
  field: layout_1.LpdfLayout.field,
package/dist/attrs.d.ts CHANGED
@@ -19,9 +19,10 @@ export interface ColumnAttr {
19
19
  */
20
20
  padding?: string;
21
21
  /**
22
- * Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
23
- * left after its siblings (shared equally if several use fill); full takes all the height
24
- * available. Any of these stops the box splitting across pages.
22
+ * Height of the box. Leave it out to size to the content. A length, or a name from the height row
23
+ * of the tokens, fixes it; fill takes what is left after its siblings (shared equally if several
24
+ * use fill); full takes all the height available. Any of these stops the box splitting across
25
+ * pages.
25
26
  */
26
27
  height?: string;
27
28
  background?: string;
@@ -84,9 +85,10 @@ export interface RowAttr {
84
85
  */
85
86
  padding?: string;
86
87
  /**
87
- * Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
88
- * left after its siblings (shared equally if several use fill); full takes all the height
89
- * available. Any of these stops the box splitting across pages.
88
+ * Height of the box. Leave it out to size to the content. A length, or a name from the height row
89
+ * of the tokens, fixes it; fill takes what is left after its siblings (shared equally if several
90
+ * use fill); full takes all the height available. Any of these stops the box splitting across
91
+ * pages.
90
92
  */
91
93
  height?: string;
92
94
  background?: string;
@@ -147,9 +149,10 @@ export interface GridAttr {
147
149
  */
148
150
  padding?: string;
149
151
  /**
150
- * Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
151
- * left after its siblings (shared equally if several use fill); full takes all the height
152
- * available. Any of these stops the box splitting across pages.
152
+ * Height of the box. Leave it out to size to the content. A length, or a name from the height row
153
+ * of the tokens, fixes it; fill takes what is left after its siblings (shared equally if several
154
+ * use fill); full takes all the height available. Any of these stops the box splitting across
155
+ * pages.
153
156
  */
154
157
  height?: string;
155
158
  background?: string;
@@ -209,9 +212,10 @@ export interface FrameAttr {
209
212
  */
210
213
  padding?: string;
211
214
  /**
212
- * Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
213
- * left after its siblings (shared equally if several use fill); full takes all the height
214
- * available. Any of these stops the box splitting across pages.
215
+ * Height of the box. Leave it out to size to the content. A length, or a name from the height row
216
+ * of the tokens, fixes it; fill takes what is left after its siblings (shared equally if several
217
+ * use fill); full takes all the height available. Any of these stops the box splitting across
218
+ * pages.
215
219
  */
216
220
  height?: string;
217
221
  background?: string;
@@ -324,6 +328,38 @@ export interface ImgAttr {
324
328
  paginate?: string;
325
329
  debug?: string;
326
330
  }
331
+ /**
332
+ * A rectangle, a circle or an ellipse in the layout, for a status dot, a color swatch or a progress
333
+ * bar. It takes its box in the flow as an image does, with no children, and is drawn centered in
334
+ * that box, which the parent's align places. A rect and an ellipse need a width and a height, and a
335
+ * circle an r. A shape with no fill and no stroke draws nothing, but keeps its box. A stroke is
336
+ * centered on the edge of the box, so half of it lies outside. To put a shape at a place on the
337
+ * page, use a rect, circle or ellipse in a layer.
338
+ */
339
+ export interface ShapeAttr {
340
+ type: string;
341
+ /**
342
+ * Width of a rect or an ellipse, a length or a name from the width row of the tokens. A circle
343
+ * takes r instead.
344
+ */
345
+ width?: string;
346
+ /**
347
+ * Height of a rect or an ellipse, a length or a name from the height row of the tokens. A circle
348
+ * takes r instead.
349
+ */
350
+ height?: string;
351
+ /** Radius of a circle. Its box is the square of side 2r. */
352
+ r?: string;
353
+ /** Rounding of the corners of a rect. A circle and an ellipse are round already. */
354
+ radius?: string;
355
+ fill?: string;
356
+ stroke?: string;
357
+ strokeWidth?: string;
358
+ strokeDash?: string;
359
+ /** How opaque the shape is, from 0 to 1. Default 1. */
360
+ opacity?: string;
361
+ debug?: string;
362
+ }
327
363
  /**
328
364
  * A QR code, a Code 128 or an EAN-13. It is never stretched. With only a width or a height, the
329
365
  * other follows the barcode's proportions. With both, they are a maximum: the barcode takes the
@@ -334,13 +370,14 @@ export interface BarcodeAttr {
334
370
  type: string;
335
371
  data: string;
336
372
  /**
337
- * Height of the whole barcode, with the digits of hrt inside it: they take the bottom 12pt and
338
- * the bars the rest. A barcode is never stretched. With only a height, the width follows the
339
- * barcode's proportions. With both width and height, they are a maximum: the barcode takes the
340
- * largest size that fits in them, and its box becomes that size. A QR code is square, so it takes
341
- * the smaller of the two. Without a size, a code128 is as wide as its bars at 1pt per module and
342
- * its bars are 40pt high, and an ean13 is the standard symbol, 0.33mm per module and bars 22.85mm
343
- * high. The digits of hrt add 12pt to either.
373
+ * Height of the whole barcode, a length or a name from the height row of the tokens, with the
374
+ * digits of hrt inside it: they take the bottom 12pt and the bars the rest. A barcode is never
375
+ * stretched. With only a height, the width follows the barcode's proportions. With both width and
376
+ * height, they are a maximum: the barcode takes the largest size that fits in them, and its box
377
+ * becomes that size. A QR code is square, so it takes the smaller of the two. Without a size, a
378
+ * code128 is as wide as its bars at 1pt per module and its bars are 40pt high, and an ean13 is
379
+ * the standard symbol, 0.33mm per module and bars 22.85mm high. The digits of hrt add 12pt to
380
+ * either.
344
381
  */
345
382
  height?: string;
346
383
  ec?: string;
@@ -357,8 +394,8 @@ export interface BarcodeAttr {
357
394
  debug?: string;
358
395
  }
359
396
  /**
360
- * A block of wrapping text. Use span children to style parts of it. Splits across pages between
361
- * lines.
397
+ * A block of wrapping text. Use span children to style parts of it, and fn children for footnotes.
398
+ * Splits across pages between lines.
362
399
  */
363
400
  export interface TextAttr {
364
401
  fontSize?: string;
@@ -457,9 +494,10 @@ export interface TdAttr {
457
494
  */
458
495
  padding?: string;
459
496
  /**
460
- * Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
461
- * left after its siblings (shared equally if several use fill); full takes all the height
462
- * available. Any of these stops the box splitting across pages.
497
+ * Height of the box. Leave it out to size to the content. A length, or a name from the height row
498
+ * of the tokens, fixes it; fill takes what is left after its siblings (shared equally if several
499
+ * use fill); full takes all the height available. Any of these stops the box splitting across
500
+ * pages.
463
501
  */
464
502
  height?: string;
465
503
  background?: string;
@@ -490,6 +528,24 @@ export interface TdAttr {
490
528
  */
491
529
  paginate?: string;
492
530
  debug?: string;
531
+ /**
532
+ * How many of the table's columns the cell spans. It is as wide as those columns and the gaps
533
+ * between them, and the cells after it in the row start at the column after its last. A row whose
534
+ * cells span more columns than the table's cols names is an error; a row with fewer leaves its
535
+ * last columns empty. It changes widths only: row heights and page breaks work as before. Default
536
+ * 1.
537
+ */
538
+ colspan?: string;
539
+ /**
540
+ * How many rows the cell spans, its own included. It is as tall as those rows and the gaps
541
+ * between them, and the rows under it leave its columns out: their cells start at the first free
542
+ * columns. If the cell's content is taller than the rows are together, the last of them grows by
543
+ * the difference. A row with a cell too many for the free columns, and a span that runs past the
544
+ * last row of the table, are errors; a thead is one row and takes no rowspan. The rows a cell
545
+ * spans stay on one page: the group moves to the next page whole when it does not fit, and one
546
+ * taller than a page is clipped at the page's end. Default 1.
547
+ */
548
+ rowspan?: string;
493
549
  align?: string;
494
550
  valign?: string;
495
551
  }
@@ -503,6 +559,14 @@ export interface TheadAttr {
503
559
  * Attributes of the `tr` element.
504
560
  */
505
561
  export interface TrAttr {
562
+ /**
563
+ * with-next keeps the row on the same page as the row after it. A run of rows that each say
564
+ * with-next, and the row that ends it, move to the next page together when a page break would
565
+ * fall inside them. A run taller than a page breaks where its rows fit, as if it had no keep.
566
+ * Rows are never split, and a header is never left alone at the bottom of a page, with or without
567
+ * this.
568
+ */
569
+ keep?: string;
506
570
  background?: string;
507
571
  }
508
572
  /**
package/dist/browser.js CHANGED
@@ -413,6 +413,11 @@ var Orientation = {
413
413
  var SectionType = {
414
414
  Toc: "toc"
415
415
  };
416
+ var FootnoteCounter = {
417
+ Page: "page",
418
+ Section: "section",
419
+ Document: "document"
420
+ };
416
421
  var BuiltinFont = {
417
422
  Courier: "Courier",
418
423
  CourierBold: "Courier-Bold",
@@ -490,6 +495,7 @@ async function initLpdf(wasmSource, licenseKey = "") {
490
495
  export {
491
496
  BuiltinFont,
492
497
  FieldType,
498
+ FootnoteCounter,
493
499
  NoAttr,
494
500
  Orientation,
495
501
  PageScope,
@@ -26,6 +26,13 @@ export declare const SectionType: {
26
26
  readonly Toc: "toc";
27
27
  };
28
28
  export type SectionType = (typeof SectionType)[keyof typeof SectionType];
29
+ /** The values of the `footnote-counter` attribute of a document or a section. */
30
+ export declare const FootnoteCounter: {
31
+ readonly Page: "page";
32
+ readonly Section: "section";
33
+ readonly Document: "document";
34
+ };
35
+ export type FootnoteCounter = (typeof FootnoteCounter)[keyof typeof FootnoteCounter];
29
36
  /** The values of the `core` attribute of a font: the built-in PDF fonts, which need no file. */
30
37
  export declare const BuiltinFont: {
31
38
  readonly Courier: "Courier";
package/dist/constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Generated from lpdf.xsd by scripts/gen-sdk-api.mjs.
3
3
  // Do not edit: change the schema and run `make gen-sdk-api`.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.PageScope = exports.BuiltinFont = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = void 0;
5
+ exports.PageScope = exports.BuiltinFont = exports.FootnoteCounter = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = void 0;
6
6
  /** The values of the `type` attribute of a field. */
7
7
  exports.FieldType = {
8
8
  Text: 'text',
@@ -27,6 +27,12 @@ exports.Orientation = {
27
27
  exports.SectionType = {
28
28
  Toc: 'toc',
29
29
  };
30
+ /** The values of the `footnote-counter` attribute of a document or a section. */
31
+ exports.FootnoteCounter = {
32
+ Page: 'page',
33
+ Section: 'section',
34
+ Document: 'document',
35
+ };
30
36
  /** The values of the `core` attribute of a font: the built-in PDF fonts, which need no file. */
31
37
  exports.BuiltinFont = {
32
38
  Courier: 'Courier',
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export { PdfEngine, LpdfRenderError } from './engine';
2
2
  export type { EncryptPermissions, EncryptOptions } from './engine';
3
3
  export type { RenderOptions, EngineOptions } from './_shared';
4
- export { FieldType, Pin, Orientation, SectionType, BuiltinFont, PageScope } from './constants';
4
+ export { FieldType, Pin, Orientation, SectionType, FootnoteCounter, BuiltinFont, PageScope } from './constants';
5
5
  export type { PdfDocument, LpdfSectionNode, LpdfSectionChild, LpdfLayoutBlock, DocumentTokens, GradientToken, GradientStop, DocumentAssets, DocumentMeta, SectionAttr, DocumentAttr, } from './kit';
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
- export type { LpdfNode, LpdfContainerNode, LpdfTextNode, LpdfSpanNode, LpdfDividerNode, LpdfImgNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, LpdfFieldNode, LpdfBookmarkNode, } from './layout';
6
+ export type { ColumnAttr, RowAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, ShapeAttr, BarcodeAttr, RegionAttr, FieldAttr, BookmarkAttr, LayerAttr, RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr, TextAtAttr, ImgAtAttr, BarcodeAtAttr, FontAttr, ImageAttr, LayoutAttr, } from './attrs';
7
+ export type { LpdfNode, LpdfContainerNode, LpdfTextNode, LpdfSpanNode, LpdfFnNode, LpdfDividerNode, LpdfImgNode, LpdfShapeNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, LpdfFieldNode, LpdfBookmarkNode, } from './layout';
8
8
  export { CanvasTransform } from './canvas';
9
9
  export type { LpdfCanvasLayerNode, LpdfCanvasPrimitiveNode, LpdfCanvasRectNode, LpdfCanvasLineNode, LpdfCanvasEllipseNode, LpdfCanvasCircleNode, LpdfCanvasPathNode, LpdfCanvasTextAtNode, LpdfCanvasImgAtNode, LpdfCanvasBarcodeAtNode, } from './canvas';
10
10
  export { L, NoAttr } from './L';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoAttr = exports.L = exports.CanvasTransform = exports.PageScope = exports.BuiltinFont = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = exports.LpdfRenderError = exports.PdfEngine = void 0;
3
+ exports.NoAttr = exports.L = exports.CanvasTransform = exports.PageScope = exports.BuiltinFont = exports.FootnoteCounter = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = exports.LpdfRenderError = exports.PdfEngine = void 0;
4
4
  // ── Engine ────────────────────────────────────────────────────────────────────
5
5
  var engine_1 = require("./engine");
6
6
  Object.defineProperty(exports, "PdfEngine", { enumerable: true, get: function () { return engine_1.PdfEngine; } });
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "FieldType", { enumerable: true, get: function ()
11
11
  Object.defineProperty(exports, "Pin", { enumerable: true, get: function () { return constants_1.Pin; } });
12
12
  Object.defineProperty(exports, "Orientation", { enumerable: true, get: function () { return constants_1.Orientation; } });
13
13
  Object.defineProperty(exports, "SectionType", { enumerable: true, get: function () { return constants_1.SectionType; } });
14
+ Object.defineProperty(exports, "FootnoteCounter", { enumerable: true, get: function () { return constants_1.FootnoteCounter; } });
14
15
  Object.defineProperty(exports, "BuiltinFont", { enumerable: true, get: function () { return constants_1.BuiltinFont; } });
15
16
  Object.defineProperty(exports, "PageScope", { enumerable: true, get: function () { return constants_1.PageScope; } });
16
17
  // ── Layer types ───────────────────────────────────────────────────────────────
package/dist/kit.d.ts CHANGED
@@ -42,11 +42,19 @@ export interface GradientToken {
42
42
  export interface DocumentTokens {
43
43
  colors?: Record<string, string>;
44
44
  gradients?: Record<string, GradientToken>;
45
+ /**
46
+ * Names for the slots of the scale, each to the slot it stands for: `{ caption: 'xs' }` lets `fontSize: 'caption'`
47
+ * mean the text size `xs`, and `gap: 'caption'` the space `xs`. A name is lowercase letters, digits and `-`,
48
+ * starting with a letter, and is neither a slot nor `fill` or `full`.
49
+ */
50
+ aliases?: Record<string, string>;
45
51
  space?: Record<string, string>;
46
52
  grid?: Record<string, string>;
47
53
  border?: Record<string, string>;
48
54
  radius?: Record<string, string>;
49
55
  width?: Record<string, string>;
56
+ /** The heights `height` names: `{ xs: '16pt', s: '24pt', m: '32pt', l: '48pt', xl: '64pt', xxl: '96pt' }` by default. */
57
+ height?: Record<string, string>;
50
58
  textSize?: Record<string, string>;
51
59
  lineHeight?: Record<string, string>;
52
60
  }
@@ -73,6 +81,7 @@ export interface SectionAttr {
73
81
  debug?: string;
74
82
  type?: string;
75
83
  tocIndentStep?: string;
84
+ footnoteCounter?: string;
76
85
  }
77
86
  export interface DocumentAttr {
78
87
  size?: string;
@@ -83,6 +92,7 @@ export interface DocumentAttr {
83
92
  tokens?: DocumentTokens;
84
93
  meta?: DocumentMeta;
85
94
  debug?: string;
95
+ footnoteCounter?: string;
86
96
  }
87
97
  /** A layout block — wraps an ordered list of layout nodes. */
88
98
  export interface LpdfLayoutBlock {
package/dist/layout.d.ts CHANGED
@@ -1,9 +1,15 @@
1
- import type { ColumnAttr, RowAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, BarcodeAttr, FieldAttr, RegionAttr, BookmarkAttr } from './attrs';
1
+ import type { ColumnAttr, RowAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, ShapeAttr, BarcodeAttr, FieldAttr, RegionAttr, BookmarkAttr } from './attrs';
2
2
  export interface LpdfSpanNode {
3
3
  type: 'span';
4
4
  attrs: Record<string, string>;
5
5
  nodes: string[];
6
6
  }
7
+ /** A footnote: its words go at the bottom of the page where its number lands. */
8
+ export interface LpdfFnNode {
9
+ type: 'fn';
10
+ attrs: Record<string, string>;
11
+ nodes: (string | LpdfSpanNode)[];
12
+ }
7
13
  export interface LpdfContainerNode {
8
14
  type: 'column' | 'row' | 'grid' | 'frame' | 'link';
9
15
  attrs: Record<string, string>;
@@ -12,7 +18,7 @@ export interface LpdfContainerNode {
12
18
  export interface LpdfTextNode {
13
19
  type: 'text';
14
20
  attrs: Record<string, string>;
15
- nodes: (string | LpdfSpanNode)[];
21
+ nodes: (string | LpdfSpanNode | LpdfFnNode)[];
16
22
  }
17
23
  export interface LpdfDividerNode {
18
24
  type: 'divider';
@@ -22,6 +28,10 @@ export interface LpdfImgNode {
22
28
  type: 'img';
23
29
  attrs: Record<string, string>;
24
30
  }
31
+ export interface LpdfShapeNode {
32
+ type: 'shape';
33
+ attrs: Record<string, string>;
34
+ }
25
35
  export interface LpdfBarcodeNode {
26
36
  type: 'barcode';
27
37
  attrs: Record<string, string>;
@@ -60,7 +70,7 @@ export interface LpdfBookmarkNode {
60
70
  type: 'bookmark';
61
71
  attrs: Record<string, string>;
62
72
  }
63
- export type LpdfNode = LpdfContainerNode | LpdfTextNode | LpdfDividerNode | LpdfTableNode | LpdfImgNode | LpdfBarcodeNode | LpdfRegionNode | LpdfFieldNode | LpdfBookmarkNode;
73
+ export type LpdfNode = LpdfContainerNode | LpdfTextNode | LpdfDividerNode | LpdfTableNode | LpdfImgNode | LpdfShapeNode | LpdfBarcodeNode | LpdfRegionNode | LpdfFieldNode | LpdfBookmarkNode;
64
74
  declare function column(attrs: ColumnAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
65
75
  declare function row(attrs: RowAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
66
76
  declare function grid(attrs: GridAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
@@ -70,10 +80,18 @@ declare function table(attrs: TableAttr, nodes?: (LpdfTheadNode | LpdfTrNode)[])
70
80
  declare function thead(attrs: TheadAttr | null, nodes?: LpdfTdNode[]): LpdfTheadNode;
71
81
  declare function tr(attrs: TrAttr | null, nodes?: LpdfTdNode[]): LpdfTrNode;
72
82
  declare function td(attrs: TdAttr | null, nodes?: LpdfNode[]): LpdfTdNode;
73
- declare function text(attrs: TextAttr | null, nodes?: (string | LpdfSpanNode)[]): LpdfTextNode;
83
+ declare function text(attrs: TextAttr | null, nodes?: (string | LpdfSpanNode | LpdfFnNode)[]): LpdfTextNode;
74
84
  declare function span(attrs: SpanAttr | null, nodes?: string[]): LpdfSpanNode;
85
+ /**
86
+ * A footnote, in the nodes of a text. The engine numbers it and puts a small raised number at its place in the
87
+ * text; its words go at the bottom of the page where that number lands. It has no attributes: pass `NoAttr`.
88
+ * The words are strings and spans.
89
+ */
90
+ declare function fn(attrs: null, nodes?: (string | LpdfSpanNode)[]): LpdfFnNode;
75
91
  declare function divider(attrs?: DividerAttr | null): LpdfDividerNode;
76
92
  declare function img(attrs: ImgAttr): LpdfImgNode;
93
+ /** A rect, circle or ellipse that takes its box in the layout, as an image does. */
94
+ declare function shape(attrs: ShapeAttr): LpdfShapeNode;
77
95
  declare function barcode(attrs: BarcodeAttr): LpdfBarcodeNode;
78
96
  declare function region(attrs: RegionAttr, nodes?: LpdfNode[]): LpdfRegionNode;
79
97
  declare function field(attrs: FieldAttr): LpdfFieldNode;
@@ -90,8 +108,10 @@ export declare const LpdfLayout: Readonly<{
90
108
  link: typeof link;
91
109
  text: typeof text;
92
110
  span: typeof span;
111
+ fn: typeof fn;
93
112
  divider: typeof divider;
94
113
  img: typeof img;
114
+ shape: typeof shape;
95
115
  barcode: typeof barcode;
96
116
  table: typeof table;
97
117
  thead: typeof thead;
package/dist/layout.js CHANGED
@@ -40,12 +40,24 @@ function text(attrs, nodes = []) {
40
40
  function span(attrs, nodes = []) {
41
41
  return { type: 'span', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
42
42
  }
43
+ /**
44
+ * A footnote, in the nodes of a text. The engine numbers it and puts a small raised number at its place in the
45
+ * text; its words go at the bottom of the page where that number lands. It has no attributes: pass `NoAttr`.
46
+ * The words are strings and spans.
47
+ */
48
+ function fn(attrs, nodes = []) {
49
+ return { type: 'fn', attrs: {}, nodes };
50
+ }
43
51
  function divider(attrs = null) {
44
52
  return { type: 'divider', attrs: (0, _shared_1.buildAttrs)(attrs) };
45
53
  }
46
54
  function img(attrs) {
47
55
  return { type: 'img', attrs: (0, _shared_1.buildAttrs)(attrs) };
48
56
  }
57
+ /** A rect, circle or ellipse that takes its box in the layout, as an image does. */
58
+ function shape(attrs) {
59
+ return { type: 'shape', attrs: (0, _shared_1.buildAttrs)(attrs) };
60
+ }
49
61
  function barcode(attrs) {
50
62
  return { type: 'barcode', attrs: (0, _shared_1.buildAttrs)(attrs) };
51
63
  }
@@ -70,8 +82,10 @@ exports.LpdfLayout = Object.freeze({
70
82
  link,
71
83
  text,
72
84
  span,
85
+ fn,
73
86
  divider,
74
87
  img,
88
+ shape,
75
89
  barcode,
76
90
  table,
77
91
  thead,
Binary file
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@lpdfio/lpdf",
3
- "version": "0.28.0",
3
+ "version": "0.29.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",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/index.d.ts",
9
10
  "require": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
+ "default": "./dist/index.js"
11
12
  },
12
13
  "./browser": {
13
14
  "import": "./dist/browser.js",
@@ -18,7 +19,7 @@
18
19
  "build": "tsc && node build-browser.mjs && node -e \"require('node:fs').cpSync('./wasm', './dist/wasm', {recursive:true})\"",
19
20
  "build:node": "tsc",
20
21
  "build:browser": "node build-browser.mjs",
21
- "test": "node --test test/render.test.mjs"
22
+ "test": "node --test test/render.test.mjs test/package-entry.test.mjs"
22
23
  },
23
24
  "author": "lpdf.io",
24
25
  "homepage": "https://lpdf.io",