@lpdfio/lpdf 0.24.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 +4 -5
- package/dist/L.js +3 -4
- package/dist/attrs.d.ts +101 -84
- package/dist/browser.js +4 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/kit.d.ts +5 -3
- package/dist/layout.d.ts +18 -11
- package/dist/layout.js +14 -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
|
@@ -30,15 +30,13 @@ 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?: (import("./kit").LpdfLayoutBlock | import("./kit").LpdfCanvasBlock)[]) => import("./kit").LpdfSectionNode;
|
|
33
|
+
section: (attrs: import("./kit").SectionAttr | null, nodes?: (import("./layout").LpdfBookmarkNode | import("./kit").LpdfLayoutBlock | import("./kit").LpdfCanvasBlock)[]) => import("./kit").LpdfSectionNode;
|
|
34
34
|
layout: (_attrs: null, nodes?: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
|
|
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;
|
|
@@ -53,6 +51,7 @@ export declare const L: Readonly<{
|
|
|
53
51
|
barcode: (attrs: import("./attrs").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
|
|
54
52
|
region: (attrs: import("./attrs").RegionAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
|
|
55
53
|
field: (attrs: import("./attrs").FieldAttr) => import("./layout").LpdfFieldNode;
|
|
54
|
+
bookmark: (attrs: import("./attrs").BookmarkAttr) => import("./layout").LpdfBookmarkNode;
|
|
56
55
|
layer: (attrs: import("./attrs").LayerAttr | null, nodes?: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
|
|
57
56
|
rect: (attrs: import("./attrs").RectAttr) => import("./canvas").LpdfCanvasRectNode;
|
|
58
57
|
line: (attrs: import("./attrs").LineAttr) => import("./canvas").LpdfCanvasLineNode;
|
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,
|
|
@@ -61,6 +59,7 @@ exports.L = Object.freeze({
|
|
|
61
59
|
barcode: layout_1.LpdfLayout.barcode,
|
|
62
60
|
region: layout_1.LpdfLayout.region,
|
|
63
61
|
field: layout_1.LpdfLayout.field,
|
|
62
|
+
bookmark: layout_1.LpdfLayout.bookmark,
|
|
64
63
|
// ── Canvas ────────────────────────────────────────────────────────────────
|
|
65
64
|
layer: canvas_1.LpdfCanvas.layer,
|
|
66
65
|
rect: canvas_1.LpdfCanvas.rect,
|
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
|
-
/**
|
|
62
|
-
* Where the box falls in the page flow. no: never split the box, and move it whole to the next
|
|
63
|
-
* page when it does not fit. break-before: start it on a new page. break-after: start the next
|
|
64
|
-
* sibling on a new page. keep-next: keep it on one page with the sibling that follows, moving
|
|
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
36
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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,14 +158,28 @@ 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
|
/**
|
|
230
169
|
* Attributes of the `link` element.
|
|
231
170
|
*/
|
|
232
171
|
export interface LinkAttr {
|
|
172
|
+
/**
|
|
173
|
+
* Where the link goes: a URL, or #id to jump to the bookmark with that id. In an entry of a table
|
|
174
|
+
* of contents, # alone jumps to that entry's bookmark.
|
|
175
|
+
*/
|
|
233
176
|
href: string;
|
|
234
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
|
+
*/
|
|
235
183
|
width?: string;
|
|
236
184
|
height?: string;
|
|
237
185
|
debug?: string;
|
|
@@ -243,6 +191,12 @@ export interface DividerAttr {
|
|
|
243
191
|
direction?: string;
|
|
244
192
|
color?: string;
|
|
245
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;
|
|
246
200
|
debug?: string;
|
|
247
201
|
}
|
|
248
202
|
/**
|
|
@@ -252,6 +206,10 @@ export interface SpanAttr {
|
|
|
252
206
|
font?: string;
|
|
253
207
|
bold?: string;
|
|
254
208
|
color?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Makes the span a link: a URL, or #id to jump to the bookmark with that id. In an entry of a
|
|
211
|
+
* table of contents, # alone jumps to that entry's bookmark.
|
|
212
|
+
*/
|
|
255
213
|
href?: string;
|
|
256
214
|
underline?: string;
|
|
257
215
|
strike?: string;
|
|
@@ -262,6 +220,11 @@ export interface SpanAttr {
|
|
|
262
220
|
export interface ImgAttr {
|
|
263
221
|
name: string;
|
|
264
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
|
+
*/
|
|
265
228
|
width?: string;
|
|
266
229
|
font?: string;
|
|
267
230
|
fontSize?: string;
|
|
@@ -280,6 +243,11 @@ export interface BarcodeAttr {
|
|
|
280
243
|
type: string;
|
|
281
244
|
data: string;
|
|
282
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
|
+
*/
|
|
283
251
|
width?: string;
|
|
284
252
|
height?: string;
|
|
285
253
|
ec?: string;
|
|
@@ -304,7 +272,25 @@ export interface TextAttr {
|
|
|
304
272
|
bold?: string;
|
|
305
273
|
color?: string;
|
|
306
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
|
+
*/
|
|
307
280
|
width?: string;
|
|
281
|
+
/**
|
|
282
|
+
* The fewest lines of the text that may stand alone at the top of the next page when it splits.
|
|
283
|
+
* Default 2. If fewer would be left, lines move from the first page to the next; 1 turns the
|
|
284
|
+
* protection off.
|
|
285
|
+
*/
|
|
286
|
+
widows?: string;
|
|
287
|
+
/**
|
|
288
|
+
* The fewest lines of the text that may stand alone at the bottom of a page when it splits.
|
|
289
|
+
* Default 2. If fewer would fit, the whole text moves to the next page; 1 turns the protection
|
|
290
|
+
* off. When no split can keep both widows and orphans, even on an empty page, the text splits
|
|
291
|
+
* where the lines fit.
|
|
292
|
+
*/
|
|
293
|
+
orphans?: string;
|
|
308
294
|
paginate?: string;
|
|
309
295
|
debug?: string;
|
|
310
296
|
}
|
|
@@ -369,6 +355,11 @@ export interface TableAttr {
|
|
|
369
355
|
gap?: string;
|
|
370
356
|
padding?: string;
|
|
371
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
|
+
*/
|
|
372
363
|
width?: string;
|
|
373
364
|
height?: string;
|
|
374
365
|
paginate?: string;
|
|
@@ -389,12 +380,38 @@ export interface FieldAttr {
|
|
|
389
380
|
readonly?: string;
|
|
390
381
|
maxLen?: string;
|
|
391
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
|
+
*/
|
|
392
388
|
width?: string;
|
|
393
389
|
height?: string;
|
|
394
390
|
background?: string;
|
|
395
391
|
border?: string;
|
|
396
392
|
debug?: string;
|
|
397
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* An entry of the PDF's outline, the bookmark panel of a viewer, and a target for links with
|
|
396
|
+
* href="#id". It draws nothing and marks the element that follows it, so it is never left at the
|
|
397
|
+
* bottom of a page apart from that element. Directly inside a section, it marks the section's first
|
|
398
|
+
* page.
|
|
399
|
+
*/
|
|
400
|
+
export interface BookmarkAttr {
|
|
401
|
+
/** The text of the entry, in the outline and in a table of contents. */
|
|
402
|
+
label: string;
|
|
403
|
+
/**
|
|
404
|
+
* Depth in the outline, 1 to 6. Defaults to 1. An entry nests under the closest entry before it
|
|
405
|
+
* with a lower level.
|
|
406
|
+
*/
|
|
407
|
+
level?: string;
|
|
408
|
+
/**
|
|
409
|
+
* The name links use to jump here, as href="#id". Leave it out to make it from the label:
|
|
410
|
+
* lowercase, with other characters than letters and digits turned into hyphens, and -2, -3 added
|
|
411
|
+
* when an earlier bookmark has it. Two bookmarks may not have the same id.
|
|
412
|
+
*/
|
|
413
|
+
id?: string;
|
|
414
|
+
}
|
|
398
415
|
/**
|
|
399
416
|
* Pins content to the top or bottom edge of pages, outside the normal flow, for headers and
|
|
400
417
|
* footers. It reserves that space on every page it appears on. Only allowed directly inside layout,
|
package/dist/browser.js
CHANGED
|
@@ -410,6 +410,9 @@ var Orientation = {
|
|
|
410
410
|
Portrait: "portrait",
|
|
411
411
|
Landscape: "landscape"
|
|
412
412
|
};
|
|
413
|
+
var SectionType = {
|
|
414
|
+
Toc: "toc"
|
|
415
|
+
};
|
|
413
416
|
var BuiltinFont = {
|
|
414
417
|
Courier: "Courier",
|
|
415
418
|
CourierBold: "Courier-Bold",
|
|
@@ -491,5 +494,6 @@ export {
|
|
|
491
494
|
Orientation,
|
|
492
495
|
PageScope,
|
|
493
496
|
Pin,
|
|
497
|
+
SectionType,
|
|
494
498
|
initLpdf
|
|
495
499
|
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export declare const Orientation: {
|
|
|
21
21
|
readonly Landscape: "landscape";
|
|
22
22
|
};
|
|
23
23
|
export type Orientation = (typeof Orientation)[keyof typeof Orientation];
|
|
24
|
+
/** The values of the `type` attribute of a section. */
|
|
25
|
+
export declare const SectionType: {
|
|
26
|
+
readonly Toc: "toc";
|
|
27
|
+
};
|
|
28
|
+
export type SectionType = (typeof SectionType)[keyof typeof SectionType];
|
|
24
29
|
/** The values of the `core` attribute of a font: the built-in PDF fonts, which need no file. */
|
|
25
30
|
export declare const BuiltinFont: {
|
|
26
31
|
readonly Courier: "Courier";
|
package/dist/constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Generated from lpdf.xsd by scripts/gen-sdk-api.mjs.
|
|
3
3
|
// Do not edit: change the schema and run `make gen-sdk-api`.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.PageScope = exports.BuiltinFont = exports.Orientation = exports.Pin = exports.FieldType = void 0;
|
|
5
|
+
exports.PageScope = exports.BuiltinFont = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = void 0;
|
|
6
6
|
/** The values of the `type` attribute of a field. */
|
|
7
7
|
exports.FieldType = {
|
|
8
8
|
Text: 'text',
|
|
@@ -23,6 +23,10 @@ exports.Orientation = {
|
|
|
23
23
|
Portrait: 'portrait',
|
|
24
24
|
Landscape: 'landscape',
|
|
25
25
|
};
|
|
26
|
+
/** The values of the `type` attribute of a section. */
|
|
27
|
+
exports.SectionType = {
|
|
28
|
+
Toc: 'toc',
|
|
29
|
+
};
|
|
26
30
|
/** The values of the `core` attribute of a font: the built-in PDF fonts, which need no file. */
|
|
27
31
|
exports.BuiltinFont = {
|
|
28
32
|
Courier: 'Courier',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { PdfEngine, LpdfRenderError } from './engine';
|
|
2
2
|
export type { EncryptPermissions, EncryptOptions } from './engine';
|
|
3
3
|
export type { RenderOptions, EngineOptions } from './_shared';
|
|
4
|
-
export { FieldType, Pin, Orientation, BuiltinFont, PageScope } from './constants';
|
|
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 {
|
|
7
|
-
export type { LpdfNode, LpdfContainerNode, LpdfTextNode, LpdfSpanNode, LpdfDividerNode, LpdfImgNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, LpdfFieldNode, } from './layout';
|
|
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
|
+
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';
|
|
10
10
|
export { L, NoAttr } from './L';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoAttr = exports.L = exports.CanvasTransform = exports.PageScope = exports.BuiltinFont = exports.Orientation = exports.Pin = exports.FieldType = exports.LpdfRenderError = exports.PdfEngine = void 0;
|
|
3
|
+
exports.NoAttr = exports.L = exports.CanvasTransform = exports.PageScope = exports.BuiltinFont = exports.SectionType = exports.Orientation = exports.Pin = exports.FieldType = exports.LpdfRenderError = exports.PdfEngine = void 0;
|
|
4
4
|
// ── Engine ────────────────────────────────────────────────────────────────────
|
|
5
5
|
var engine_1 = require("./engine");
|
|
6
6
|
Object.defineProperty(exports, "PdfEngine", { enumerable: true, get: function () { return engine_1.PdfEngine; } });
|
|
@@ -10,6 +10,7 @@ var constants_1 = require("./constants");
|
|
|
10
10
|
Object.defineProperty(exports, "FieldType", { enumerable: true, get: function () { return constants_1.FieldType; } });
|
|
11
11
|
Object.defineProperty(exports, "Pin", { enumerable: true, get: function () { return constants_1.Pin; } });
|
|
12
12
|
Object.defineProperty(exports, "Orientation", { enumerable: true, get: function () { return constants_1.Orientation; } });
|
|
13
|
+
Object.defineProperty(exports, "SectionType", { enumerable: true, get: function () { return constants_1.SectionType; } });
|
|
13
14
|
Object.defineProperty(exports, "BuiltinFont", { enumerable: true, get: function () { return constants_1.BuiltinFont; } });
|
|
14
15
|
Object.defineProperty(exports, "PageScope", { enumerable: true, get: function () { return constants_1.PageScope; } });
|
|
15
16
|
// ── Canvas types ──────────────────────────────────────────────────────────────
|
package/dist/kit.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* const bytes = await new LpdfEngine(key).renderPdf(doc);
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
import type { LpdfNode } from './layout';
|
|
26
|
+
import type { LpdfBookmarkNode, LpdfNode } from './layout';
|
|
27
27
|
import type { LpdfCanvasLayerNode } from './canvas';
|
|
28
28
|
import type { FontAttr, ImageAttr } from './attrs';
|
|
29
29
|
export interface DocumentTokens {
|
|
@@ -57,6 +57,8 @@ export interface SectionAttr {
|
|
|
57
57
|
background?: string;
|
|
58
58
|
title?: string;
|
|
59
59
|
debug?: string;
|
|
60
|
+
type?: string;
|
|
61
|
+
tocIndentStep?: string;
|
|
60
62
|
}
|
|
61
63
|
export interface DocumentAttr {
|
|
62
64
|
size?: string;
|
|
@@ -82,7 +84,7 @@ export interface LpdfCanvasBlock {
|
|
|
82
84
|
export interface LpdfSectionNode {
|
|
83
85
|
type: 'section';
|
|
84
86
|
attrs: Record<string, string>;
|
|
85
|
-
nodes: (LpdfLayoutBlock | LpdfCanvasBlock)[];
|
|
87
|
+
nodes: (LpdfBookmarkNode | LpdfLayoutBlock | LpdfCanvasBlock)[];
|
|
86
88
|
}
|
|
87
89
|
export interface PdfDocument {
|
|
88
90
|
version: 1;
|
|
@@ -92,7 +94,7 @@ export interface PdfDocument {
|
|
|
92
94
|
}
|
|
93
95
|
declare function layout(_attrs: null, nodes?: LpdfNode[]): LpdfLayoutBlock;
|
|
94
96
|
declare function canvas(_attrs: null, layers?: LpdfCanvasLayerNode[]): LpdfCanvasBlock;
|
|
95
|
-
declare function section(attrs: SectionAttr | null, nodes?: (LpdfLayoutBlock | LpdfCanvasBlock)[]): LpdfSectionNode;
|
|
97
|
+
declare function section(attrs: SectionAttr | null, nodes?: (LpdfBookmarkNode | LpdfLayoutBlock | LpdfCanvasBlock)[]): LpdfSectionNode;
|
|
96
98
|
declare function document(attrs: DocumentAttr | null, nodes?: LpdfSectionNode[]): PdfDocument;
|
|
97
99
|
export declare const LpdfKit: Readonly<{
|
|
98
100
|
layout: typeof layout;
|
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
|
}
|
|
@@ -55,11 +55,14 @@ export interface LpdfFieldNode {
|
|
|
55
55
|
type: 'field';
|
|
56
56
|
attrs: Record<string, string>;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
/** An outline entry and link target that marks the node after it; it draws nothing. */
|
|
59
|
+
export interface LpdfBookmarkNode {
|
|
60
|
+
type: 'bookmark';
|
|
61
|
+
attrs: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
export type LpdfNode = LpdfContainerNode | LpdfTextNode | LpdfDividerNode | LpdfTableNode | LpdfImgNode | LpdfBarcodeNode | LpdfRegionNode | LpdfFieldNode | LpdfBookmarkNode;
|
|
64
|
+
declare function column(attrs: ColumnAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
65
|
+
declare function row(attrs: RowAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
63
66
|
declare function grid(attrs: GridAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
64
67
|
declare function frame(attrs: FrameAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
65
68
|
declare function link(attrs: LinkAttr, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
@@ -74,11 +77,14 @@ declare function img(attrs: ImgAttr): LpdfImgNode;
|
|
|
74
77
|
declare function barcode(attrs: BarcodeAttr): LpdfBarcodeNode;
|
|
75
78
|
declare function region(attrs: RegionAttr, nodes?: LpdfNode[]): LpdfRegionNode;
|
|
76
79
|
declare function field(attrs: FieldAttr): LpdfFieldNode;
|
|
80
|
+
/**
|
|
81
|
+
* An entry of the PDF's outline and a target for `href: '#id'` links. It marks the node that follows it
|
|
82
|
+
* in the same list; directly in a section's nodes, it marks the section's first page.
|
|
83
|
+
*/
|
|
84
|
+
declare function bookmark(attrs: BookmarkAttr): LpdfBookmarkNode;
|
|
77
85
|
export declare const LpdfLayout: Readonly<{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
split: typeof split;
|
|
81
|
-
cluster: typeof cluster;
|
|
86
|
+
column: typeof column;
|
|
87
|
+
row: typeof row;
|
|
82
88
|
grid: typeof grid;
|
|
83
89
|
frame: typeof frame;
|
|
84
90
|
link: typeof link;
|
|
@@ -93,5 +99,6 @@ export declare const LpdfLayout: Readonly<{
|
|
|
93
99
|
td: typeof td;
|
|
94
100
|
region: typeof region;
|
|
95
101
|
field: typeof field;
|
|
102
|
+
bookmark: typeof bookmark;
|
|
96
103
|
}>;
|
|
97
104
|
export {};
|
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);
|
|
@@ -61,11 +55,16 @@ function region(attrs, nodes = []) {
|
|
|
61
55
|
function field(attrs) {
|
|
62
56
|
return { type: 'field', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
63
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* An entry of the PDF's outline and a target for `href: '#id'` links. It marks the node that follows it
|
|
60
|
+
* in the same list; directly in a section's nodes, it marks the section's first page.
|
|
61
|
+
*/
|
|
62
|
+
function bookmark(attrs) {
|
|
63
|
+
return { type: 'bookmark', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
64
|
+
}
|
|
64
65
|
exports.LpdfLayout = Object.freeze({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
split,
|
|
68
|
-
cluster,
|
|
66
|
+
column,
|
|
67
|
+
row,
|
|
69
68
|
grid,
|
|
70
69
|
frame,
|
|
71
70
|
link,
|
|
@@ -80,4 +79,5 @@ exports.LpdfLayout = Object.freeze({
|
|
|
80
79
|
td,
|
|
81
80
|
region,
|
|
82
81
|
field,
|
|
82
|
+
bookmark,
|
|
83
83
|
});
|
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",
|