@lpdfio/lpdf 0.25.0 → 0.26.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 +4 -4
- package/dist/L.d.ts +2 -4
- package/dist/L.js +2 -4
- package/dist/attrs.d.ts +59 -84
- package/dist/index.d.ts +1 -1
- package/dist/layout.d.ts +6 -10
- package/dist/layout.js +6 -14
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,16 +22,16 @@ const engine = L.engine()
|
|
|
22
22
|
const doc = L.document({ size: 'letter', margin: '48pt' }, [
|
|
23
23
|
L.section(NoAttr, [
|
|
24
24
|
L.layout(NoAttr, [
|
|
25
|
-
L.
|
|
26
|
-
L.
|
|
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
|
@@ -35,10 +35,8 @@ export declare const L: Readonly<{
|
|
|
35
35
|
canvas: (_attrs: null, layers?: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
|
|
36
36
|
assets: (attrs: DocumentAssets) => DocumentAssets;
|
|
37
37
|
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;
|
|
38
|
+
column: (attrs: import("./attrs").ColumnAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
39
|
+
row: (attrs: import("./attrs").RowAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
42
40
|
grid: (attrs: import("./attrs").GridAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
43
41
|
frame: (attrs: import("./attrs").FrameAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
44
42
|
link: (attrs: import("./attrs").LinkAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
package/dist/L.js
CHANGED
|
@@ -43,10 +43,8 @@ exports.L = Object.freeze({
|
|
|
43
43
|
assets: (attrs) => attrs,
|
|
44
44
|
tokens: (attrs) => attrs,
|
|
45
45
|
// ── Layout ────────────────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
split: layout_1.LpdfLayout.split,
|
|
49
|
-
cluster: layout_1.LpdfLayout.cluster,
|
|
46
|
+
column: layout_1.LpdfLayout.column,
|
|
47
|
+
row: layout_1.LpdfLayout.row,
|
|
50
48
|
grid: layout_1.LpdfLayout.grid,
|
|
51
49
|
frame: layout_1.LpdfLayout.frame,
|
|
52
50
|
link: layout_1.LpdfLayout.link,
|
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.
|
|
68
|
-
*/
|
|
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.
|
|
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.
|
|
75
40
|
*/
|
|
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
|
/**
|
|
@@ -270,6 +220,11 @@ export interface SpanAttr {
|
|
|
270
220
|
export interface ImgAttr {
|
|
271
221
|
name: string;
|
|
272
222
|
height?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
225
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
226
|
+
* line; in a column it takes the full width.
|
|
227
|
+
*/
|
|
273
228
|
width?: string;
|
|
274
229
|
font?: string;
|
|
275
230
|
fontSize?: string;
|
|
@@ -288,6 +243,11 @@ export interface BarcodeAttr {
|
|
|
288
243
|
type: string;
|
|
289
244
|
data: string;
|
|
290
245
|
size?: string;
|
|
246
|
+
/**
|
|
247
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
248
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
249
|
+
* line; in a column it takes the full width.
|
|
250
|
+
*/
|
|
291
251
|
width?: string;
|
|
292
252
|
height?: string;
|
|
293
253
|
ec?: string;
|
|
@@ -312,6 +272,11 @@ export interface TextAttr {
|
|
|
312
272
|
bold?: string;
|
|
313
273
|
color?: string;
|
|
314
274
|
align?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
277
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
278
|
+
* line; in a column it takes the full width.
|
|
279
|
+
*/
|
|
315
280
|
width?: string;
|
|
316
281
|
/**
|
|
317
282
|
* The fewest lines of the text that may stand alone at the top of the next page when it splits.
|
|
@@ -390,6 +355,11 @@ export interface TableAttr {
|
|
|
390
355
|
gap?: string;
|
|
391
356
|
padding?: string;
|
|
392
357
|
background?: string;
|
|
358
|
+
/**
|
|
359
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
360
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
361
|
+
* line; in a column it takes the full width.
|
|
362
|
+
*/
|
|
393
363
|
width?: string;
|
|
394
364
|
height?: string;
|
|
395
365
|
paginate?: string;
|
|
@@ -410,6 +380,11 @@ export interface FieldAttr {
|
|
|
410
380
|
readonly?: string;
|
|
411
381
|
maxLen?: string;
|
|
412
382
|
actionUrl?: string;
|
|
383
|
+
/**
|
|
384
|
+
* Width of the element. A length fixes it. fill, in a row, takes the width its line leaves after
|
|
385
|
+
* the other children, shared equally if several on the line use fill, and never moves to the next
|
|
386
|
+
* line; in a column it takes the full width.
|
|
387
|
+
*/
|
|
413
388
|
width?: string;
|
|
414
389
|
height?: string;
|
|
415
390
|
background?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
5
|
export type { PdfDocument, LpdfSectionNode, LpdfLayoutBlock, LpdfCanvasBlock, DocumentTokens, DocumentAssets, DocumentMeta, SectionAttr, DocumentAttr, } from './kit';
|
|
6
|
-
export type {
|
|
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, CanvasTextAttr, CanvasImgAttr, FontAttr, ImageAttr, } 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
9
|
export type { LpdfCanvasLayerNode, LpdfCanvasPrimitiveNode, LpdfCanvasRectNode, LpdfCanvasLineNode, LpdfCanvasEllipseNode, LpdfCanvasCircleNode, LpdfCanvasPathNode, LpdfCanvasTextNode, LpdfCanvasImgNode, } from './canvas';
|
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_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.26.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",
|