@lpdfio/lpdf 0.5.0 → 0.7.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/LICENSE +33 -16
- package/README.md +33 -38
- package/dist/_shared.d.ts +3 -6
- package/dist/browser.js +21 -62
- package/dist/canvas.d.ts +8 -6
- package/dist/canvas.js +13 -13
- package/dist/engine.d.ts +16 -13
- package/dist/engine.js +23 -23
- package/dist/index.d.ts +9 -45
- package/dist/index.js +12 -32
- package/dist/kit-to-xml.d.ts +2 -2
- package/dist/kit.d.ts +7 -16
- package/dist/kit.js +12 -12
- package/dist/layout.d.ts +35 -34
- package/dist/layout.js +43 -43
- package/dist/pdf.d.ts +61 -0
- package/dist/pdf.js +70 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
Kit: Readonly<{
|
|
11
|
-
layout: (nodes?: import("./layout").LpdfNode[]) => import("./kit").LpdfLayoutBlock;
|
|
12
|
-
canvas: (layers?: import("./canvas").LpdfCanvasLayerNode[]) => import("./kit").LpdfCanvasBlock;
|
|
13
|
-
section: (input?: import("./kit").SectionInput) => import("./kit").LpdfSectionNode;
|
|
14
|
-
document: (input?: import("./kit").DocumentInput) => import("./kit").LpdfDocument;
|
|
15
|
-
}>;
|
|
16
|
-
Layout: Readonly<{
|
|
17
|
-
stack: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").StackOptions) => import("./layout").LpdfContainerNode;
|
|
18
|
-
flank: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").FlankOptions) => import("./layout").LpdfContainerNode;
|
|
19
|
-
split: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").SplitOptions) => import("./layout").LpdfContainerNode;
|
|
20
|
-
cluster: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").ClusterOptions) => import("./layout").LpdfContainerNode;
|
|
21
|
-
grid: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").GridOptions) => import("./layout").LpdfContainerNode;
|
|
22
|
-
frame: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").FrameOptions) => import("./layout").LpdfContainerNode;
|
|
23
|
-
link: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").LinkOptions) => import("./layout").LpdfContainerNode;
|
|
24
|
-
text: (nodes?: (string | import("./layout").LpdfSpanNode)[], options?: import("./layout").TextOptions) => import("./layout").LpdfTextNode;
|
|
25
|
-
span: (nodes?: string[], options?: import("./layout").SpanOptions) => import("./layout").LpdfSpanNode;
|
|
26
|
-
divider: (options?: import("./layout").DividerOptions) => import("./layout").LpdfDividerNode;
|
|
27
|
-
img: (options: import("./layout").ImgOptions) => import("./layout").LpdfImgNode;
|
|
28
|
-
barcode: (options: import("./layout").BarcodeOptions) => import("./layout").LpdfBarcodeNode;
|
|
29
|
-
table: (options: import("./layout").TableOptions, nodes?: (import("./layout").LpdfTheadNode | import("./layout").LpdfTrNode)[]) => import("./layout").LpdfTableNode;
|
|
30
|
-
thead: (nodes?: import("./layout").LpdfTdNode[], options?: import("./layout").TheadOptions) => import("./layout").LpdfTheadNode;
|
|
31
|
-
tr: (nodes?: import("./layout").LpdfTdNode[], options?: import("./layout").TrOptions) => import("./layout").LpdfTrNode;
|
|
32
|
-
td: (nodes?: import("./layout").LpdfNode[], options?: import("./layout").TdOptions) => import("./layout").LpdfTdNode;
|
|
33
|
-
region: (pin: string, nodes?: import("./layout").LpdfNode[], options?: import("./layout").RegionOptions) => import("./layout").LpdfRegionNode;
|
|
34
|
-
}>;
|
|
35
|
-
Canvas: Readonly<{
|
|
36
|
-
rect: (x: number, y: number, w: number, h: number, style?: import("./canvas").CanvasRectStyle) => import("./canvas").LpdfCanvasRectNode;
|
|
37
|
-
line: (x1: number, y1: number, x2: number, y2: number, style?: import("./canvas").CanvasLineStyle) => import("./canvas").LpdfCanvasLineNode;
|
|
38
|
-
ellipse: (cx: number, cy: number, rx: number, ry: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasEllipseNode;
|
|
39
|
-
circle: (cx: number, cy: number, r: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasCircleNode;
|
|
40
|
-
path: (d: string, style?: import("./canvas").CanvasPathStyle) => import("./canvas").LpdfCanvasPathNode;
|
|
41
|
-
text: (x: number, y: number, content: string, style?: import("./canvas").CanvasTextStyle, runs?: import("./canvas").CanvasRun[]) => import("./canvas").LpdfCanvasTextNode;
|
|
42
|
-
img: (x: number, y: number, w: number, h: number, name: string) => import("./canvas").LpdfCanvasImgNode;
|
|
43
|
-
layer: (nodes: import("./canvas").LpdfCanvasPrimitiveNode[], options?: import("./canvas").CanvasLayerOptions) => import("./canvas").LpdfCanvasLayerNode;
|
|
44
|
-
}>;
|
|
45
|
-
}>;
|
|
1
|
+
export { PdfEngine, LpdfRenderError } from './engine';
|
|
2
|
+
export type { EncryptPermissions, EncryptOptions } from './engine';
|
|
3
|
+
export type { RenderOptions, EngineOptions, PageScope } from './_shared';
|
|
4
|
+
export type { PdfDocument, LpdfSectionNode, LpdfLayoutBlock, LpdfCanvasBlock, LpdfTokens, LpdfFontDef, LpdfMeta, SectionAttr, DocumentAttr, } from './kit';
|
|
5
|
+
export type { StackAttr, FlankAttr, SplitAttr, ClusterAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, BarcodeAttr, RegionAttr, } from './layout';
|
|
6
|
+
export type { LpdfNode, LpdfContainerNode, LpdfTextNode, LpdfSpanNode, LpdfDividerNode, LpdfImgNode, LpdfBarcodeNode, LpdfTableNode, LpdfTheadNode, LpdfTrNode, LpdfTdNode, LpdfRegionNode, } from './layout';
|
|
7
|
+
export { CanvasTransform } from './canvas';
|
|
8
|
+
export type { LineCap, LineJoin, TextAlign, LayerAttr, CanvasRun, CanvasRectStyle, CanvasLineStyle, CanvasEllipseStyle, CanvasPathStyle, CanvasTextStyle, LpdfCanvasLayerNode, LpdfCanvasPrimitiveNode, LpdfCanvasRectNode, LpdfCanvasLineNode, LpdfCanvasEllipseNode, LpdfCanvasCircleNode, LpdfCanvasPathNode, LpdfCanvasTextNode, LpdfCanvasImgNode, } from './canvas';
|
|
9
|
+
export { L, NoAttr } from './pdf';
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exports.Lpdf = Object.freeze({
|
|
30
|
-
Engine: engine_1.LpdfEngine,
|
|
31
|
-
Kit: kit_1.LpdfKit,
|
|
32
|
-
Layout: layout_1.LpdfLayout,
|
|
33
|
-
Canvas: canvas_1.LpdfCanvas,
|
|
34
|
-
});
|
|
3
|
+
exports.NoAttr = exports.L = exports.CanvasTransform = exports.LpdfRenderError = exports.PdfEngine = void 0;
|
|
4
|
+
// ── Engine ────────────────────────────────────────────────────────────────────
|
|
5
|
+
var engine_1 = require("./engine");
|
|
6
|
+
Object.defineProperty(exports, "PdfEngine", { enumerable: true, get: function () { return engine_1.PdfEngine; } });
|
|
7
|
+
Object.defineProperty(exports, "LpdfRenderError", { enumerable: true, get: function () { return engine_1.LpdfRenderError; } });
|
|
8
|
+
// ── Canvas types ──────────────────────────────────────────────────────────────
|
|
9
|
+
var canvas_1 = require("./canvas");
|
|
10
|
+
Object.defineProperty(exports, "CanvasTransform", { enumerable: true, get: function () { return canvas_1.CanvasTransform; } });
|
|
11
|
+
// ── Facade ────────────────────────────────────────────────────────────────────
|
|
12
|
+
var pdf_1 = require("./pdf");
|
|
13
|
+
Object.defineProperty(exports, "L", { enumerable: true, get: function () { return pdf_1.L; } });
|
|
14
|
+
Object.defineProperty(exports, "NoAttr", { enumerable: true, get: function () { return pdf_1.NoAttr; } });
|
package/dist/kit-to-xml.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* console.log(xml);
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import type {
|
|
19
|
+
import type { PdfDocument } from './kit';
|
|
20
20
|
/**
|
|
21
21
|
* Convert an `LpdfDocument` tree (built with `LpdfKit`) into an lpdf XML
|
|
22
22
|
* string.
|
|
@@ -27,4 +27,4 @@ import type { LpdfDocument } from './kit';
|
|
|
27
27
|
* @param doc - The document tree returned by `LpdfKit.document(...)`.
|
|
28
28
|
* @returns A well-formed XML string with an `<?xml ...?>` declaration.
|
|
29
29
|
*/
|
|
30
|
-
export declare function kitToXml(doc:
|
|
30
|
+
export declare function kitToXml(doc: PdfDocument): string;
|
package/dist/kit.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface LpdfMeta {
|
|
|
49
49
|
keywords?: string;
|
|
50
50
|
creator?: string;
|
|
51
51
|
}
|
|
52
|
-
export interface
|
|
52
|
+
export interface SectionAttr {
|
|
53
53
|
size?: string;
|
|
54
54
|
orientation?: string;
|
|
55
55
|
margin?: string;
|
|
@@ -57,7 +57,7 @@ export interface SectionOptions {
|
|
|
57
57
|
title?: string;
|
|
58
58
|
debug?: string;
|
|
59
59
|
}
|
|
60
|
-
export interface
|
|
60
|
+
export interface DocumentAttr {
|
|
61
61
|
size?: string;
|
|
62
62
|
orientation?: string;
|
|
63
63
|
margin?: string;
|
|
@@ -81,25 +81,16 @@ export interface LpdfSectionNode {
|
|
|
81
81
|
attrs: Record<string, string>;
|
|
82
82
|
nodes: (LpdfLayoutBlock | LpdfCanvasBlock)[];
|
|
83
83
|
}
|
|
84
|
-
export interface
|
|
84
|
+
export interface PdfDocument {
|
|
85
85
|
version: 1;
|
|
86
86
|
type: 'document';
|
|
87
87
|
attrs: Record<string, unknown>;
|
|
88
88
|
nodes: LpdfSectionNode[];
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export interface DocumentInput {
|
|
95
|
-
/** Sections — serialised as `nodes` on the wire (matching kit_to_xml and parse_tree). */
|
|
96
|
-
sections?: LpdfSectionNode[];
|
|
97
|
-
options?: DocumentOptions;
|
|
98
|
-
}
|
|
99
|
-
declare function layout(nodes?: LpdfNode[]): LpdfLayoutBlock;
|
|
100
|
-
declare function canvas(layers?: LpdfCanvasLayerNode[]): LpdfCanvasBlock;
|
|
101
|
-
declare function section(input?: SectionInput): LpdfSectionNode;
|
|
102
|
-
declare function document(input?: DocumentInput): LpdfDocument;
|
|
90
|
+
declare function layout(_attrs: null, nodes: LpdfNode[]): LpdfLayoutBlock;
|
|
91
|
+
declare function canvas(_attrs: null, layers: LpdfCanvasLayerNode[]): LpdfCanvasBlock;
|
|
92
|
+
declare function section(attrs: SectionAttr | null, nodes: (LpdfLayoutBlock | LpdfCanvasBlock)[]): LpdfSectionNode;
|
|
93
|
+
declare function document(attrs: DocumentAttr | null, nodes: LpdfSectionNode[]): PdfDocument;
|
|
103
94
|
export declare const LpdfKit: Readonly<{
|
|
104
95
|
layout: typeof layout;
|
|
105
96
|
canvas: typeof canvas;
|
package/dist/kit.js
CHANGED
|
@@ -40,33 +40,33 @@ function buildAttrs(options) {
|
|
|
40
40
|
return result;
|
|
41
41
|
}
|
|
42
42
|
// ── Factory functions ─────────────────────────────────────────────────────────
|
|
43
|
-
function layout(nodes
|
|
43
|
+
function layout(_attrs, nodes) {
|
|
44
44
|
return { type: 'layout', nodes };
|
|
45
45
|
}
|
|
46
|
-
function canvas(layers
|
|
46
|
+
function canvas(_attrs, layers) {
|
|
47
47
|
return { type: 'canvas', nodes: layers };
|
|
48
48
|
}
|
|
49
|
-
function section(
|
|
49
|
+
function section(attrs, nodes) {
|
|
50
50
|
return {
|
|
51
51
|
type: 'section',
|
|
52
|
-
attrs: buildAttrs((
|
|
53
|
-
nodes
|
|
52
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
53
|
+
nodes,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function document(
|
|
57
|
-
const { tokens, meta, ...restOpts } =
|
|
58
|
-
const
|
|
56
|
+
function document(attrs, nodes) {
|
|
57
|
+
const { tokens, meta, ...restOpts } = attrs ?? {};
|
|
58
|
+
const attrsObj = {
|
|
59
59
|
...buildAttrs(restOpts),
|
|
60
60
|
};
|
|
61
61
|
if (tokens !== undefined)
|
|
62
|
-
|
|
62
|
+
attrsObj['tokens'] = tokens;
|
|
63
63
|
if (meta !== undefined)
|
|
64
|
-
|
|
64
|
+
attrsObj['meta'] = meta;
|
|
65
65
|
return {
|
|
66
66
|
version: 1,
|
|
67
67
|
type: 'document',
|
|
68
|
-
attrs,
|
|
69
|
-
nodes
|
|
68
|
+
attrs: attrsObj,
|
|
69
|
+
nodes,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
// ── LpdfKit export ────────────────────────────────────────────────────────────
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PageScope } from './_shared';
|
|
2
|
-
export interface
|
|
2
|
+
export interface StackAttr {
|
|
3
3
|
gap?: string;
|
|
4
4
|
padding?: string;
|
|
5
5
|
background?: string;
|
|
@@ -11,7 +11,7 @@ export interface StackOptions {
|
|
|
11
11
|
radius?: string;
|
|
12
12
|
debug?: string;
|
|
13
13
|
}
|
|
14
|
-
export interface
|
|
14
|
+
export interface FlankAttr {
|
|
15
15
|
gap?: string;
|
|
16
16
|
padding?: string;
|
|
17
17
|
background?: string;
|
|
@@ -24,7 +24,7 @@ export interface FlankOptions {
|
|
|
24
24
|
radius?: string;
|
|
25
25
|
debug?: string;
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface SplitAttr {
|
|
28
28
|
gap?: string;
|
|
29
29
|
padding?: string;
|
|
30
30
|
background?: string;
|
|
@@ -36,7 +36,7 @@ export interface SplitOptions {
|
|
|
36
36
|
radius?: string;
|
|
37
37
|
debug?: string;
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface ClusterAttr {
|
|
40
40
|
gap?: string;
|
|
41
41
|
padding?: string;
|
|
42
42
|
background?: string;
|
|
@@ -48,7 +48,7 @@ export interface ClusterOptions {
|
|
|
48
48
|
radius?: string;
|
|
49
49
|
debug?: string;
|
|
50
50
|
}
|
|
51
|
-
export interface
|
|
51
|
+
export interface GridAttr {
|
|
52
52
|
cols?: string;
|
|
53
53
|
colWidth?: string;
|
|
54
54
|
gap?: string;
|
|
@@ -61,7 +61,7 @@ export interface GridOptions {
|
|
|
61
61
|
radius?: string;
|
|
62
62
|
debug?: string;
|
|
63
63
|
}
|
|
64
|
-
export interface
|
|
64
|
+
export interface FrameAttr {
|
|
65
65
|
width?: string;
|
|
66
66
|
height?: string;
|
|
67
67
|
padding?: string;
|
|
@@ -71,13 +71,13 @@ export interface FrameOptions {
|
|
|
71
71
|
align?: string;
|
|
72
72
|
debug?: string;
|
|
73
73
|
}
|
|
74
|
-
export interface
|
|
74
|
+
export interface LinkAttr {
|
|
75
75
|
url?: string;
|
|
76
76
|
width?: string;
|
|
77
77
|
height?: string;
|
|
78
78
|
debug?: string;
|
|
79
79
|
}
|
|
80
|
-
export interface
|
|
80
|
+
export interface TableAttr {
|
|
81
81
|
cols: string;
|
|
82
82
|
border?: string;
|
|
83
83
|
stripe?: string;
|
|
@@ -89,13 +89,13 @@ export interface TableOptions {
|
|
|
89
89
|
repeat?: string;
|
|
90
90
|
debug?: string;
|
|
91
91
|
}
|
|
92
|
-
export interface
|
|
92
|
+
export interface TheadAttr {
|
|
93
93
|
background?: string;
|
|
94
94
|
}
|
|
95
|
-
export interface
|
|
95
|
+
export interface TrAttr {
|
|
96
96
|
background?: string;
|
|
97
97
|
}
|
|
98
|
-
export interface
|
|
98
|
+
export interface TdAttr {
|
|
99
99
|
padding?: string;
|
|
100
100
|
background?: string;
|
|
101
101
|
align?: string;
|
|
@@ -105,7 +105,7 @@ export interface TdOptions {
|
|
|
105
105
|
gap?: string;
|
|
106
106
|
debug?: string;
|
|
107
107
|
}
|
|
108
|
-
export interface
|
|
108
|
+
export interface TextAttr {
|
|
109
109
|
font?: string;
|
|
110
110
|
fontSize?: string;
|
|
111
111
|
textAlign?: string;
|
|
@@ -121,7 +121,7 @@ export interface TextOptions {
|
|
|
121
121
|
repeat?: string;
|
|
122
122
|
debug?: string;
|
|
123
123
|
}
|
|
124
|
-
export interface
|
|
124
|
+
export interface SpanAttr {
|
|
125
125
|
font?: string;
|
|
126
126
|
fontSize?: string;
|
|
127
127
|
color?: string;
|
|
@@ -130,13 +130,13 @@ export interface SpanOptions {
|
|
|
130
130
|
underline?: string;
|
|
131
131
|
strike?: string;
|
|
132
132
|
}
|
|
133
|
-
export interface
|
|
133
|
+
export interface DividerAttr {
|
|
134
134
|
color?: string;
|
|
135
135
|
thickness?: string;
|
|
136
136
|
direction?: string;
|
|
137
137
|
debug?: string;
|
|
138
138
|
}
|
|
139
|
-
export interface
|
|
139
|
+
export interface ImgAttr {
|
|
140
140
|
name: string;
|
|
141
141
|
height?: string;
|
|
142
142
|
width?: string;
|
|
@@ -150,7 +150,7 @@ export interface ImgOptions {
|
|
|
150
150
|
repeat?: string;
|
|
151
151
|
debug?: string;
|
|
152
152
|
}
|
|
153
|
-
export interface
|
|
153
|
+
export interface BarcodeAttr {
|
|
154
154
|
type: string;
|
|
155
155
|
data: string;
|
|
156
156
|
size?: string;
|
|
@@ -163,7 +163,8 @@ export interface BarcodeOptions {
|
|
|
163
163
|
repeat?: string;
|
|
164
164
|
debug?: string;
|
|
165
165
|
}
|
|
166
|
-
export interface
|
|
166
|
+
export interface RegionAttr {
|
|
167
|
+
pin: string;
|
|
167
168
|
page?: PageScope | string;
|
|
168
169
|
w?: string;
|
|
169
170
|
debug?: string;
|
|
@@ -221,23 +222,23 @@ export interface LpdfRegionNode {
|
|
|
221
222
|
nodes: LpdfNode[];
|
|
222
223
|
}
|
|
223
224
|
export type LpdfNode = LpdfContainerNode | LpdfTextNode | LpdfDividerNode | LpdfTableNode | LpdfImgNode | LpdfBarcodeNode | LpdfRegionNode;
|
|
224
|
-
declare function stack(nodes
|
|
225
|
-
declare function flank(nodes
|
|
226
|
-
declare function split(nodes
|
|
227
|
-
declare function cluster(nodes
|
|
228
|
-
declare function grid(nodes
|
|
229
|
-
declare function frame(nodes
|
|
230
|
-
declare function link(nodes
|
|
231
|
-
declare function table(
|
|
232
|
-
declare function thead(nodes
|
|
233
|
-
declare function tr(nodes
|
|
234
|
-
declare function td(nodes
|
|
235
|
-
declare function text(nodes
|
|
236
|
-
declare function span(nodes
|
|
237
|
-
declare function divider(
|
|
238
|
-
declare function img(
|
|
239
|
-
declare function barcode(
|
|
240
|
-
declare function region(
|
|
225
|
+
declare function stack(attrs: StackAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
226
|
+
declare function flank(attrs: FlankAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
227
|
+
declare function split(attrs: SplitAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
228
|
+
declare function cluster(attrs: ClusterAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
229
|
+
declare function grid(attrs: GridAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
230
|
+
declare function frame(attrs: FrameAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
231
|
+
declare function link(attrs: LinkAttr | null, nodes: LpdfNode[]): LpdfContainerNode;
|
|
232
|
+
declare function table(attrs: TableAttr, nodes: (LpdfTheadNode | LpdfTrNode)[]): LpdfTableNode;
|
|
233
|
+
declare function thead(attrs: TheadAttr | null, nodes: LpdfTdNode[]): LpdfTheadNode;
|
|
234
|
+
declare function tr(attrs: TrAttr | null, nodes: LpdfTdNode[]): LpdfTrNode;
|
|
235
|
+
declare function td(attrs: TdAttr | null, nodes: LpdfNode[]): LpdfTdNode;
|
|
236
|
+
declare function text(attrs: TextAttr | null, nodes: (string | LpdfSpanNode)[]): LpdfTextNode;
|
|
237
|
+
declare function span(attrs: SpanAttr | null, nodes: string[]): LpdfSpanNode;
|
|
238
|
+
declare function divider(attrs: DividerAttr | null): LpdfDividerNode;
|
|
239
|
+
declare function img(attrs: ImgAttr): LpdfImgNode;
|
|
240
|
+
declare function barcode(attrs: BarcodeAttr): LpdfBarcodeNode;
|
|
241
|
+
declare function region(attrs: RegionAttr, nodes: LpdfNode[]): LpdfRegionNode;
|
|
241
242
|
export declare const LpdfLayout: Readonly<{
|
|
242
243
|
stack: typeof stack;
|
|
243
244
|
flank: typeof flank;
|
package/dist/layout.js
CHANGED
|
@@ -15,100 +15,100 @@ function buildAttrs(options) {
|
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
17
|
// ── Helper ────────────────────────────────────────────────────────────────────
|
|
18
|
-
function makeContainer(type,
|
|
19
|
-
return { type, attrs: buildAttrs(
|
|
18
|
+
function makeContainer(type, attrs, nodes) {
|
|
19
|
+
return { type, attrs: buildAttrs(attrs ?? {}), nodes };
|
|
20
20
|
}
|
|
21
21
|
// ── LpdfLayout factory ────────────────────────────────────────────────────────
|
|
22
|
-
function stack(
|
|
23
|
-
return makeContainer('stack',
|
|
22
|
+
function stack(attrs, nodes) {
|
|
23
|
+
return makeContainer('stack', attrs, nodes);
|
|
24
24
|
}
|
|
25
|
-
function flank(
|
|
26
|
-
return makeContainer('flank',
|
|
25
|
+
function flank(attrs, nodes) {
|
|
26
|
+
return makeContainer('flank', attrs, nodes);
|
|
27
27
|
}
|
|
28
|
-
function split(
|
|
29
|
-
return makeContainer('split',
|
|
28
|
+
function split(attrs, nodes) {
|
|
29
|
+
return makeContainer('split', attrs, nodes);
|
|
30
30
|
}
|
|
31
|
-
function cluster(
|
|
32
|
-
return makeContainer('cluster',
|
|
31
|
+
function cluster(attrs, nodes) {
|
|
32
|
+
return makeContainer('cluster', attrs, nodes);
|
|
33
33
|
}
|
|
34
|
-
function grid(
|
|
35
|
-
return makeContainer('grid',
|
|
34
|
+
function grid(attrs, nodes) {
|
|
35
|
+
return makeContainer('grid', attrs, nodes);
|
|
36
36
|
}
|
|
37
|
-
function frame(
|
|
38
|
-
return makeContainer('frame',
|
|
37
|
+
function frame(attrs, nodes) {
|
|
38
|
+
return makeContainer('frame', attrs, nodes);
|
|
39
39
|
}
|
|
40
|
-
function link(
|
|
41
|
-
return makeContainer('link',
|
|
40
|
+
function link(attrs, nodes) {
|
|
41
|
+
return makeContainer('link', attrs, nodes);
|
|
42
42
|
}
|
|
43
|
-
function table(
|
|
43
|
+
function table(attrs, nodes) {
|
|
44
44
|
return {
|
|
45
45
|
type: 'table',
|
|
46
|
-
attrs: buildAttrs(
|
|
46
|
+
attrs: buildAttrs(attrs),
|
|
47
47
|
nodes,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function thead(
|
|
50
|
+
function thead(attrs, nodes) {
|
|
51
51
|
return {
|
|
52
52
|
type: 'thead',
|
|
53
|
-
attrs: buildAttrs((
|
|
53
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
54
54
|
nodes,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function tr(
|
|
57
|
+
function tr(attrs, nodes) {
|
|
58
58
|
return {
|
|
59
59
|
type: 'tr',
|
|
60
|
-
attrs: buildAttrs((
|
|
60
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
61
61
|
nodes,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function td(
|
|
64
|
+
function td(attrs, nodes) {
|
|
65
65
|
return {
|
|
66
66
|
type: 'td',
|
|
67
|
-
attrs: buildAttrs((
|
|
67
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
68
68
|
nodes,
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function text(
|
|
71
|
+
function text(attrs, nodes) {
|
|
72
72
|
return {
|
|
73
73
|
type: 'text',
|
|
74
|
-
attrs: buildAttrs((
|
|
74
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
75
75
|
nodes,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function span(
|
|
78
|
+
function span(attrs, nodes) {
|
|
79
79
|
return {
|
|
80
80
|
type: 'span',
|
|
81
|
-
attrs: buildAttrs((
|
|
81
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
82
82
|
nodes,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function divider(
|
|
85
|
+
function divider(attrs) {
|
|
86
86
|
return {
|
|
87
87
|
type: 'divider',
|
|
88
|
-
attrs: buildAttrs((
|
|
88
|
+
attrs: buildAttrs((attrs ?? {})),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
function img(
|
|
91
|
+
function img(attrs) {
|
|
92
92
|
return {
|
|
93
93
|
type: 'img',
|
|
94
|
-
attrs: buildAttrs(
|
|
94
|
+
attrs: buildAttrs(attrs),
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function barcode(
|
|
97
|
+
function barcode(attrs) {
|
|
98
98
|
return {
|
|
99
99
|
type: 'barcode',
|
|
100
|
-
attrs: buildAttrs(
|
|
100
|
+
attrs: buildAttrs(attrs),
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
function region(
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
return { type: 'layout-region', attrs, nodes };
|
|
103
|
+
function region(attrs, nodes) {
|
|
104
|
+
const a = { pin: attrs.pin };
|
|
105
|
+
if (attrs.page !== undefined)
|
|
106
|
+
a['page'] = attrs.page;
|
|
107
|
+
if (attrs.w !== undefined)
|
|
108
|
+
a['w'] = attrs.w;
|
|
109
|
+
if (attrs.debug !== undefined)
|
|
110
|
+
a['debug'] = attrs.debug;
|
|
111
|
+
return { type: 'layout-region', attrs: a, nodes };
|
|
112
112
|
}
|
|
113
113
|
exports.LpdfLayout = Object.freeze({
|
|
114
114
|
stack,
|
package/dist/pdf.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PdfDocument } from './kit';
|
|
2
|
+
import { PdfEngine } from './engine';
|
|
3
|
+
/** Pass as `attrs` when a node has no attributes. Equivalent to `null`. */
|
|
4
|
+
export declare const NoAttr: null;
|
|
5
|
+
/**
|
|
6
|
+
* Unified lpdf facade.
|
|
7
|
+
*
|
|
8
|
+
* All document, layout, and canvas factory methods are available as flat
|
|
9
|
+
* properties on this object. Construction-time configuration is handled via
|
|
10
|
+
* `L.engine()`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { L, NoAttr } from 'lpdf';
|
|
15
|
+
*
|
|
16
|
+
* const engine = L.engine().setLicenseKey(process.env.LPDF_KEY);
|
|
17
|
+
*
|
|
18
|
+
* const doc = L.document(NoAttr, [
|
|
19
|
+
* L.section(NoAttr, [
|
|
20
|
+
* L.layout(null, [ L.text(NoAttr, ['Hello']) ]),
|
|
21
|
+
* ]),
|
|
22
|
+
* ]);
|
|
23
|
+
*
|
|
24
|
+
* const pdf = await engine.render(doc);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const L: Readonly<{
|
|
28
|
+
/** Create a new {@link PdfEngine} instance. Call `.setLicenseKey()` to configure. */
|
|
29
|
+
engine: () => PdfEngine;
|
|
30
|
+
/** Convert a `PdfDocument` tree to an lpdf XML string. */
|
|
31
|
+
toXml: (doc: PdfDocument) => string;
|
|
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
|
+
stack: (attrs: import("./layout").StackAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
37
|
+
flank: (attrs: import("./layout").FlankAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
38
|
+
split: (attrs: import("./layout").SplitAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
39
|
+
cluster: (attrs: import("./layout").ClusterAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
40
|
+
grid: (attrs: import("./layout").GridAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
41
|
+
frame: (attrs: import("./layout").FrameAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
42
|
+
link: (attrs: import("./layout").LinkAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfContainerNode;
|
|
43
|
+
table: (attrs: import("./layout").TableAttr, nodes: (import("./layout").LpdfTheadNode | import("./layout").LpdfTrNode)[]) => import("./layout").LpdfTableNode;
|
|
44
|
+
thead: (attrs: import("./layout").TheadAttr | null, nodes: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTheadNode;
|
|
45
|
+
tr: (attrs: import("./layout").TrAttr | null, nodes: import("./layout").LpdfTdNode[]) => import("./layout").LpdfTrNode;
|
|
46
|
+
td: (attrs: import("./layout").TdAttr | null, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfTdNode;
|
|
47
|
+
text: (attrs: import("./layout").TextAttr | null, nodes: (string | import("./layout").LpdfSpanNode)[]) => import("./layout").LpdfTextNode;
|
|
48
|
+
span: (attrs: import("./layout").SpanAttr | null, nodes: string[]) => import("./layout").LpdfSpanNode;
|
|
49
|
+
divider: (attrs: import("./layout").DividerAttr | null) => import("./layout").LpdfDividerNode;
|
|
50
|
+
img: (attrs: import("./layout").ImgAttr) => import("./layout").LpdfImgNode;
|
|
51
|
+
barcode: (attrs: import("./layout").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
|
|
52
|
+
region: (attrs: import("./layout").RegionAttr, nodes: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
|
|
53
|
+
layer: (attrs: import("./canvas").LayerAttr | null, nodes: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
|
|
54
|
+
rect: (x: number, y: number, w: number, h: number, style?: import("./canvas").CanvasRectStyle) => import("./canvas").LpdfCanvasRectNode;
|
|
55
|
+
line: (x1: number, y1: number, x2: number, y2: number, style?: import("./canvas").CanvasLineStyle) => import("./canvas").LpdfCanvasLineNode;
|
|
56
|
+
ellipse: (cx: number, cy: number, rx: number, ry: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasEllipseNode;
|
|
57
|
+
circle: (cx: number, cy: number, r: number, style?: import("./canvas").CanvasEllipseStyle) => import("./canvas").LpdfCanvasCircleNode;
|
|
58
|
+
path: (d: string, style?: import("./canvas").CanvasPathStyle) => import("./canvas").LpdfCanvasPathNode;
|
|
59
|
+
textAt: (x: number, y: number, content: string, style?: import("./canvas").CanvasTextStyle, runs?: import("./canvas").CanvasRun[]) => import("./canvas").LpdfCanvasTextNode;
|
|
60
|
+
imgAt: (x: number, y: number, w: number, h: number, name: string) => import("./canvas").LpdfCanvasImgNode;
|
|
61
|
+
}>;
|