@lpdfio/lpdf 0.22.0 → 0.23.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 +5 -5
- package/dist/L.d.ts +34 -33
- package/dist/L.js +2 -1
- package/dist/_shared.d.ts +4 -3
- package/dist/_shared.js +15 -0
- package/dist/attrs.d.ts +493 -0
- package/dist/attrs.js +4 -0
- package/dist/browser.js +47 -0
- package/dist/canvas.d.ts +24 -87
- package/dist/canvas.js +22 -134
- package/dist/constants.d.ts +50 -0
- package/dist/constants.js +50 -0
- package/dist/engine.js +19 -15
- package/dist/index.d.ts +5 -4
- package/dist/index.js +8 -1
- package/dist/kit.d.ts +19 -16
- package/dist/kit.js +10 -20
- package/dist/layout.d.ts +18 -203
- package/dist/layout.js +37 -92
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @lpdfio/lpdf
|
|
4
4
|
|
|
5
|
-
**Node.js SDK for [Lpdf](https://lpdf.io?
|
|
5
|
+
**Node.js SDK for [Lpdf](https://lpdf.io?utm_campaign=sdk-node&utm_medium=referral&utm_source=readme) — PDF as Code on every platform**
|
|
6
6
|
|
|
7
7
|
You describe a document as code or XML. Lpdf renders a compact, pixel-perfect PDF — identical across platforms.
|
|
8
8
|
|
|
@@ -14,8 +14,8 @@ npm install @lpdfio/lpdf
|
|
|
14
14
|
|
|
15
15
|
## Usage — Node.js
|
|
16
16
|
|
|
17
|
-
```
|
|
18
|
-
|
|
17
|
+
```js
|
|
18
|
+
const { L, NoAttr } = require('@lpdfio/lpdf')
|
|
19
19
|
|
|
20
20
|
const engine = L.engine()
|
|
21
21
|
|
|
@@ -38,7 +38,7 @@ const doc = L.document({ size: 'letter', margin: '48pt' }, [
|
|
|
38
38
|
]),
|
|
39
39
|
])
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
engine.render(doc).then((pdf) => require('node:fs').writeFileSync('proposal.pdf', pdf))
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## Requirements
|
|
@@ -48,7 +48,7 @@ const pdf = await engine.render(doc)
|
|
|
48
48
|
|
|
49
49
|
## Docs
|
|
50
50
|
|
|
51
|
-
[lpdf.io/docs](https://lpdf.io/docs/?sdk=js&
|
|
51
|
+
[lpdf.io/docs](https://lpdf.io/docs/install/?sdk=js&utm_campaign=sdk-node&utm_medium=referral&utm_source=readme)
|
|
52
52
|
|
|
53
53
|
## Issues
|
|
54
54
|
|
package/dist/L.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DocumentAssets, DocumentTokens, PdfDocument } from './kit';
|
|
2
2
|
import { PdfEngine } from './engine';
|
|
3
3
|
/** Pass as `attrs` when a node has no attributes. Equivalent to `null`. */
|
|
4
4
|
export declare const NoAttr: null;
|
|
@@ -11,7 +11,7 @@ export declare const NoAttr: null;
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
-
*
|
|
14
|
+
* const { L, NoAttr } = require('@lpdfio/lpdf');
|
|
15
15
|
*
|
|
16
16
|
* const engine = L.engine().setLicenseKey(process.env.LPDF_KEY);
|
|
17
17
|
*
|
|
@@ -29,35 +29,36 @@ export declare const L: Readonly<{
|
|
|
29
29
|
engine: () => PdfEngine;
|
|
30
30
|
/** Convert a `PdfDocument` tree to an lpdf XML string. */
|
|
31
31
|
toXml: (doc: PdfDocument) => string;
|
|
32
|
-
document: (attrs: import("./kit").DocumentAttr | null, nodes
|
|
33
|
-
section: (attrs: import("./kit").SectionAttr | null, nodes
|
|
34
|
-
layout: (_attrs: null, nodes
|
|
35
|
-
canvas: (_attrs: null, layers
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
32
|
+
document: (attrs: import("./kit").DocumentAttr | null, nodes?: import("./kit").LpdfSectionNode[]) => PdfDocument;
|
|
33
|
+
section: (attrs: import("./kit").SectionAttr | null, nodes?: (import("./kit").LpdfLayoutBlock | import("./kit").LpdfCanvasBlock)[]) => import("./kit").LpdfSectionNode;
|
|
34
|
+
layout: (_attrs: null, nodes?: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
|
|
35
|
+
canvas: (_attrs: null, layers?: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
|
|
36
|
+
assets: (attrs: DocumentAssets) => DocumentAssets;
|
|
37
|
+
tokens: (attrs: DocumentTokens) => DocumentTokens;
|
|
38
|
+
stack: (attrs: import("./attrs").StackAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
39
|
+
flank: (attrs: import("./attrs").FlankAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
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;
|
|
42
|
+
grid: (attrs: import("./attrs").GridAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
43
|
+
frame: (attrs: import("./attrs").FrameAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
44
|
+
link: (attrs: import("./attrs").LinkAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
45
|
+
table: (attrs: import("./attrs").TableAttr, nodes?: (import("./layout").LpdfTheadNode | import("./layout").LpdfTrNode)[]) => import("./layout").LpdfTableNode;
|
|
46
|
+
thead: (attrs: import("./attrs").TheadAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTheadNode;
|
|
47
|
+
tr: (attrs: import("./attrs").TrAttr | null, nodes?: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTrNode;
|
|
48
|
+
td: (attrs: import("./attrs").TdAttr | null, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfTdNode;
|
|
49
|
+
text: (attrs: import("./attrs").TextAttr | null, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfTextNode;
|
|
50
|
+
span: (attrs: import("./attrs").SpanAttr | null, nodes?: string[]) => import("./layout").LpdfSpanNode;
|
|
51
|
+
divider: (attrs?: import("./attrs").DividerAttr | null) => import("./layout").LpdfDividerNode;
|
|
52
|
+
img: (attrs: import("./attrs").ImgAttr) => import("./layout").LpdfImgNode;
|
|
53
|
+
barcode: (attrs: import("./attrs").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
|
|
54
|
+
region: (attrs: import("./attrs").RegionAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
|
|
55
|
+
field: (attrs: import("./attrs").FieldAttr) => import("./layout").LpdfFieldNode;
|
|
56
|
+
layer: (attrs: import("./attrs").LayerAttr | null, nodes?: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
|
|
57
|
+
rect: (attrs: import("./attrs").RectAttr) => import("./canvas").LpdfCanvasRectNode;
|
|
58
|
+
line: (attrs: import("./attrs").LineAttr) => import("./canvas").LpdfCanvasLineNode;
|
|
59
|
+
ellipse: (attrs: import("./attrs").EllipseAttr) => import("./canvas").LpdfCanvasEllipseNode;
|
|
60
|
+
circle: (attrs: import("./attrs").CircleAttr) => import("./canvas").LpdfCanvasCircleNode;
|
|
61
|
+
path: (attrs: import("./attrs").PathAttr) => import("./canvas").LpdfCanvasPathNode;
|
|
62
|
+
textAt: (attrs: import("./attrs").CanvasTextAttr, nodes?: (string | import("./layout").LpdfSpanNode)[]) => import("./canvas").LpdfCanvasTextNode;
|
|
63
|
+
imgAt: (attrs: import("./attrs").CanvasImgAttr) => import("./canvas").LpdfCanvasImgNode;
|
|
63
64
|
}>;
|
package/dist/L.js
CHANGED
|
@@ -17,7 +17,7 @@ exports.NoAttr = null;
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
|
-
*
|
|
20
|
+
* const { L, NoAttr } = require('@lpdfio/lpdf');
|
|
21
21
|
*
|
|
22
22
|
* const engine = L.engine().setLicenseKey(process.env.LPDF_KEY);
|
|
23
23
|
*
|
|
@@ -40,6 +40,7 @@ exports.L = Object.freeze({
|
|
|
40
40
|
section: kit_1.LpdfKit.section,
|
|
41
41
|
layout: kit_1.LpdfKit.layout,
|
|
42
42
|
canvas: kit_1.LpdfKit.canvas,
|
|
43
|
+
assets: (attrs) => attrs,
|
|
43
44
|
tokens: (attrs) => attrs,
|
|
44
45
|
// ── Layout ────────────────────────────────────────────────────────────────
|
|
45
46
|
stack: layout_1.LpdfLayout.stack,
|
package/dist/_shared.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export interface RenderOptions {
|
|
|
19
19
|
data?: Record<string, unknown> | null;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* The attributes of an element: an attribute object's own properties, with each camelCase name
|
|
23
|
+
* written as the schema's kebab-case one (`fontSize` as `font-size`) and each value as a string.
|
|
24
|
+
* Properties that are `undefined` are left out.
|
|
24
25
|
*/
|
|
25
|
-
export
|
|
26
|
+
export declare function buildAttrs(options: object | null | undefined): Record<string, string>;
|
package/dist/_shared.js
CHANGED
|
@@ -3,3 +3,18 @@
|
|
|
3
3
|
* Shared types used by both the Node.js and browser entry points.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildAttrs = buildAttrs;
|
|
7
|
+
/**
|
|
8
|
+
* The attributes of an element: an attribute object's own properties, with each camelCase name
|
|
9
|
+
* written as the schema's kebab-case one (`fontSize` as `font-size`) and each value as a string.
|
|
10
|
+
* Properties that are `undefined` are left out.
|
|
11
|
+
*/
|
|
12
|
+
function buildAttrs(options) {
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const [key, value] of Object.entries(options ?? {})) {
|
|
15
|
+
if (value !== undefined && value !== null) {
|
|
16
|
+
result[key.replace(/[A-Z]/g, c => '-' + c.toLowerCase())] = String(value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
package/dist/attrs.d.ts
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Places children top to bottom, each at the full width, with gap between them. Can split across
|
|
3
|
+
* pages between children.
|
|
4
|
+
*/
|
|
5
|
+
export interface StackAttr {
|
|
6
|
+
font?: string;
|
|
7
|
+
fontSize?: string;
|
|
8
|
+
gap?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
11
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
12
|
+
* bottom and left.
|
|
13
|
+
*/
|
|
14
|
+
padding?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
17
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
18
|
+
* available. Any of these stops the box splitting across pages.
|
|
19
|
+
*/
|
|
20
|
+
height?: string;
|
|
21
|
+
background?: string;
|
|
22
|
+
border?: string;
|
|
23
|
+
radius?: string;
|
|
24
|
+
debug?: string;
|
|
25
|
+
align?: string;
|
|
26
|
+
justify?: string;
|
|
27
|
+
width?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One row where the children keep their own width except one, which fills the rest. By default the
|
|
31
|
+
* last child fills; set end to true and the first fills. Never splits across pages.
|
|
32
|
+
*/
|
|
33
|
+
export interface FlankAttr {
|
|
34
|
+
font?: string;
|
|
35
|
+
fontSize?: string;
|
|
36
|
+
gap?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
39
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
40
|
+
* bottom and left.
|
|
41
|
+
*/
|
|
42
|
+
padding?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
45
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
46
|
+
* available. Any of these stops the box splitting across pages.
|
|
47
|
+
*/
|
|
48
|
+
height?: string;
|
|
49
|
+
background?: string;
|
|
50
|
+
border?: string;
|
|
51
|
+
radius?: string;
|
|
52
|
+
debug?: string;
|
|
53
|
+
align?: string;
|
|
54
|
+
/**
|
|
55
|
+
* false (the default): every child but the last keeps its own width at the left, and the last
|
|
56
|
+
* fills the rest. true: the first child fills, and the others keep their own width at the right.
|
|
57
|
+
*/
|
|
58
|
+
end?: string;
|
|
59
|
+
width?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Two children side by side; any further children are ignored. By default each keeps its own width,
|
|
63
|
+
* the first at the left edge and the second at the right. With equal set to true they take half the
|
|
64
|
+
* width each. Never splits across pages.
|
|
65
|
+
*/
|
|
66
|
+
export interface SplitAttr {
|
|
67
|
+
font?: string;
|
|
68
|
+
fontSize?: string;
|
|
69
|
+
gap?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
72
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
73
|
+
* bottom and left.
|
|
74
|
+
*/
|
|
75
|
+
padding?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
78
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
79
|
+
* available. Any of these stops the box splitting across pages.
|
|
80
|
+
*/
|
|
81
|
+
height?: string;
|
|
82
|
+
background?: string;
|
|
83
|
+
border?: string;
|
|
84
|
+
radius?: string;
|
|
85
|
+
debug?: string;
|
|
86
|
+
align?: string;
|
|
87
|
+
/**
|
|
88
|
+
* false (the default): each child keeps its own width, the first at the left edge and the second
|
|
89
|
+
* at the right edge. true: the two children share the width in equal halves.
|
|
90
|
+
*/
|
|
91
|
+
equal?: string;
|
|
92
|
+
width?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A row that wraps: children sit side by side, and continue on the next line when they run out of
|
|
96
|
+
* width. Splits across pages between lines.
|
|
97
|
+
*/
|
|
98
|
+
export interface ClusterAttr {
|
|
99
|
+
font?: string;
|
|
100
|
+
fontSize?: string;
|
|
101
|
+
gap?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
104
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
105
|
+
* bottom and left.
|
|
106
|
+
*/
|
|
107
|
+
padding?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
110
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
111
|
+
* available. Any of these stops the box splitting across pages.
|
|
112
|
+
*/
|
|
113
|
+
height?: string;
|
|
114
|
+
background?: string;
|
|
115
|
+
border?: string;
|
|
116
|
+
radius?: string;
|
|
117
|
+
debug?: string;
|
|
118
|
+
align?: string;
|
|
119
|
+
justify?: string;
|
|
120
|
+
width?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Fills a fixed number of equal columns from left to right, then starts a new row. A row never
|
|
124
|
+
* splits across pages. For data with a header row, use table.
|
|
125
|
+
*/
|
|
126
|
+
export interface GridAttr {
|
|
127
|
+
font?: string;
|
|
128
|
+
fontSize?: string;
|
|
129
|
+
gap?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
132
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
133
|
+
* bottom and left.
|
|
134
|
+
*/
|
|
135
|
+
padding?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
138
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
139
|
+
* available. Any of these stops the box splitting across pages.
|
|
140
|
+
*/
|
|
141
|
+
height?: string;
|
|
142
|
+
background?: string;
|
|
143
|
+
border?: string;
|
|
144
|
+
radius?: string;
|
|
145
|
+
debug?: string;
|
|
146
|
+
width?: string;
|
|
147
|
+
colWidth?: string;
|
|
148
|
+
cols?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A box around a single child, which it centres. Never splits across pages: if it does not fit, the
|
|
152
|
+
* whole box moves to the next page.
|
|
153
|
+
*/
|
|
154
|
+
export interface FrameAttr {
|
|
155
|
+
font?: string;
|
|
156
|
+
fontSize?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
159
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
160
|
+
* bottom and left.
|
|
161
|
+
*/
|
|
162
|
+
padding?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
165
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
166
|
+
* available. Any of these stops the box splitting across pages.
|
|
167
|
+
*/
|
|
168
|
+
height?: string;
|
|
169
|
+
background?: string;
|
|
170
|
+
border?: string;
|
|
171
|
+
radius?: string;
|
|
172
|
+
debug?: string;
|
|
173
|
+
width?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Attributes of the `link` element.
|
|
177
|
+
*/
|
|
178
|
+
export interface LinkAttr {
|
|
179
|
+
href: string;
|
|
180
|
+
gap?: string;
|
|
181
|
+
width?: string;
|
|
182
|
+
height?: string;
|
|
183
|
+
debug?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Attributes of the `divider` element.
|
|
187
|
+
*/
|
|
188
|
+
export interface DividerAttr {
|
|
189
|
+
direction?: string;
|
|
190
|
+
color?: string;
|
|
191
|
+
thickness?: string;
|
|
192
|
+
debug?: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Attributes of the `span` element.
|
|
196
|
+
*/
|
|
197
|
+
export interface SpanAttr {
|
|
198
|
+
font?: string;
|
|
199
|
+
bold?: string;
|
|
200
|
+
color?: string;
|
|
201
|
+
href?: string;
|
|
202
|
+
underline?: string;
|
|
203
|
+
strike?: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Attributes of the `img` element.
|
|
207
|
+
*/
|
|
208
|
+
export interface ImgAttr {
|
|
209
|
+
name: string;
|
|
210
|
+
height?: string;
|
|
211
|
+
width?: string;
|
|
212
|
+
font?: string;
|
|
213
|
+
fontSize?: string;
|
|
214
|
+
gap?: string;
|
|
215
|
+
padding?: string;
|
|
216
|
+
background?: string;
|
|
217
|
+
border?: string;
|
|
218
|
+
radius?: string;
|
|
219
|
+
debug?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Attributes of the `barcode` element.
|
|
223
|
+
*/
|
|
224
|
+
export interface BarcodeAttr {
|
|
225
|
+
type: string;
|
|
226
|
+
data: string;
|
|
227
|
+
size?: string;
|
|
228
|
+
width?: string;
|
|
229
|
+
height?: string;
|
|
230
|
+
ec?: string;
|
|
231
|
+
hrt?: string;
|
|
232
|
+
color?: string;
|
|
233
|
+
background?: string;
|
|
234
|
+
debug?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A block of wrapping text. Use span children to style parts of it. Splits across pages between
|
|
238
|
+
* lines.
|
|
239
|
+
*/
|
|
240
|
+
export interface TextAttr {
|
|
241
|
+
fontSize?: string;
|
|
242
|
+
font?: string;
|
|
243
|
+
/**
|
|
244
|
+
* Use the bold face of the font. It applies to the 14 built-in fonts: Helvetica becomes
|
|
245
|
+
* Helvetica-Bold, Times-Roman becomes Times-Bold, Courier becomes Courier-Bold, and the oblique
|
|
246
|
+
* and italic faces their bold forms. A custom font has no bold face to pick, so name one in font.
|
|
247
|
+
*/
|
|
248
|
+
bold?: string;
|
|
249
|
+
color?: string;
|
|
250
|
+
align?: string;
|
|
251
|
+
width?: string;
|
|
252
|
+
debug?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Attributes of the `td` element.
|
|
256
|
+
*/
|
|
257
|
+
export interface TdAttr {
|
|
258
|
+
font?: string;
|
|
259
|
+
fontSize?: string;
|
|
260
|
+
gap?: string;
|
|
261
|
+
/**
|
|
262
|
+
* Space between the edge of the box and its content, written like CSS: one value for all sides,
|
|
263
|
+
* two for top-bottom and left-right, three for top, left-right and bottom, four for top, right,
|
|
264
|
+
* bottom and left.
|
|
265
|
+
*/
|
|
266
|
+
padding?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Height of the box. Leave it out to size to the content. A length fixes it; fill takes what is
|
|
269
|
+
* left after its siblings (shared equally if several use fill); full takes all the height
|
|
270
|
+
* available. Any of these stops the box splitting across pages.
|
|
271
|
+
*/
|
|
272
|
+
height?: string;
|
|
273
|
+
background?: string;
|
|
274
|
+
border?: string;
|
|
275
|
+
radius?: string;
|
|
276
|
+
debug?: string;
|
|
277
|
+
align?: string;
|
|
278
|
+
valign?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Attributes of the `thead` element.
|
|
282
|
+
*/
|
|
283
|
+
export interface TheadAttr {
|
|
284
|
+
background?: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Attributes of the `tr` element.
|
|
288
|
+
*/
|
|
289
|
+
export interface TrAttr {
|
|
290
|
+
background?: string;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Rows and cells in columns whose widths are set by cols. The thead row repeats at the top of every
|
|
294
|
+
* page, and rows move between pages whole.
|
|
295
|
+
*/
|
|
296
|
+
export interface TableAttr {
|
|
297
|
+
/**
|
|
298
|
+
* Column widths, separated by spaces, in fr, pt or % units: for example 2fr 1fr 120pt 20%.
|
|
299
|
+
*/
|
|
300
|
+
cols: string;
|
|
301
|
+
border?: string;
|
|
302
|
+
stripe?: string;
|
|
303
|
+
gap?: string;
|
|
304
|
+
padding?: string;
|
|
305
|
+
background?: string;
|
|
306
|
+
width?: string;
|
|
307
|
+
height?: string;
|
|
308
|
+
debug?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Attributes of the `field` element.
|
|
312
|
+
*/
|
|
313
|
+
export interface FieldAttr {
|
|
314
|
+
type: string;
|
|
315
|
+
name: string;
|
|
316
|
+
value?: string;
|
|
317
|
+
label?: string;
|
|
318
|
+
options?: string;
|
|
319
|
+
group?: string;
|
|
320
|
+
checked?: string;
|
|
321
|
+
required?: string;
|
|
322
|
+
readonly?: string;
|
|
323
|
+
maxLen?: string;
|
|
324
|
+
actionUrl?: string;
|
|
325
|
+
width?: string;
|
|
326
|
+
height?: string;
|
|
327
|
+
background?: string;
|
|
328
|
+
border?: string;
|
|
329
|
+
debug?: string;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Pins content to the top or bottom edge of pages, outside the normal flow, for headers and
|
|
333
|
+
* footers. It reserves that space on every page it appears on. Only allowed directly inside layout,
|
|
334
|
+
* and one per pin on a page.
|
|
335
|
+
*/
|
|
336
|
+
export interface RegionAttr {
|
|
337
|
+
/**
|
|
338
|
+
* Which edge the region sticks to. top and bottom work. left and right pass validation but are
|
|
339
|
+
* not implemented yet.
|
|
340
|
+
*/
|
|
341
|
+
pin: string;
|
|
342
|
+
/**
|
|
343
|
+
* Which pages show the region: each, first, last, odd, even, or a range such as 2-last. Defaults
|
|
344
|
+
* to each.
|
|
345
|
+
*/
|
|
346
|
+
page?: string;
|
|
347
|
+
w?: string;
|
|
348
|
+
debug?: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Groups canvas shapes and sets what applies to all of them: which pages they appear on, opacity,
|
|
352
|
+
* transform and clip. Layers cannot be nested.
|
|
353
|
+
*/
|
|
354
|
+
export interface LayerAttr {
|
|
355
|
+
page?: string;
|
|
356
|
+
opacity?: string;
|
|
357
|
+
transform?: string;
|
|
358
|
+
clip?: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Attributes of the `rect` element on the canvas.
|
|
362
|
+
*/
|
|
363
|
+
export interface RectAttr {
|
|
364
|
+
w: string;
|
|
365
|
+
h: string;
|
|
366
|
+
x?: string;
|
|
367
|
+
y?: string;
|
|
368
|
+
anchor?: string;
|
|
369
|
+
radius?: string;
|
|
370
|
+
fill?: string;
|
|
371
|
+
stroke?: string;
|
|
372
|
+
strokeWidth?: string;
|
|
373
|
+
strokeDash?: string;
|
|
374
|
+
opacity?: string;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Attributes of the `circle` element on the canvas.
|
|
378
|
+
*/
|
|
379
|
+
export interface CircleAttr {
|
|
380
|
+
r: string;
|
|
381
|
+
cx?: string;
|
|
382
|
+
cy?: string;
|
|
383
|
+
anchor?: string;
|
|
384
|
+
fill?: string;
|
|
385
|
+
stroke?: string;
|
|
386
|
+
strokeWidth?: string;
|
|
387
|
+
strokeDash?: string;
|
|
388
|
+
opacity?: string;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Attributes of the `ellipse` element on the canvas.
|
|
392
|
+
*/
|
|
393
|
+
export interface EllipseAttr {
|
|
394
|
+
rx: string;
|
|
395
|
+
ry: string;
|
|
396
|
+
cx?: string;
|
|
397
|
+
cy?: string;
|
|
398
|
+
anchor?: string;
|
|
399
|
+
fill?: string;
|
|
400
|
+
stroke?: string;
|
|
401
|
+
strokeWidth?: string;
|
|
402
|
+
strokeDash?: string;
|
|
403
|
+
opacity?: string;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Attributes of the `line` element on the canvas.
|
|
407
|
+
*/
|
|
408
|
+
export interface LineAttr {
|
|
409
|
+
x1: string;
|
|
410
|
+
y1: string;
|
|
411
|
+
x2: string;
|
|
412
|
+
y2: string;
|
|
413
|
+
stroke?: string;
|
|
414
|
+
strokeWidth?: string;
|
|
415
|
+
strokeDash?: string;
|
|
416
|
+
lineCap?: string;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Attributes of the `path` element on the canvas.
|
|
420
|
+
*/
|
|
421
|
+
export interface PathAttr {
|
|
422
|
+
d: string;
|
|
423
|
+
fill?: string;
|
|
424
|
+
stroke?: string;
|
|
425
|
+
fillRule?: string;
|
|
426
|
+
strokeWidth?: string;
|
|
427
|
+
strokeDash?: string;
|
|
428
|
+
lineCap?: string;
|
|
429
|
+
opacity?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Text at an exact position on the page: either x and y, or an anchor with optional offsets.
|
|
433
|
+
*/
|
|
434
|
+
export interface CanvasTextAttr {
|
|
435
|
+
x?: string;
|
|
436
|
+
y?: string;
|
|
437
|
+
anchor?: string;
|
|
438
|
+
font?: string;
|
|
439
|
+
fontSize?: string;
|
|
440
|
+
color?: string;
|
|
441
|
+
align?: string;
|
|
442
|
+
w?: string;
|
|
443
|
+
lineHeight?: string;
|
|
444
|
+
opacity?: string;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Attributes of the `img` element on the canvas.
|
|
448
|
+
*/
|
|
449
|
+
export interface CanvasImgAttr {
|
|
450
|
+
name: string;
|
|
451
|
+
w: string;
|
|
452
|
+
h: string;
|
|
453
|
+
x?: string;
|
|
454
|
+
y?: string;
|
|
455
|
+
anchor?: string;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Declares a font that text can be set in by name, with the font attribute. A built-in PDF font is
|
|
459
|
+
* named by core; any other font is a file the SDK reads from src, or one loaded on the engine under
|
|
460
|
+
* ref or, with no ref, under the font's own name.
|
|
461
|
+
*/
|
|
462
|
+
export interface FontAttr {
|
|
463
|
+
/**
|
|
464
|
+
* The name that the font attribute of a text uses to pick this font: lowercase letters, digits
|
|
465
|
+
* and -, starting with a letter.
|
|
466
|
+
*/
|
|
467
|
+
name: string;
|
|
468
|
+
/** A built-in PDF font, which needs no file. */
|
|
469
|
+
core?: string;
|
|
470
|
+
/** The key the font was loaded under on the engine, when that is not its name. */
|
|
471
|
+
ref?: string;
|
|
472
|
+
/**
|
|
473
|
+
* A path the SDK reads the font file from, when the font was not loaded on the engine.
|
|
474
|
+
*/
|
|
475
|
+
src?: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Declares an image that an img refers to by name. The SDK reads the file from src, or the image
|
|
479
|
+
* was loaded on the engine under ref or, with no ref, under its own name.
|
|
480
|
+
*/
|
|
481
|
+
export interface ImageAttr {
|
|
482
|
+
/**
|
|
483
|
+
* The name that the name attribute of an img uses to pick this image: lowercase letters, digits
|
|
484
|
+
* and -, starting with a letter.
|
|
485
|
+
*/
|
|
486
|
+
name: string;
|
|
487
|
+
/** The key the image was loaded under on the engine, when that is not its name. */
|
|
488
|
+
ref?: string;
|
|
489
|
+
/**
|
|
490
|
+
* A path the SDK reads the image file from, when the image was not loaded on the engine.
|
|
491
|
+
*/
|
|
492
|
+
src?: string;
|
|
493
|
+
}
|
package/dist/attrs.js
ADDED