@lpdfio/lpdf 0.25.0 → 0.27.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 +6 -6
- package/dist/L.d.ts +8 -10
- package/dist/L.js +5 -7
- package/dist/attrs.d.ts +203 -114
- package/dist/browser.js +1 -1
- package/dist/canvas.d.ts +14 -8
- package/dist/canvas.js +6 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/kit.d.ts +22 -29
- package/dist/kit.js +14 -22
- package/dist/layout.d.ts +6 -10
- package/dist/layout.js +6 -14
- package/dist/wasm/lpdf-web.js +1 -1
- package/dist/wasm/lpdf.js +1 -1
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,19 +19,19 @@ const { L, NoAttr } = require('@lpdfio/lpdf')
|
|
|
19
19
|
|
|
20
20
|
const engine = L.engine()
|
|
21
21
|
|
|
22
|
-
const doc = L.document({ size: 'letter'
|
|
22
|
+
const doc = L.document({ size: 'letter' }, [
|
|
23
23
|
L.section(NoAttr, [
|
|
24
|
-
L.layout(
|
|
25
|
-
L.
|
|
26
|
-
L.
|
|
24
|
+
L.layout({ margin: '48pt' }, [
|
|
25
|
+
L.column({ gap: '24pt' }, [
|
|
26
|
+
L.row({ justify: 'between' }, [
|
|
27
27
|
L.text({ fontSize: '8pt', color: '#888888' }, ['ACME CORP']),
|
|
28
28
|
L.text({ fontSize: '22pt', bold: 'true' }, ['Project Proposal']),
|
|
29
29
|
]),
|
|
30
30
|
L.divider({ thickness: 'xs' }),
|
|
31
31
|
L.text({ fontSize: '13pt', bold: 'true' }, ['Scope of Work']),
|
|
32
|
-
L.
|
|
32
|
+
L.row({ gap: '12pt', align: 'start' }, [
|
|
33
33
|
L.text({ color: '#888888', width: '24pt' }, ['01']),
|
|
34
|
-
L.text(
|
|
34
|
+
L.text({ width: 'fill' }, ['Discovery & Research']),
|
|
35
35
|
]),
|
|
36
36
|
]),
|
|
37
37
|
]),
|
package/dist/L.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const NoAttr: null;
|
|
|
5
5
|
/**
|
|
6
6
|
* Unified lpdf facade.
|
|
7
7
|
*
|
|
8
|
-
* All document, layout, and
|
|
8
|
+
* All document, layout, and layer factory methods are available as flat
|
|
9
9
|
* properties on this object. Construction-time configuration is handled via
|
|
10
10
|
* `L.engine()`.
|
|
11
11
|
*
|
|
@@ -30,15 +30,12 @@ export declare const L: Readonly<{
|
|
|
30
30
|
/** Convert a `PdfDocument` tree to an lpdf XML string. */
|
|
31
31
|
toXml: (doc: PdfDocument) => string;
|
|
32
32
|
document: (attrs: import("./kit").DocumentAttr | null, nodes?: import("./kit").LpdfSectionNode[]) => PdfDocument;
|
|
33
|
-
section: (attrs: import("./kit").SectionAttr | null, nodes?:
|
|
34
|
-
layout: (
|
|
35
|
-
canvas: (_attrs: null, layers?: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
|
|
33
|
+
section: (attrs: import("./kit").SectionAttr | null, nodes?: import("./kit").LpdfSectionChild[]) => import("./kit").LpdfSectionNode;
|
|
34
|
+
layout: (attrs: import("./attrs").LayoutAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
|
|
36
35
|
assets: (attrs: DocumentAssets) => DocumentAssets;
|
|
37
36
|
tokens: (attrs: DocumentTokens) => DocumentTokens;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
split: (attrs: import("./attrs").SplitAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
41
|
-
cluster: (attrs: import("./attrs").ClusterAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
37
|
+
column: (attrs: import("./attrs").ColumnAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
38
|
+
row: (attrs: import("./attrs").RowAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
42
39
|
grid: (attrs: import("./attrs").GridAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
43
40
|
frame: (attrs: import("./attrs").FrameAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
44
41
|
link: (attrs: import("./attrs").LinkAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
@@ -60,6 +57,7 @@ export declare const L: Readonly<{
|
|
|
60
57
|
ellipse: (attrs: import("./attrs").EllipseAttr) => import("./canvas").LpdfCanvasEllipseNode;
|
|
61
58
|
circle: (attrs: import("./attrs").CircleAttr) => import("./canvas").LpdfCanvasCircleNode;
|
|
62
59
|
path: (attrs: import("./attrs").PathAttr) => import("./canvas").LpdfCanvasPathNode;
|
|
63
|
-
textAt: (attrs: import("./attrs").
|
|
64
|
-
imgAt: (attrs: import("./attrs").
|
|
60
|
+
textAt: (attrs: import("./attrs").TextAtAttr, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./canvas").LpdfCanvasTextAtNode;
|
|
61
|
+
imgAt: (attrs: import("./attrs").ImgAtAttr) => import("./canvas").LpdfCanvasImgAtNode;
|
|
62
|
+
barcodeAt: (attrs: import("./attrs").BarcodeAtAttr) => import("./canvas").LpdfCanvasBarcodeAtNode;
|
|
65
63
|
}>;
|
package/dist/L.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.NoAttr = null;
|
|
|
11
11
|
/**
|
|
12
12
|
* Unified lpdf facade.
|
|
13
13
|
*
|
|
14
|
-
* All document, layout, and
|
|
14
|
+
* All document, layout, and layer factory methods are available as flat
|
|
15
15
|
* properties on this object. Construction-time configuration is handled via
|
|
16
16
|
* `L.engine()`.
|
|
17
17
|
*
|
|
@@ -39,14 +39,11 @@ exports.L = Object.freeze({
|
|
|
39
39
|
document: kit_1.LpdfKit.document,
|
|
40
40
|
section: kit_1.LpdfKit.section,
|
|
41
41
|
layout: kit_1.LpdfKit.layout,
|
|
42
|
-
canvas: kit_1.LpdfKit.canvas,
|
|
43
42
|
assets: (attrs) => attrs,
|
|
44
43
|
tokens: (attrs) => attrs,
|
|
45
44
|
// ── Layout ────────────────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
split: layout_1.LpdfLayout.split,
|
|
49
|
-
cluster: layout_1.LpdfLayout.cluster,
|
|
45
|
+
column: layout_1.LpdfLayout.column,
|
|
46
|
+
row: layout_1.LpdfLayout.row,
|
|
50
47
|
grid: layout_1.LpdfLayout.grid,
|
|
51
48
|
frame: layout_1.LpdfLayout.frame,
|
|
52
49
|
link: layout_1.LpdfLayout.link,
|
|
@@ -62,7 +59,7 @@ exports.L = Object.freeze({
|
|
|
62
59
|
region: layout_1.LpdfLayout.region,
|
|
63
60
|
field: layout_1.LpdfLayout.field,
|
|
64
61
|
bookmark: layout_1.LpdfLayout.bookmark,
|
|
65
|
-
// ──
|
|
62
|
+
// ── Layers ────────────────────────────────────────────────────────────────
|
|
66
63
|
layer: canvas_1.LpdfCanvas.layer,
|
|
67
64
|
rect: canvas_1.LpdfCanvas.rect,
|
|
68
65
|
line: canvas_1.LpdfCanvas.line,
|
|
@@ -71,4 +68,5 @@ exports.L = Object.freeze({
|
|
|
71
68
|
path: canvas_1.LpdfCanvas.path,
|
|
72
69
|
textAt: canvas_1.LpdfCanvas.textAt,
|
|
73
70
|
imgAt: canvas_1.LpdfCanvas.imgAt,
|
|
71
|
+
barcodeAt: canvas_1.LpdfCanvas.barcodeAt,
|
|
74
72
|
});
|
package/dist/attrs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Places children top to bottom, each at the full width, with gap between them. Can split across
|
|
3
3
|
* pages between children.
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface ColumnAttr {
|
|
6
6
|
font?: string;
|
|
7
7
|
fontSize?: string;
|
|
8
8
|
gap?: string;
|
|
@@ -33,55 +33,20 @@ export interface StackAttr {
|
|
|
33
33
|
debug?: string;
|
|
34
34
|
align?: string;
|
|
35
35
|
justify?: string;
|
|
36
|
-
width?: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* One row where the children keep their own width except one, which fills the rest. By default the
|
|
40
|
-
* last child fills; set end to true and the first fills. Never splits across pages.
|
|
41
|
-
*/
|
|
42
|
-
export interface FlankAttr {
|
|
43
|
-
font?: string;
|
|
44
|
-
fontSize?: string;
|
|
45
|
-
gap?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
48
|
-
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
49
|
-
* bottom and left.
|
|
50
|
-
*/
|
|
51
|
-
padding?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
54
|
-
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
55
|
-
* available. Any of these stops the box splitting across pages.
|
|
56
|
-
*/
|
|
57
|
-
height?: string;
|
|
58
|
-
background?: string;
|
|
59
|
-
border?: string;
|
|
60
|
-
radius?: string;
|
|
61
36
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* both to the next page if that sibling would not fit. break-before, break-after and keep-next
|
|
66
|
-
* take effect on the children of layout; on a box inside another box they are not applied. no
|
|
67
|
-
* applies at any depth.
|
|
37
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
38
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
39
|
+
* line; in a column it takes the full width.
|
|
68
40
|
*/
|
|
69
|
-
paginate?: string;
|
|
70
|
-
debug?: string;
|
|
71
|
-
align?: string;
|
|
72
|
-
/**
|
|
73
|
-
* false (the default): every child but the last keeps its own width at the left, and the last
|
|
74
|
-
* fills the rest. true: the first child fills, and the others keep their own width at the right.
|
|
75
|
-
*/
|
|
76
|
-
end?: string;
|
|
77
41
|
width?: string;
|
|
78
42
|
}
|
|
79
43
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
44
|
+
* Children side by side, continuing on the next line when they run out of width. A child with width
|
|
45
|
+
* set to fill takes what its line leaves; justify set to between puts a line's first child at the
|
|
46
|
+
* left edge, its last at the right and the others evenly between. Splits across pages between
|
|
47
|
+
* lines.
|
|
83
48
|
*/
|
|
84
|
-
export interface
|
|
49
|
+
export interface RowAttr {
|
|
85
50
|
font?: string;
|
|
86
51
|
fontSize?: string;
|
|
87
52
|
gap?: string;
|
|
@@ -111,48 +76,12 @@ export interface SplitAttr {
|
|
|
111
76
|
paginate?: string;
|
|
112
77
|
debug?: string;
|
|
113
78
|
align?: string;
|
|
79
|
+
justify?: string;
|
|
114
80
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
equal?: string;
|
|
119
|
-
width?: string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* A row that wraps: children sit side by side, and continue on the next line when they run out of
|
|
123
|
-
* width. Splits across pages between lines.
|
|
124
|
-
*/
|
|
125
|
-
export interface ClusterAttr {
|
|
126
|
-
font?: string;
|
|
127
|
-
fontSize?: string;
|
|
128
|
-
gap?: string;
|
|
129
|
-
/**
|
|
130
|
-
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
131
|
-
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
132
|
-
* bottom and left.
|
|
133
|
-
*/
|
|
134
|
-
padding?: string;
|
|
135
|
-
/**
|
|
136
|
-
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
137
|
-
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
138
|
-
* available. Any of these stops the box splitting across pages.
|
|
139
|
-
*/
|
|
140
|
-
height?: string;
|
|
141
|
-
background?: string;
|
|
142
|
-
border?: string;
|
|
143
|
-
radius?: string;
|
|
144
|
-
/**
|
|
145
|
-
* Where the box falls in the page flow. no: never split the box, and move it whole to the next
|
|
146
|
-
* page when it does not fit. break-before: start it on a new page. break-after: start the next
|
|
147
|
-
* sibling on a new page. keep-next: keep it on one page with the sibling that follows, moving
|
|
148
|
-
* both to the next page if that sibling would not fit. break-before, break-after and keep-next
|
|
149
|
-
* take effect on the children of layout; on a box inside another box they are not applied. no
|
|
150
|
-
* applies at any depth.
|
|
81
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
82
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
83
|
+
* line; in a column it takes the full width.
|
|
151
84
|
*/
|
|
152
|
-
paginate?: string;
|
|
153
|
-
debug?: string;
|
|
154
|
-
align?: string;
|
|
155
|
-
justify?: string;
|
|
156
85
|
width?: string;
|
|
157
86
|
}
|
|
158
87
|
/**
|
|
@@ -188,6 +117,11 @@ export interface GridAttr {
|
|
|
188
117
|
*/
|
|
189
118
|
paginate?: string;
|
|
190
119
|
debug?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
122
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
123
|
+
* line; in a column it takes the full width.
|
|
124
|
+
*/
|
|
191
125
|
width?: string;
|
|
192
126
|
colWidth?: string;
|
|
193
127
|
cols?: string;
|
|
@@ -224,6 +158,11 @@ export interface FrameAttr {
|
|
|
224
158
|
*/
|
|
225
159
|
paginate?: string;
|
|
226
160
|
debug?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
163
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
164
|
+
* line; in a column it takes the full width.
|
|
165
|
+
*/
|
|
227
166
|
width?: string;
|
|
228
167
|
}
|
|
229
168
|
/**
|
|
@@ -236,6 +175,11 @@ export interface LinkAttr {
|
|
|
236
175
|
*/
|
|
237
176
|
href: string;
|
|
238
177
|
gap?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
180
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
181
|
+
* line; in a column it takes the full width.
|
|
182
|
+
*/
|
|
239
183
|
width?: string;
|
|
240
184
|
height?: string;
|
|
241
185
|
debug?: string;
|
|
@@ -247,6 +191,12 @@ export interface DividerAttr {
|
|
|
247
191
|
direction?: string;
|
|
248
192
|
color?: string;
|
|
249
193
|
thickness?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
196
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
197
|
+
* line; in a column it takes the full width.
|
|
198
|
+
*/
|
|
199
|
+
width?: string;
|
|
250
200
|
debug?: string;
|
|
251
201
|
}
|
|
252
202
|
/**
|
|
@@ -265,11 +215,20 @@ export interface SpanAttr {
|
|
|
265
215
|
strike?: string;
|
|
266
216
|
}
|
|
267
217
|
/**
|
|
268
|
-
*
|
|
218
|
+
* An image. It is never stretched. With only a width or a height, the other follows the image's
|
|
219
|
+
* proportions. With both, they are a maximum: the image takes the largest size that fits in them,
|
|
220
|
+
* and its box becomes that size, which the parent's align places. To put images of different shapes
|
|
221
|
+
* in slots of one size, wrap each in a frame of that size. With neither, the image has its natural
|
|
222
|
+
* size.
|
|
269
223
|
*/
|
|
270
224
|
export interface ImgAttr {
|
|
271
225
|
name: string;
|
|
272
226
|
height?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
229
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
230
|
+
* line; in a column it takes the full width.
|
|
231
|
+
*/
|
|
273
232
|
width?: string;
|
|
274
233
|
font?: string;
|
|
275
234
|
fontSize?: string;
|
|
@@ -282,18 +241,34 @@ export interface ImgAttr {
|
|
|
282
241
|
debug?: string;
|
|
283
242
|
}
|
|
284
243
|
/**
|
|
285
|
-
*
|
|
244
|
+
* A QR code, a Code 128 or an EAN-13. It is never stretched. With only a width or a height, the
|
|
245
|
+
* other follows the barcode's proportions. With both, they are a maximum: the barcode takes the
|
|
246
|
+
* largest size that fits in them, and its box becomes that size, which the parent's align places.
|
|
247
|
+
* To put barcodes in slots of one size, wrap each in a frame of that size.
|
|
286
248
|
*/
|
|
287
249
|
export interface BarcodeAttr {
|
|
288
250
|
type: string;
|
|
289
251
|
data: string;
|
|
290
|
-
|
|
291
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Height of the whole barcode, with the digits of hrt inside it: they take the bottom 12pt and
|
|
254
|
+
* the bars the rest. A barcode is never stretched. With only a height, the width follows the
|
|
255
|
+
* barcode's proportions. With both width and height, they are a maximum: the barcode takes the
|
|
256
|
+
* largest size that fits in them, and its box becomes that size. A QR code is square, so it takes
|
|
257
|
+
* the smaller of the two. Without a size, a code128 is as wide as its bars at 1pt per module and
|
|
258
|
+
* its bars are 40pt high, and an ean13 is the standard symbol, 0.33mm per module and bars 22.85mm
|
|
259
|
+
* high. The digits of hrt add 12pt to either.
|
|
260
|
+
*/
|
|
292
261
|
height?: string;
|
|
293
262
|
ec?: string;
|
|
294
263
|
hrt?: string;
|
|
295
264
|
color?: string;
|
|
296
265
|
background?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
268
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
269
|
+
* line; in a column it takes the full width.
|
|
270
|
+
*/
|
|
271
|
+
width?: string;
|
|
297
272
|
paginate?: string;
|
|
298
273
|
debug?: string;
|
|
299
274
|
}
|
|
@@ -312,6 +287,11 @@ export interface TextAttr {
|
|
|
312
287
|
bold?: string;
|
|
313
288
|
color?: string;
|
|
314
289
|
align?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
292
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
293
|
+
* line; in a column it takes the full width.
|
|
294
|
+
*/
|
|
315
295
|
width?: string;
|
|
316
296
|
/**
|
|
317
297
|
* The fewest lines of the text that may stand alone at the top of the next page when it splits.
|
|
@@ -390,6 +370,11 @@ export interface TableAttr {
|
|
|
390
370
|
gap?: string;
|
|
391
371
|
padding?: string;
|
|
392
372
|
background?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
375
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
376
|
+
* line; in a column it takes the full width.
|
|
377
|
+
*/
|
|
393
378
|
width?: string;
|
|
394
379
|
height?: string;
|
|
395
380
|
paginate?: string;
|
|
@@ -410,6 +395,11 @@ export interface FieldAttr {
|
|
|
410
395
|
readonly?: string;
|
|
411
396
|
maxLen?: string;
|
|
412
397
|
actionUrl?: string;
|
|
398
|
+
/**
|
|
399
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
400
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
401
|
+
* line; in a column it takes the full width.
|
|
402
|
+
*/
|
|
413
403
|
width?: string;
|
|
414
404
|
height?: string;
|
|
415
405
|
background?: string;
|
|
@@ -457,21 +447,32 @@ export interface RegionAttr {
|
|
|
457
447
|
debug?: string;
|
|
458
448
|
}
|
|
459
449
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
450
|
+
* Draws shapes, text, images and barcodes at exact positions on the page, independent of the
|
|
451
|
+
* flowing layout: watermarks, stamps, page furniture. Coordinates start at the top left corner of
|
|
452
|
+
* the whole page, not inside the layout's margin, and y grows downward. A layer before the
|
|
453
|
+
* 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.
|
|
462
455
|
*/
|
|
463
456
|
export interface LayerAttr {
|
|
464
457
|
page?: string;
|
|
458
|
+
/**
|
|
459
|
+
* How opaque everything in the layer is, from 0 to 1. To fade one element, put it in a layer of
|
|
460
|
+
* its own.
|
|
461
|
+
*/
|
|
465
462
|
opacity?: string;
|
|
466
463
|
transform?: string;
|
|
464
|
+
/**
|
|
465
|
+
* A rectangle that cuts off what the layer draws outside it: x y w h, in points from the top left
|
|
466
|
+
* corner of the page.
|
|
467
|
+
*/
|
|
467
468
|
clip?: string;
|
|
468
469
|
}
|
|
469
470
|
/**
|
|
470
|
-
* Attributes of the `rect` element
|
|
471
|
+
* Attributes of the `rect` element in a layer.
|
|
471
472
|
*/
|
|
472
473
|
export interface RectAttr {
|
|
473
|
-
|
|
474
|
-
|
|
474
|
+
width: string;
|
|
475
|
+
height: string;
|
|
475
476
|
x?: string;
|
|
476
477
|
y?: string;
|
|
477
478
|
anchor?: string;
|
|
@@ -480,39 +481,56 @@ export interface RectAttr {
|
|
|
480
481
|
stroke?: string;
|
|
481
482
|
strokeWidth?: string;
|
|
482
483
|
strokeDash?: string;
|
|
483
|
-
opacity?: string;
|
|
484
484
|
}
|
|
485
485
|
/**
|
|
486
|
-
* Attributes of the `circle` element
|
|
486
|
+
* Attributes of the `circle` element in a layer.
|
|
487
487
|
*/
|
|
488
488
|
export interface CircleAttr {
|
|
489
489
|
r: string;
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Where the circle's box goes, the square of side 2r around it: its left edge, or with anchor, an
|
|
492
|
+
* offset from that point of the page, where the box's matching point goes. The centre is r
|
|
493
|
+
* further in.
|
|
494
|
+
*/
|
|
495
|
+
x?: string;
|
|
496
|
+
/**
|
|
497
|
+
* Where the circle's box goes, the square of side 2r around it: its top edge, or with anchor, an
|
|
498
|
+
* offset from that point of the page, where the box's matching point goes. The centre is r
|
|
499
|
+
* further in.
|
|
500
|
+
*/
|
|
501
|
+
y?: string;
|
|
492
502
|
anchor?: string;
|
|
493
503
|
fill?: string;
|
|
494
504
|
stroke?: string;
|
|
495
505
|
strokeWidth?: string;
|
|
496
506
|
strokeDash?: string;
|
|
497
|
-
opacity?: string;
|
|
498
507
|
}
|
|
499
508
|
/**
|
|
500
|
-
* Attributes of the `ellipse` element
|
|
509
|
+
* Attributes of the `ellipse` element in a layer.
|
|
501
510
|
*/
|
|
502
511
|
export interface EllipseAttr {
|
|
503
512
|
rx: string;
|
|
504
513
|
ry: string;
|
|
505
|
-
|
|
506
|
-
|
|
514
|
+
/**
|
|
515
|
+
* Where the ellipse's box goes, 2rx wide and 2ry high around it: its left edge, or with anchor,
|
|
516
|
+
* an offset from that point of the page, where the box's matching point goes. The centre is rx
|
|
517
|
+
* further in.
|
|
518
|
+
*/
|
|
519
|
+
x?: string;
|
|
520
|
+
/**
|
|
521
|
+
* Where the ellipse's box goes, 2rx wide and 2ry high around it: its top edge, or with anchor, an
|
|
522
|
+
* offset from that point of the page, where the box's matching point goes. The centre is ry
|
|
523
|
+
* further in.
|
|
524
|
+
*/
|
|
525
|
+
y?: string;
|
|
507
526
|
anchor?: string;
|
|
508
527
|
fill?: string;
|
|
509
528
|
stroke?: string;
|
|
510
529
|
strokeWidth?: string;
|
|
511
530
|
strokeDash?: string;
|
|
512
|
-
opacity?: string;
|
|
513
531
|
}
|
|
514
532
|
/**
|
|
515
|
-
* Attributes of the `line` element
|
|
533
|
+
* Attributes of the `line` element in a layer.
|
|
516
534
|
*/
|
|
517
535
|
export interface LineAttr {
|
|
518
536
|
x1: string;
|
|
@@ -525,7 +543,7 @@ export interface LineAttr {
|
|
|
525
543
|
lineCap?: string;
|
|
526
544
|
}
|
|
527
545
|
/**
|
|
528
|
-
* Attributes of the `path` element
|
|
546
|
+
* Attributes of the `path` element in a layer.
|
|
529
547
|
*/
|
|
530
548
|
export interface PathAttr {
|
|
531
549
|
d: string;
|
|
@@ -535,33 +553,104 @@ export interface PathAttr {
|
|
|
535
553
|
strokeWidth?: string;
|
|
536
554
|
strokeDash?: string;
|
|
537
555
|
lineCap?: string;
|
|
538
|
-
opacity?: string;
|
|
539
556
|
}
|
|
540
557
|
/**
|
|
541
|
-
* Text at
|
|
558
|
+
* Text at a fixed place on the page. It is the text of the layout, with the same defaults: the
|
|
559
|
+
* document's font or Helvetica, 11pt and the text colour. It is one line unless told otherwise;
|
|
560
|
+
* give width to cut it off at a width or to wrap it with max-lines. x and y place its box: the
|
|
561
|
+
* top-left corner, or with anchor, an offset from that point of the page, where the box's matching
|
|
562
|
+
* point goes. {page} and {pages} in it count within the section, and a text that comes from data
|
|
563
|
+
* belongs in the layout, since a longer text loses its end here without a warning.
|
|
542
564
|
*/
|
|
543
|
-
export interface
|
|
565
|
+
export interface TextAtAttr {
|
|
544
566
|
x?: string;
|
|
545
567
|
y?: string;
|
|
546
568
|
anchor?: string;
|
|
547
|
-
font?: string;
|
|
548
569
|
fontSize?: string;
|
|
570
|
+
font?: string;
|
|
571
|
+
/**
|
|
572
|
+
* Use the bold face of the font. It applies to the 14 built-in fonts: Helvetica becomes
|
|
573
|
+
* Helvetica-Bold, Times-Roman becomes Times-Bold, Courier becomes Courier-Bold, and the oblique
|
|
574
|
+
* and italic faces their bold forms. A custom font has no bold face to pick, so name one in font.
|
|
575
|
+
*/
|
|
576
|
+
bold?: string;
|
|
549
577
|
color?: string;
|
|
550
578
|
align?: string;
|
|
551
|
-
|
|
579
|
+
/**
|
|
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.
|
|
584
|
+
*/
|
|
585
|
+
width?: string;
|
|
586
|
+
/**
|
|
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.
|
|
589
|
+
*/
|
|
590
|
+
maxLines?: string;
|
|
591
|
+
/**
|
|
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.
|
|
594
|
+
*/
|
|
595
|
+
ellipsis?: string;
|
|
596
|
+
/** The distance between lines, as a factor of the font size. Default 1.2. */
|
|
552
597
|
lineHeight?: string;
|
|
553
|
-
opacity?: string;
|
|
554
598
|
}
|
|
555
599
|
/**
|
|
556
|
-
*
|
|
600
|
+
* An image at a fixed place on the page. It needs width or height, and the other follows the
|
|
601
|
+
* image's proportions. With both, they are a maximum: the image takes the largest size that fits in
|
|
602
|
+
* them, and its box becomes that size, so an anchor places the image itself. x and y place its box:
|
|
603
|
+
* the top-left corner, or with anchor, an offset from that point of the page, where the box's
|
|
604
|
+
* matching point goes.
|
|
557
605
|
*/
|
|
558
|
-
export interface
|
|
606
|
+
export interface ImgAtAttr {
|
|
559
607
|
name: string;
|
|
560
|
-
w: string;
|
|
561
|
-
h: string;
|
|
562
608
|
x?: string;
|
|
563
609
|
y?: string;
|
|
564
610
|
anchor?: string;
|
|
611
|
+
width?: string;
|
|
612
|
+
height?: string;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* A barcode at a fixed place on the page. It needs width or height, and the other follows the
|
|
616
|
+
* barcode's proportions. With both, they are a maximum: the barcode takes the largest size that
|
|
617
|
+
* fits in them, and its box becomes that size, so an anchor places the barcode itself. x and y
|
|
618
|
+
* place its box: the top-left corner, or with anchor, an offset from that point of the page, where
|
|
619
|
+
* the box's matching point goes.
|
|
620
|
+
*/
|
|
621
|
+
export interface BarcodeAtAttr {
|
|
622
|
+
type: string;
|
|
623
|
+
data: string;
|
|
624
|
+
/**
|
|
625
|
+
* Height of the whole barcode, with the digits of hrt inside it: they take the bottom 12pt and
|
|
626
|
+
* the bars the rest. A barcode is never stretched. With only a height, the width follows the
|
|
627
|
+
* barcode's proportions. With both width and height, they are a maximum: the barcode takes the
|
|
628
|
+
* largest size that fits in them, and its box becomes that size. A QR code is square, so it takes
|
|
629
|
+
* the smaller of the two. Without a size, a code128 is as wide as its bars at 1pt per module and
|
|
630
|
+
* its bars are 40pt high, and an ean13 is the standard symbol, 0.33mm per module and bars 22.85mm
|
|
631
|
+
* high. The digits of hrt add 12pt to either.
|
|
632
|
+
*/
|
|
633
|
+
height?: string;
|
|
634
|
+
ec?: string;
|
|
635
|
+
hrt?: string;
|
|
636
|
+
color?: string;
|
|
637
|
+
background?: string;
|
|
638
|
+
x?: string;
|
|
639
|
+
y?: string;
|
|
640
|
+
anchor?: string;
|
|
641
|
+
width?: string;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* The flowing content of a section. Elements stack down the page, and a new page starts when one
|
|
645
|
+
* runs out of room. Put headers and footers in a region, which sits outside the flow.
|
|
646
|
+
*/
|
|
647
|
+
export interface LayoutAttr {
|
|
648
|
+
/**
|
|
649
|
+
* The space between the page edges and the flowing content and its regions: one value for all
|
|
650
|
+
* four sides, or two to four in the order top, right, bottom, left. Defaults to 36pt. Layers
|
|
651
|
+
* ignore it and measure from the page edges.
|
|
652
|
+
*/
|
|
653
|
+
margin?: string;
|
|
565
654
|
}
|
|
566
655
|
/**
|
|
567
656
|
* Declares a font that text can be set in by name, with the font attribute. A built-in PDF font is
|
package/dist/browser.js
CHANGED
|
@@ -119,7 +119,7 @@ var LpdfEngine = class {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
* Render a JSON kit-tree
|
|
122
|
+
* Render a JSON kit-tree document to PDF bytes.
|
|
123
123
|
*
|
|
124
124
|
* This is the JSON counterpart of `render_pdf`. The Node adapter uses it
|
|
125
125
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
package/dist/canvas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr,
|
|
1
|
+
import type { RectAttr, CircleAttr, EllipseAttr, LineAttr, PathAttr, TextAtAttr, ImgAtAttr, BarcodeAtAttr, LayerAttr } from './attrs';
|
|
2
2
|
import type { LpdfSpanNode } from './layout';
|
|
3
3
|
/**
|
|
4
4
|
* Builds the `transform` string of a layer. `String(CanvasTransform.rotate(45))` is
|
|
@@ -41,16 +41,20 @@ export interface LpdfCanvasPathNode {
|
|
|
41
41
|
type: 'path';
|
|
42
42
|
attrs: Record<string, string>;
|
|
43
43
|
}
|
|
44
|
-
export interface
|
|
45
|
-
type: 'text';
|
|
44
|
+
export interface LpdfCanvasTextAtNode {
|
|
45
|
+
type: 'text-at';
|
|
46
46
|
attrs: Record<string, string>;
|
|
47
47
|
nodes: (string | LpdfSpanNode)[];
|
|
48
48
|
}
|
|
49
|
-
export interface
|
|
50
|
-
type: 'img';
|
|
49
|
+
export interface LpdfCanvasImgAtNode {
|
|
50
|
+
type: 'img-at';
|
|
51
51
|
attrs: Record<string, string>;
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export interface LpdfCanvasBarcodeAtNode {
|
|
54
|
+
type: 'barcode-at';
|
|
55
|
+
attrs: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
export type LpdfCanvasPrimitiveNode = LpdfCanvasRectNode | LpdfCanvasLineNode | LpdfCanvasEllipseNode | LpdfCanvasCircleNode | LpdfCanvasPathNode | LpdfCanvasTextAtNode | LpdfCanvasImgAtNode | LpdfCanvasBarcodeAtNode;
|
|
54
58
|
export interface LpdfCanvasLayerNode {
|
|
55
59
|
type: 'layer';
|
|
56
60
|
attrs: Record<string, string>;
|
|
@@ -61,8 +65,9 @@ declare function line(attrs: LineAttr): LpdfCanvasLineNode;
|
|
|
61
65
|
declare function ellipse(attrs: EllipseAttr): LpdfCanvasEllipseNode;
|
|
62
66
|
declare function circle(attrs: CircleAttr): LpdfCanvasCircleNode;
|
|
63
67
|
declare function path(attrs: PathAttr): LpdfCanvasPathNode;
|
|
64
|
-
declare function textAt(attrs:
|
|
65
|
-
declare function imgAt(attrs:
|
|
68
|
+
declare function textAt(attrs: TextAtAttr, nodes?: (string | LpdfSpanNode)[]): LpdfCanvasTextAtNode;
|
|
69
|
+
declare function imgAt(attrs: ImgAtAttr): LpdfCanvasImgAtNode;
|
|
70
|
+
declare function barcodeAt(attrs: BarcodeAtAttr): LpdfCanvasBarcodeAtNode;
|
|
66
71
|
declare function layer(attrs: LayerAttr | null, nodes?: LpdfCanvasPrimitiveNode[]): LpdfCanvasLayerNode;
|
|
67
72
|
export declare const LpdfCanvas: Readonly<{
|
|
68
73
|
rect: typeof rect;
|
|
@@ -72,6 +77,7 @@ export declare const LpdfCanvas: Readonly<{
|
|
|
72
77
|
path: typeof path;
|
|
73
78
|
textAt: typeof textAt;
|
|
74
79
|
imgAt: typeof imgAt;
|
|
80
|
+
barcodeAt: typeof barcodeAt;
|
|
75
81
|
layer: typeof layer;
|
|
76
82
|
}>;
|
|
77
83
|
export {};
|
package/dist/canvas.js
CHANGED
|
@@ -67,10 +67,13 @@ function path(attrs) {
|
|
|
67
67
|
return { type: 'path', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
68
68
|
}
|
|
69
69
|
function textAt(attrs, nodes = []) {
|
|
70
|
-
return { type: 'text', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
70
|
+
return { type: 'text-at', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
71
71
|
}
|
|
72
72
|
function imgAt(attrs) {
|
|
73
|
-
return { type: 'img', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
73
|
+
return { type: 'img-at', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
74
|
+
}
|
|
75
|
+
function barcodeAt(attrs) {
|
|
76
|
+
return { type: 'barcode-at', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
74
77
|
}
|
|
75
78
|
function layer(attrs, nodes = []) {
|
|
76
79
|
return { type: 'layer', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
@@ -83,5 +86,6 @@ exports.LpdfCanvas = Object.freeze({
|
|
|
83
86
|
path,
|
|
84
87
|
textAt,
|
|
85
88
|
imgAt,
|
|
89
|
+
barcodeAt,
|
|
86
90
|
layer,
|
|
87
91
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ 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,
|
|
6
|
-
export type {
|
|
5
|
+
export type { PdfDocument, LpdfSectionNode, LpdfSectionChild, LpdfLayoutBlock, DocumentTokens, 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
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';
|
|
9
|
-
export type { LpdfCanvasLayerNode, LpdfCanvasPrimitiveNode, LpdfCanvasRectNode, LpdfCanvasLineNode, LpdfCanvasEllipseNode, LpdfCanvasCircleNode, LpdfCanvasPathNode,
|
|
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
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "Orientation", { enumerable: true, get: function
|
|
|
13
13
|
Object.defineProperty(exports, "SectionType", { enumerable: true, get: function () { return constants_1.SectionType; } });
|
|
14
14
|
Object.defineProperty(exports, "BuiltinFont", { enumerable: true, get: function () { return constants_1.BuiltinFont; } });
|
|
15
15
|
Object.defineProperty(exports, "PageScope", { enumerable: true, get: function () { return constants_1.PageScope; } });
|
|
16
|
-
// ──
|
|
16
|
+
// ── Layer types ───────────────────────────────────────────────────────────────
|
|
17
17
|
var canvas_1 = require("./canvas");
|
|
18
18
|
Object.defineProperty(exports, "CanvasTransform", { enumerable: true, get: function () { return canvas_1.CanvasTransform; } });
|
|
19
19
|
// ── Facade ────────────────────────────────────────────────────────────────────
|
package/dist/kit.d.ts
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LpdfKit — document skeleton assembly.
|
|
3
3
|
*
|
|
4
|
-
* Assembles sections (
|
|
5
|
-
*
|
|
4
|
+
* Assembles sections (layers and a layout) into a document tree ready for
|
|
5
|
+
* `PdfEngine.render()` or `L.toXml()`. A section holds layers, then at most
|
|
6
|
+
* one layout, then layers: the layers before the layout paint under it, and
|
|
7
|
+
* the layers after it paint over it.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
|
-
* import {
|
|
11
|
+
* import { L, NoAttr } from '@lpdfio/lpdf';
|
|
10
12
|
*
|
|
11
|
-
* const doc =
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* options: { size: 'a4', margin: '28pt' },
|
|
19
|
-
* }),
|
|
20
|
-
* ],
|
|
21
|
-
* options: { meta: { title: 'My Doc' } },
|
|
22
|
-
* });
|
|
23
|
-
* const bytes = await new LpdfEngine(key).renderPdf(doc);
|
|
13
|
+
* const doc = L.document({ meta: { title: 'My Doc' } }, [
|
|
14
|
+
* L.section({ size: 'a4' }, [
|
|
15
|
+
* L.layer(NoAttr, [ L.rect({ x: '0pt', y: '0pt', width: '595pt', height: '842pt', fill: '#f5f5f5' }) ]),
|
|
16
|
+
* L.layout({ margin: '28pt' }, [ L.text(NoAttr, ['Hello']) ]),
|
|
17
|
+
* ]),
|
|
18
|
+
* ]);
|
|
19
|
+
* const bytes = await L.engine().setLicenseKey(key).render(doc);
|
|
24
20
|
* ```
|
|
25
21
|
*/
|
|
26
22
|
import type { LpdfBookmarkNode, LpdfNode } from './layout';
|
|
27
23
|
import type { LpdfCanvasLayerNode } from './canvas';
|
|
28
|
-
import type { FontAttr, ImageAttr } from './attrs';
|
|
24
|
+
import type { FontAttr, ImageAttr, LayoutAttr } from './attrs';
|
|
29
25
|
export interface DocumentTokens {
|
|
30
26
|
colors?: Record<string, string>;
|
|
31
27
|
space?: Record<string, string>;
|
|
@@ -53,7 +49,6 @@ export interface DocumentMeta {
|
|
|
53
49
|
export interface SectionAttr {
|
|
54
50
|
size?: string;
|
|
55
51
|
orientation?: string;
|
|
56
|
-
margin?: string;
|
|
57
52
|
background?: string;
|
|
58
53
|
title?: string;
|
|
59
54
|
debug?: string;
|
|
@@ -63,7 +58,6 @@ export interface SectionAttr {
|
|
|
63
58
|
export interface DocumentAttr {
|
|
64
59
|
size?: string;
|
|
65
60
|
orientation?: string;
|
|
66
|
-
margin?: string;
|
|
67
61
|
background?: string;
|
|
68
62
|
font?: string;
|
|
69
63
|
assets?: DocumentAssets;
|
|
@@ -74,31 +68,30 @@ export interface DocumentAttr {
|
|
|
74
68
|
/** A layout block — wraps an ordered list of layout nodes. */
|
|
75
69
|
export interface LpdfLayoutBlock {
|
|
76
70
|
type: 'layout';
|
|
71
|
+
attrs: Record<string, string>;
|
|
77
72
|
nodes: LpdfNode[];
|
|
78
73
|
}
|
|
79
|
-
/** A canvas block — wraps an ordered list of canvas layers. */
|
|
80
|
-
export interface LpdfCanvasBlock {
|
|
81
|
-
type: 'canvas';
|
|
82
|
-
nodes: LpdfCanvasLayerNode[];
|
|
83
|
-
}
|
|
84
74
|
export interface LpdfSectionNode {
|
|
85
75
|
type: 'section';
|
|
86
76
|
attrs: Record<string, string>;
|
|
87
|
-
nodes:
|
|
77
|
+
nodes: LpdfSectionChild[];
|
|
88
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* What a section holds: a bookmark first, then layers, then at most one layout, then layers. Layers before
|
|
81
|
+
* the layout paint under it, and layers after it paint over it.
|
|
82
|
+
*/
|
|
83
|
+
export type LpdfSectionChild = LpdfBookmarkNode | LpdfCanvasLayerNode | LpdfLayoutBlock;
|
|
89
84
|
export interface PdfDocument {
|
|
90
85
|
version: 1;
|
|
91
86
|
type: 'document';
|
|
92
87
|
attrs: Record<string, unknown>;
|
|
93
88
|
nodes: LpdfSectionNode[];
|
|
94
89
|
}
|
|
95
|
-
declare function layout(
|
|
96
|
-
declare function
|
|
97
|
-
declare function section(attrs: SectionAttr | null, nodes?: (LpdfBookmarkNode | LpdfLayoutBlock | LpdfCanvasBlock)[]): LpdfSectionNode;
|
|
90
|
+
declare function layout(attrs: LayoutAttr | null, nodes?: LpdfNode[]): LpdfLayoutBlock;
|
|
91
|
+
declare function section(attrs: SectionAttr | null, nodes?: LpdfSectionChild[]): LpdfSectionNode;
|
|
98
92
|
declare function document(attrs: DocumentAttr | null, nodes?: LpdfSectionNode[]): PdfDocument;
|
|
99
93
|
export declare const LpdfKit: Readonly<{
|
|
100
94
|
layout: typeof layout;
|
|
101
|
-
canvas: typeof canvas;
|
|
102
95
|
section: typeof section;
|
|
103
96
|
document: typeof document;
|
|
104
97
|
}>;
|
package/dist/kit.js
CHANGED
|
@@ -2,37 +2,30 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* LpdfKit — document skeleton assembly.
|
|
4
4
|
*
|
|
5
|
-
* Assembles sections (
|
|
6
|
-
*
|
|
5
|
+
* Assembles sections (layers and a layout) into a document tree ready for
|
|
6
|
+
* `PdfEngine.render()` or `L.toXml()`. A section holds layers, then at most
|
|
7
|
+
* one layout, then layers: the layers before the layout paint under it, and
|
|
8
|
+
* the layers after it paint over it.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
11
|
* ```ts
|
|
10
|
-
* import {
|
|
12
|
+
* import { L, NoAttr } from '@lpdfio/lpdf';
|
|
11
13
|
*
|
|
12
|
-
* const doc =
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* options: { size: 'a4', margin: '28pt' },
|
|
20
|
-
* }),
|
|
21
|
-
* ],
|
|
22
|
-
* options: { meta: { title: 'My Doc' } },
|
|
23
|
-
* });
|
|
24
|
-
* const bytes = await new LpdfEngine(key).renderPdf(doc);
|
|
14
|
+
* const doc = L.document({ meta: { title: 'My Doc' } }, [
|
|
15
|
+
* L.section({ size: 'a4' }, [
|
|
16
|
+
* L.layer(NoAttr, [ L.rect({ x: '0pt', y: '0pt', width: '595pt', height: '842pt', fill: '#f5f5f5' }) ]),
|
|
17
|
+
* L.layout({ margin: '28pt' }, [ L.text(NoAttr, ['Hello']) ]),
|
|
18
|
+
* ]),
|
|
19
|
+
* ]);
|
|
20
|
+
* const bytes = await L.engine().setLicenseKey(key).render(doc);
|
|
25
21
|
* ```
|
|
26
22
|
*/
|
|
27
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
24
|
exports.LpdfKit = void 0;
|
|
29
25
|
const _shared_1 = require("./_shared");
|
|
30
26
|
// ── Factory functions ─────────────────────────────────────────────────────────
|
|
31
|
-
function layout(
|
|
32
|
-
return { type: 'layout', nodes };
|
|
33
|
-
}
|
|
34
|
-
function canvas(_attrs, layers = []) {
|
|
35
|
-
return { type: 'canvas', nodes: layers };
|
|
27
|
+
function layout(attrs, nodes = []) {
|
|
28
|
+
return { type: 'layout', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
36
29
|
}
|
|
37
30
|
function section(attrs, nodes = []) {
|
|
38
31
|
return {
|
|
@@ -64,7 +57,6 @@ function document(attrs, nodes = []) {
|
|
|
64
57
|
// ── LpdfKit export ────────────────────────────────────────────────────────────
|
|
65
58
|
exports.LpdfKit = Object.freeze({
|
|
66
59
|
layout,
|
|
67
|
-
canvas,
|
|
68
60
|
section,
|
|
69
61
|
document,
|
|
70
62
|
});
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColumnAttr, RowAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, 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
7
|
export interface LpdfContainerNode {
|
|
8
|
-
type: '
|
|
8
|
+
type: 'column' | 'row' | 'grid' | 'frame' | 'link';
|
|
9
9
|
attrs: Record<string, string>;
|
|
10
10
|
nodes: LpdfNode[];
|
|
11
11
|
}
|
|
@@ -61,10 +61,8 @@ export interface LpdfBookmarkNode {
|
|
|
61
61
|
attrs: Record<string, string>;
|
|
62
62
|
}
|
|
63
63
|
export type LpdfNode = LpdfContainerNode | LpdfTextNode | LpdfDividerNode | LpdfTableNode | LpdfImgNode | LpdfBarcodeNode | LpdfRegionNode | LpdfFieldNode | LpdfBookmarkNode;
|
|
64
|
-
declare function
|
|
65
|
-
declare function
|
|
66
|
-
declare function split(attrs: SplitAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
67
|
-
declare function cluster(attrs: ClusterAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
64
|
+
declare function column(attrs: ColumnAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
65
|
+
declare function row(attrs: RowAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
68
66
|
declare function grid(attrs: GridAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
69
67
|
declare function frame(attrs: FrameAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
70
68
|
declare function link(attrs: LinkAttr, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
@@ -85,10 +83,8 @@ declare function field(attrs: FieldAttr): LpdfFieldNode;
|
|
|
85
83
|
*/
|
|
86
84
|
declare function bookmark(attrs: BookmarkAttr): LpdfBookmarkNode;
|
|
87
85
|
export declare const LpdfLayout: Readonly<{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
split: typeof split;
|
|
91
|
-
cluster: typeof cluster;
|
|
86
|
+
column: typeof column;
|
|
87
|
+
row: typeof row;
|
|
92
88
|
grid: typeof grid;
|
|
93
89
|
frame: typeof frame;
|
|
94
90
|
link: typeof link;
|
package/dist/layout.js
CHANGED
|
@@ -7,17 +7,11 @@ function makeContainer(type, attrs, nodes) {
|
|
|
7
7
|
return { type, attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
8
8
|
}
|
|
9
9
|
// ── LpdfLayout factory ────────────────────────────────────────────────────────
|
|
10
|
-
function
|
|
11
|
-
return makeContainer('
|
|
10
|
+
function column(attrs, nodes = []) {
|
|
11
|
+
return makeContainer('column', attrs, nodes);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return makeContainer('
|
|
15
|
-
}
|
|
16
|
-
function split(attrs, nodes = []) {
|
|
17
|
-
return makeContainer('split', attrs, nodes);
|
|
18
|
-
}
|
|
19
|
-
function cluster(attrs, nodes = []) {
|
|
20
|
-
return makeContainer('cluster', attrs, nodes);
|
|
13
|
+
function row(attrs, nodes = []) {
|
|
14
|
+
return makeContainer('row', attrs, nodes);
|
|
21
15
|
}
|
|
22
16
|
function grid(attrs, nodes = []) {
|
|
23
17
|
return makeContainer('grid', attrs, nodes);
|
|
@@ -69,10 +63,8 @@ function bookmark(attrs) {
|
|
|
69
63
|
return { type: 'bookmark', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
70
64
|
}
|
|
71
65
|
exports.LpdfLayout = Object.freeze({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
split,
|
|
75
|
-
cluster,
|
|
66
|
+
column,
|
|
67
|
+
row,
|
|
76
68
|
grid,
|
|
77
69
|
frame,
|
|
78
70
|
link,
|
package/dist/wasm/lpdf-web.js
CHANGED
|
@@ -120,7 +120,7 @@ export class LpdfEngine {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* Render a JSON kit-tree
|
|
123
|
+
* Render a JSON kit-tree document to PDF bytes.
|
|
124
124
|
*
|
|
125
125
|
* This is the JSON counterpart of `render_pdf`. The Node adapter uses it
|
|
126
126
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
package/dist/wasm/lpdf.js
CHANGED
|
@@ -120,7 +120,7 @@ class LpdfEngine {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* Render a JSON kit-tree
|
|
123
|
+
* Render a JSON kit-tree document to PDF bytes.
|
|
124
124
|
*
|
|
125
125
|
* This is the JSON counterpart of `render_pdf`. The Node adapter uses it
|
|
126
126
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
package/dist/wasm/lpdf_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lpdfio/lpdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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",
|