@lpdfio/lpdf 0.24.0 → 0.25.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/dist/L.d.ts +2 -1
- package/dist/L.js +1 -0
- package/dist/attrs.d.ts +42 -0
- 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 +13 -2
- package/dist/layout.js +8 -0
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/L.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ 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;
|
|
@@ -53,6 +53,7 @@ export declare const L: Readonly<{
|
|
|
53
53
|
barcode: (attrs: import("./attrs").BarcodeAttr) => import("./layout").LpdfBarcodeNode;
|
|
54
54
|
region: (attrs: import("./attrs").RegionAttr, nodes?: import("./layout").LpdfNode[]) => import("./layout").LpdfRegionNode;
|
|
55
55
|
field: (attrs: import("./attrs").FieldAttr) => import("./layout").LpdfFieldNode;
|
|
56
|
+
bookmark: (attrs: import("./attrs").BookmarkAttr) => import("./layout").LpdfBookmarkNode;
|
|
56
57
|
layer: (attrs: import("./attrs").LayerAttr | null, nodes?: import("./canvas").LpdfCanvasPrimitiveNode[]) => import("./canvas").LpdfCanvasLayerNode;
|
|
57
58
|
rect: (attrs: import("./attrs").RectAttr) => import("./canvas").LpdfCanvasRectNode;
|
|
58
59
|
line: (attrs: import("./attrs").LineAttr) => import("./canvas").LpdfCanvasLineNode;
|
package/dist/L.js
CHANGED
|
@@ -61,6 +61,7 @@ exports.L = Object.freeze({
|
|
|
61
61
|
barcode: layout_1.LpdfLayout.barcode,
|
|
62
62
|
region: layout_1.LpdfLayout.region,
|
|
63
63
|
field: layout_1.LpdfLayout.field,
|
|
64
|
+
bookmark: layout_1.LpdfLayout.bookmark,
|
|
64
65
|
// ── Canvas ────────────────────────────────────────────────────────────────
|
|
65
66
|
layer: canvas_1.LpdfCanvas.layer,
|
|
66
67
|
rect: canvas_1.LpdfCanvas.rect,
|
package/dist/attrs.d.ts
CHANGED
|
@@ -230,6 +230,10 @@ export interface FrameAttr {
|
|
|
230
230
|
* Attributes of the `link` element.
|
|
231
231
|
*/
|
|
232
232
|
export interface LinkAttr {
|
|
233
|
+
/**
|
|
234
|
+
* Where the link goes: a URL, or #id to jump to the bookmark with that id. In an entry of a table
|
|
235
|
+
* of contents, # alone jumps to that entry's bookmark.
|
|
236
|
+
*/
|
|
233
237
|
href: string;
|
|
234
238
|
gap?: string;
|
|
235
239
|
width?: string;
|
|
@@ -252,6 +256,10 @@ export interface SpanAttr {
|
|
|
252
256
|
font?: string;
|
|
253
257
|
bold?: string;
|
|
254
258
|
color?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Makes the span a link: a URL, or #id to jump to the bookmark with that id. In an entry of a
|
|
261
|
+
* table of contents, # alone jumps to that entry's bookmark.
|
|
262
|
+
*/
|
|
255
263
|
href?: string;
|
|
256
264
|
underline?: string;
|
|
257
265
|
strike?: string;
|
|
@@ -305,6 +313,19 @@ export interface TextAttr {
|
|
|
305
313
|
color?: string;
|
|
306
314
|
align?: string;
|
|
307
315
|
width?: string;
|
|
316
|
+
/**
|
|
317
|
+
* The fewest lines of the text that may stand alone at the top of the next page when it splits.
|
|
318
|
+
* Default 2. If fewer would be left, lines move from the first page to the next; 1 turns the
|
|
319
|
+
* protection off.
|
|
320
|
+
*/
|
|
321
|
+
widows?: string;
|
|
322
|
+
/**
|
|
323
|
+
* The fewest lines of the text that may stand alone at the bottom of a page when it splits.
|
|
324
|
+
* Default 2. If fewer would fit, the whole text moves to the next page; 1 turns the protection
|
|
325
|
+
* off. When no split can keep both widows and orphans, even on an empty page, the text splits
|
|
326
|
+
* where the lines fit.
|
|
327
|
+
*/
|
|
328
|
+
orphans?: string;
|
|
308
329
|
paginate?: string;
|
|
309
330
|
debug?: string;
|
|
310
331
|
}
|
|
@@ -395,6 +416,27 @@ export interface FieldAttr {
|
|
|
395
416
|
border?: string;
|
|
396
417
|
debug?: string;
|
|
397
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* An entry of the PDF's outline, the bookmark panel of a viewer, and a target for links with
|
|
421
|
+
* href="#id". It draws nothing and marks the element that follows it, so it is never left at the
|
|
422
|
+
* bottom of a page apart from that element. Directly inside a section, it marks the section's first
|
|
423
|
+
* page.
|
|
424
|
+
*/
|
|
425
|
+
export interface BookmarkAttr {
|
|
426
|
+
/** The text of the entry, in the outline and in a table of contents. */
|
|
427
|
+
label: string;
|
|
428
|
+
/**
|
|
429
|
+
* Depth in the outline, 1 to 6. Defaults to 1. An entry nests under the closest entry before it
|
|
430
|
+
* with a lower level.
|
|
431
|
+
*/
|
|
432
|
+
level?: string;
|
|
433
|
+
/**
|
|
434
|
+
* The name links use to jump here, as href="#id". Leave it out to make it from the label:
|
|
435
|
+
* lowercase, with other characters than letters and digits turned into hyphens, and -2, -3 added
|
|
436
|
+
* when an earlier bookmark has it. Two bookmarks may not have the same id.
|
|
437
|
+
*/
|
|
438
|
+
id?: string;
|
|
439
|
+
}
|
|
398
440
|
/**
|
|
399
441
|
* Pins content to the top or bottom edge of pages, outside the normal flow, for headers and
|
|
400
442
|
* 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 { StackAttr, FlankAttr, SplitAttr, ClusterAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, BarcodeAttr, RegionAttr, FieldAttr, 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, } from './layout';
|
|
6
|
+
export type { StackAttr, FlankAttr, SplitAttr, ClusterAttr, 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,4 +1,4 @@
|
|
|
1
|
-
import type { StackAttr, FlankAttr, SplitAttr, ClusterAttr, GridAttr, FrameAttr, LinkAttr, TableAttr, TheadAttr, TrAttr, TdAttr, TextAttr, SpanAttr, DividerAttr, ImgAttr, BarcodeAttr, FieldAttr, RegionAttr } from './attrs';
|
|
1
|
+
import type { StackAttr, FlankAttr, SplitAttr, ClusterAttr, 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>;
|
|
@@ -55,7 +55,12 @@ export interface LpdfFieldNode {
|
|
|
55
55
|
type: 'field';
|
|
56
56
|
attrs: Record<string, string>;
|
|
57
57
|
}
|
|
58
|
-
|
|
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;
|
|
59
64
|
declare function stack(attrs: StackAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
60
65
|
declare function flank(attrs: FlankAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
61
66
|
declare function split(attrs: SplitAttr | null, nodes?: LpdfNode[]): LpdfContainerNode;
|
|
@@ -74,6 +79,11 @@ declare function img(attrs: ImgAttr): LpdfImgNode;
|
|
|
74
79
|
declare function barcode(attrs: BarcodeAttr): LpdfBarcodeNode;
|
|
75
80
|
declare function region(attrs: RegionAttr, nodes?: LpdfNode[]): LpdfRegionNode;
|
|
76
81
|
declare function field(attrs: FieldAttr): LpdfFieldNode;
|
|
82
|
+
/**
|
|
83
|
+
* An entry of the PDF's outline and a target for `href: '#id'` links. It marks the node that follows it
|
|
84
|
+
* in the same list; directly in a section's nodes, it marks the section's first page.
|
|
85
|
+
*/
|
|
86
|
+
declare function bookmark(attrs: BookmarkAttr): LpdfBookmarkNode;
|
|
77
87
|
export declare const LpdfLayout: Readonly<{
|
|
78
88
|
stack: typeof stack;
|
|
79
89
|
flank: typeof flank;
|
|
@@ -93,5 +103,6 @@ export declare const LpdfLayout: Readonly<{
|
|
|
93
103
|
td: typeof td;
|
|
94
104
|
region: typeof region;
|
|
95
105
|
field: typeof field;
|
|
106
|
+
bookmark: typeof bookmark;
|
|
96
107
|
}>;
|
|
97
108
|
export {};
|
package/dist/layout.js
CHANGED
|
@@ -61,6 +61,13 @@ function region(attrs, nodes = []) {
|
|
|
61
61
|
function field(attrs) {
|
|
62
62
|
return { type: 'field', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* An entry of the PDF's outline and a target for `href: '#id'` links. It marks the node that follows it
|
|
66
|
+
* in the same list; directly in a section's nodes, it marks the section's first page.
|
|
67
|
+
*/
|
|
68
|
+
function bookmark(attrs) {
|
|
69
|
+
return { type: 'bookmark', attrs: (0, _shared_1.buildAttrs)(attrs) };
|
|
70
|
+
}
|
|
64
71
|
exports.LpdfLayout = Object.freeze({
|
|
65
72
|
stack,
|
|
66
73
|
flank,
|
|
@@ -80,4 +87,5 @@ exports.LpdfLayout = Object.freeze({
|
|
|
80
87
|
td,
|
|
81
88
|
region,
|
|
82
89
|
field,
|
|
90
|
+
bookmark,
|
|
83
91
|
});
|
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.25.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",
|