@lpdfio/lpdf 0.22.0 → 0.24.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 +560 -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
|
+
}
|