js.documents 1.73.0 → 1.74.1
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/edit/pdf/editor.cjs +63 -0
- package/dist/edit/pdf/editor.d.cts +26 -0
- package/dist/edit/pdf/editor.d.ts +26 -0
- package/dist/edit/pdf/editor.js +60 -0
- package/dist/edit/pdf/item.cjs +483 -0
- package/dist/edit/pdf/item.d.cts +2 -0
- package/dist/edit/pdf/item.d.ts +2 -0
- package/dist/edit/pdf/item.js +468 -0
- package/dist/edit/pdf/page.cjs +178 -0
- package/dist/edit/pdf/page.d.cts +49 -0
- package/dist/edit/pdf/page.d.ts +49 -0
- package/dist/edit/pdf/page.js +176 -0
- package/dist/edit/pdf/util.cjs +38 -0
- package/dist/edit/pdf/util.d.cts +6 -0
- package/dist/edit/pdf/util.d.ts +6 -0
- package/dist/edit/pdf/util.js +36 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/item-CNEgqooo.d.ts +227 -0
- package/dist/item-DhYRoAvM.d.cts +227 -0
- package/dist/markdown/read.cjs +1 -5
- package/dist/markdown/read.js +1 -5
- package/dist/markdown/write.cjs +14 -27
- package/dist/markdown/write.js +14 -27
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
4
|
+
const require_edit_pdf_page = require("./page.cjs");
|
|
5
|
+
let document_schema_js = require("document-schema.js");
|
|
6
|
+
let pdf_codec = require("pdf-codec");
|
|
7
|
+
//#region src/edit/pdf/editor.ts
|
|
8
|
+
var PdfEditor = class {
|
|
9
|
+
doc;
|
|
10
|
+
constructor(doc) {
|
|
11
|
+
this.doc = doc;
|
|
12
|
+
}
|
|
13
|
+
get metadata() {
|
|
14
|
+
return this.doc.metadata;
|
|
15
|
+
}
|
|
16
|
+
set metadata(value) {
|
|
17
|
+
this.doc.metadata = value;
|
|
18
|
+
}
|
|
19
|
+
pages() {
|
|
20
|
+
return this.doc.pages.map((page) => new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images));
|
|
21
|
+
}
|
|
22
|
+
page(index) {
|
|
23
|
+
const node = this.doc.pages[index];
|
|
24
|
+
return node === void 0 ? void 0 : new require_edit_pdf_page.PdfPage(this.doc.pages, node, this.doc.images);
|
|
25
|
+
}
|
|
26
|
+
appendPage(init) {
|
|
27
|
+
const page = require_edit_pdf_page.buildPage(init);
|
|
28
|
+
this.doc.pages.push(page);
|
|
29
|
+
return new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images);
|
|
30
|
+
}
|
|
31
|
+
insertPageAt(index, init) {
|
|
32
|
+
const page = require_edit_pdf_page.buildPage(init);
|
|
33
|
+
const insertAt = Math.min(Math.max(index, 0), this.doc.pages.length);
|
|
34
|
+
this.doc.pages.splice(insertAt, 0, page);
|
|
35
|
+
return new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images);
|
|
36
|
+
}
|
|
37
|
+
toLayoutDocument() {
|
|
38
|
+
return this.doc;
|
|
39
|
+
}
|
|
40
|
+
toBytes(options) {
|
|
41
|
+
return (0, pdf_codec.writePdf)(this.doc, options);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
function openPdf(bytes, options) {
|
|
45
|
+
return new PdfEditor((0, pdf_codec.readPdf)(bytes, options));
|
|
46
|
+
}
|
|
47
|
+
function createPdf(options) {
|
|
48
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
49
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
50
|
+
return new PdfEditor({
|
|
51
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
52
|
+
metadata,
|
|
53
|
+
pages: [require_edit_pdf_page.buildPage({
|
|
54
|
+
widthPt: options?.widthPt,
|
|
55
|
+
heightPt: options?.heightPt
|
|
56
|
+
})],
|
|
57
|
+
images: {}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.PdfEditor = PdfEditor;
|
|
62
|
+
exports.createPdf = createPdf;
|
|
63
|
+
exports.openPdf = openPdf;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
|
+
import { PageInit, PdfPage } from "./page.cjs";
|
|
3
|
+
import { LayoutDocument, LayoutMetadata } from "document-schema.js";
|
|
4
|
+
import { ReadPdfOptions, WritePdfOptions } from "pdf-codec";
|
|
5
|
+
//#region src/edit/pdf/editor.d.ts
|
|
6
|
+
declare class PdfEditor {
|
|
7
|
+
private readonly doc;
|
|
8
|
+
constructor(doc: LayoutDocument);
|
|
9
|
+
get metadata(): LayoutMetadata;
|
|
10
|
+
set metadata(value: LayoutMetadata);
|
|
11
|
+
pages(): PdfPage[];
|
|
12
|
+
page(index: number): PdfPage | undefined;
|
|
13
|
+
appendPage(init?: PageInit): PdfPage;
|
|
14
|
+
insertPageAt(index: number, init?: PageInit): PdfPage;
|
|
15
|
+
toLayoutDocument(): LayoutDocument;
|
|
16
|
+
toBytes(options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
declare function openPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): PdfEditor;
|
|
19
|
+
interface CreatePdfOptions {
|
|
20
|
+
readonly widthPt?: number;
|
|
21
|
+
readonly heightPt?: number;
|
|
22
|
+
readonly clock?: ClockPort;
|
|
23
|
+
}
|
|
24
|
+
declare function createPdf(options?: CreatePdfOptions): PdfEditor;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CreatePdfOptions, PdfEditor, createPdf, openPdf };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
2
|
+
import { PageInit, PdfPage } from "./page.js";
|
|
3
|
+
import { LayoutDocument, LayoutMetadata } from "document-schema.js";
|
|
4
|
+
import { ReadPdfOptions, WritePdfOptions } from "pdf-codec";
|
|
5
|
+
//#region src/edit/pdf/editor.d.ts
|
|
6
|
+
declare class PdfEditor {
|
|
7
|
+
private readonly doc;
|
|
8
|
+
constructor(doc: LayoutDocument);
|
|
9
|
+
get metadata(): LayoutMetadata;
|
|
10
|
+
set metadata(value: LayoutMetadata);
|
|
11
|
+
pages(): PdfPage[];
|
|
12
|
+
page(index: number): PdfPage | undefined;
|
|
13
|
+
appendPage(init?: PageInit): PdfPage;
|
|
14
|
+
insertPageAt(index: number, init?: PageInit): PdfPage;
|
|
15
|
+
toLayoutDocument(): LayoutDocument;
|
|
16
|
+
toBytes(options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
declare function openPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): PdfEditor;
|
|
19
|
+
interface CreatePdfOptions {
|
|
20
|
+
readonly widthPt?: number;
|
|
21
|
+
readonly heightPt?: number;
|
|
22
|
+
readonly clock?: ClockPort;
|
|
23
|
+
}
|
|
24
|
+
declare function createPdf(options?: CreatePdfOptions): PdfEditor;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CreatePdfOptions, PdfEditor, createPdf, openPdf };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
3
|
+
import { PdfPage, buildPage } from "./page.js";
|
|
4
|
+
import { LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
5
|
+
import { readPdf, writePdf } from "pdf-codec";
|
|
6
|
+
//#region src/edit/pdf/editor.ts
|
|
7
|
+
var PdfEditor = class {
|
|
8
|
+
doc;
|
|
9
|
+
constructor(doc) {
|
|
10
|
+
this.doc = doc;
|
|
11
|
+
}
|
|
12
|
+
get metadata() {
|
|
13
|
+
return this.doc.metadata;
|
|
14
|
+
}
|
|
15
|
+
set metadata(value) {
|
|
16
|
+
this.doc.metadata = value;
|
|
17
|
+
}
|
|
18
|
+
pages() {
|
|
19
|
+
return this.doc.pages.map((page) => new PdfPage(this.doc.pages, page, this.doc.images));
|
|
20
|
+
}
|
|
21
|
+
page(index) {
|
|
22
|
+
const node = this.doc.pages[index];
|
|
23
|
+
return node === void 0 ? void 0 : new PdfPage(this.doc.pages, node, this.doc.images);
|
|
24
|
+
}
|
|
25
|
+
appendPage(init) {
|
|
26
|
+
const page = buildPage(init);
|
|
27
|
+
this.doc.pages.push(page);
|
|
28
|
+
return new PdfPage(this.doc.pages, page, this.doc.images);
|
|
29
|
+
}
|
|
30
|
+
insertPageAt(index, init) {
|
|
31
|
+
const page = buildPage(init);
|
|
32
|
+
const insertAt = Math.min(Math.max(index, 0), this.doc.pages.length);
|
|
33
|
+
this.doc.pages.splice(insertAt, 0, page);
|
|
34
|
+
return new PdfPage(this.doc.pages, page, this.doc.images);
|
|
35
|
+
}
|
|
36
|
+
toLayoutDocument() {
|
|
37
|
+
return this.doc;
|
|
38
|
+
}
|
|
39
|
+
toBytes(options) {
|
|
40
|
+
return writePdf(this.doc, options);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function openPdf(bytes, options) {
|
|
44
|
+
return new PdfEditor(readPdf(bytes, options));
|
|
45
|
+
}
|
|
46
|
+
function createPdf(options) {
|
|
47
|
+
const clock = options?.clock ?? systemClock;
|
|
48
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
49
|
+
return new PdfEditor({
|
|
50
|
+
formatVersion: LAYOUT_FORMAT_VERSION,
|
|
51
|
+
metadata,
|
|
52
|
+
pages: [buildPage({
|
|
53
|
+
widthPt: options?.widthPt,
|
|
54
|
+
heightPt: options?.heightPt
|
|
55
|
+
})],
|
|
56
|
+
images: {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { PdfEditor, createPdf, openPdf };
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_edit_pdf_util = require("./util.cjs");
|
|
3
|
+
//#region src/edit/pdf/item.ts
|
|
4
|
+
var PdfItemBase = class {
|
|
5
|
+
container;
|
|
6
|
+
node;
|
|
7
|
+
typeName;
|
|
8
|
+
removed = false;
|
|
9
|
+
constructor(container, node, typeName) {
|
|
10
|
+
this.container = container;
|
|
11
|
+
this.node = node;
|
|
12
|
+
this.typeName = typeName;
|
|
13
|
+
}
|
|
14
|
+
live() {
|
|
15
|
+
if (this.removed) throw new Error(`this ${this.typeName} has been removed from its page and can no longer be used`);
|
|
16
|
+
return this.node;
|
|
17
|
+
}
|
|
18
|
+
get sourcePath() {
|
|
19
|
+
return this.live().sourcePath;
|
|
20
|
+
}
|
|
21
|
+
remove() {
|
|
22
|
+
const node = this.live();
|
|
23
|
+
require_edit_pdf_util.spliceOut(this.container, node);
|
|
24
|
+
this.removed = true;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function requirePositive(value, field) {
|
|
28
|
+
if (!(value > 0)) throw new Error(`${field} must be a positive number, got ${value}`);
|
|
29
|
+
}
|
|
30
|
+
function requireNonNegative(value, field) {
|
|
31
|
+
if (!(value >= 0)) throw new Error(`${field} must be a nonnegative number, got ${value}`);
|
|
32
|
+
}
|
|
33
|
+
function setOrDelete(node, key, value) {
|
|
34
|
+
if (value === void 0) {
|
|
35
|
+
delete node[key];
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
node[key] = value;
|
|
39
|
+
}
|
|
40
|
+
function buildTextItem(init) {
|
|
41
|
+
requirePositive(init.sizePt, "sizePt");
|
|
42
|
+
return {
|
|
43
|
+
kind: "text",
|
|
44
|
+
xPt: init.xPt,
|
|
45
|
+
yPt: init.yPt,
|
|
46
|
+
text: init.text,
|
|
47
|
+
font: init.font,
|
|
48
|
+
sizePt: init.sizePt,
|
|
49
|
+
color: init.color,
|
|
50
|
+
rotationDeg: init.rotationDeg,
|
|
51
|
+
underline: init.underline
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var PdfTextItem = class extends PdfItemBase {
|
|
55
|
+
kind = "text";
|
|
56
|
+
constructor(container, node) {
|
|
57
|
+
super(container, node, "PdfTextItem");
|
|
58
|
+
}
|
|
59
|
+
get xPt() {
|
|
60
|
+
return this.live().xPt;
|
|
61
|
+
}
|
|
62
|
+
set xPt(value) {
|
|
63
|
+
this.live().xPt = value;
|
|
64
|
+
}
|
|
65
|
+
get yPt() {
|
|
66
|
+
return this.live().yPt;
|
|
67
|
+
}
|
|
68
|
+
set yPt(value) {
|
|
69
|
+
this.live().yPt = value;
|
|
70
|
+
}
|
|
71
|
+
get text() {
|
|
72
|
+
return this.live().text;
|
|
73
|
+
}
|
|
74
|
+
set text(value) {
|
|
75
|
+
this.live().text = value;
|
|
76
|
+
}
|
|
77
|
+
get font() {
|
|
78
|
+
return this.live().font;
|
|
79
|
+
}
|
|
80
|
+
set font(value) {
|
|
81
|
+
this.live().font = value;
|
|
82
|
+
}
|
|
83
|
+
get sizePt() {
|
|
84
|
+
return this.live().sizePt;
|
|
85
|
+
}
|
|
86
|
+
set sizePt(value) {
|
|
87
|
+
requirePositive(value, "sizePt");
|
|
88
|
+
this.live().sizePt = value;
|
|
89
|
+
}
|
|
90
|
+
get color() {
|
|
91
|
+
return this.live().color;
|
|
92
|
+
}
|
|
93
|
+
set color(value) {
|
|
94
|
+
this.live().color = value;
|
|
95
|
+
}
|
|
96
|
+
get widthPt() {
|
|
97
|
+
return this.live().widthPt;
|
|
98
|
+
}
|
|
99
|
+
set widthPt(value) {
|
|
100
|
+
if (value !== void 0) requireNonNegative(value, "widthPt");
|
|
101
|
+
setOrDelete(this.live(), "widthPt", value);
|
|
102
|
+
}
|
|
103
|
+
get rotationDeg() {
|
|
104
|
+
return this.live().rotationDeg;
|
|
105
|
+
}
|
|
106
|
+
set rotationDeg(value) {
|
|
107
|
+
setOrDelete(this.live(), "rotationDeg", value);
|
|
108
|
+
}
|
|
109
|
+
get underline() {
|
|
110
|
+
return this.live().underline;
|
|
111
|
+
}
|
|
112
|
+
set underline(value) {
|
|
113
|
+
setOrDelete(this.live(), "underline", value);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function requireValidStroke(stroke) {
|
|
117
|
+
if (stroke !== void 0) requirePositive(stroke.widthPt, "stroke.widthPt");
|
|
118
|
+
}
|
|
119
|
+
function buildRectItem(init) {
|
|
120
|
+
requireNonNegative(init.widthPt, "widthPt");
|
|
121
|
+
requireNonNegative(init.heightPt, "heightPt");
|
|
122
|
+
requireValidStroke(init.stroke);
|
|
123
|
+
return {
|
|
124
|
+
kind: "rect",
|
|
125
|
+
xPt: init.xPt,
|
|
126
|
+
yPt: init.yPt,
|
|
127
|
+
widthPt: init.widthPt,
|
|
128
|
+
heightPt: init.heightPt,
|
|
129
|
+
fill: init.fill,
|
|
130
|
+
stroke: init.stroke
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function buildEllipseItem(init) {
|
|
134
|
+
requirePositive(init.widthPt, "widthPt");
|
|
135
|
+
requirePositive(init.heightPt, "heightPt");
|
|
136
|
+
requireValidStroke(init.stroke);
|
|
137
|
+
return {
|
|
138
|
+
kind: "ellipse",
|
|
139
|
+
xPt: init.xPt,
|
|
140
|
+
yPt: init.yPt,
|
|
141
|
+
widthPt: init.widthPt,
|
|
142
|
+
heightPt: init.heightPt,
|
|
143
|
+
fill: init.fill,
|
|
144
|
+
stroke: init.stroke
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
var PdfRectItem = class extends PdfItemBase {
|
|
148
|
+
kind = "rect";
|
|
149
|
+
constructor(container, node) {
|
|
150
|
+
super(container, node, "PdfRectItem");
|
|
151
|
+
}
|
|
152
|
+
get xPt() {
|
|
153
|
+
return this.live().xPt;
|
|
154
|
+
}
|
|
155
|
+
set xPt(value) {
|
|
156
|
+
this.live().xPt = value;
|
|
157
|
+
}
|
|
158
|
+
get yPt() {
|
|
159
|
+
return this.live().yPt;
|
|
160
|
+
}
|
|
161
|
+
set yPt(value) {
|
|
162
|
+
this.live().yPt = value;
|
|
163
|
+
}
|
|
164
|
+
get widthPt() {
|
|
165
|
+
return this.live().widthPt;
|
|
166
|
+
}
|
|
167
|
+
set widthPt(value) {
|
|
168
|
+
requireNonNegative(value, "widthPt");
|
|
169
|
+
this.live().widthPt = value;
|
|
170
|
+
}
|
|
171
|
+
get heightPt() {
|
|
172
|
+
return this.live().heightPt;
|
|
173
|
+
}
|
|
174
|
+
set heightPt(value) {
|
|
175
|
+
requireNonNegative(value, "heightPt");
|
|
176
|
+
this.live().heightPt = value;
|
|
177
|
+
}
|
|
178
|
+
get fill() {
|
|
179
|
+
return this.live().fill;
|
|
180
|
+
}
|
|
181
|
+
set fill(value) {
|
|
182
|
+
setOrDelete(this.live(), "fill", value);
|
|
183
|
+
}
|
|
184
|
+
get stroke() {
|
|
185
|
+
return this.live().stroke;
|
|
186
|
+
}
|
|
187
|
+
set stroke(value) {
|
|
188
|
+
requireValidStroke(value);
|
|
189
|
+
setOrDelete(this.live(), "stroke", value);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var PdfEllipseItem = class extends PdfItemBase {
|
|
193
|
+
kind = "ellipse";
|
|
194
|
+
constructor(container, node) {
|
|
195
|
+
super(container, node, "PdfEllipseItem");
|
|
196
|
+
}
|
|
197
|
+
get xPt() {
|
|
198
|
+
return this.live().xPt;
|
|
199
|
+
}
|
|
200
|
+
set xPt(value) {
|
|
201
|
+
this.live().xPt = value;
|
|
202
|
+
}
|
|
203
|
+
get yPt() {
|
|
204
|
+
return this.live().yPt;
|
|
205
|
+
}
|
|
206
|
+
set yPt(value) {
|
|
207
|
+
this.live().yPt = value;
|
|
208
|
+
}
|
|
209
|
+
get widthPt() {
|
|
210
|
+
return this.live().widthPt;
|
|
211
|
+
}
|
|
212
|
+
set widthPt(value) {
|
|
213
|
+
requirePositive(value, "widthPt");
|
|
214
|
+
this.live().widthPt = value;
|
|
215
|
+
}
|
|
216
|
+
get heightPt() {
|
|
217
|
+
return this.live().heightPt;
|
|
218
|
+
}
|
|
219
|
+
set heightPt(value) {
|
|
220
|
+
requirePositive(value, "heightPt");
|
|
221
|
+
this.live().heightPt = value;
|
|
222
|
+
}
|
|
223
|
+
get fill() {
|
|
224
|
+
return this.live().fill;
|
|
225
|
+
}
|
|
226
|
+
set fill(value) {
|
|
227
|
+
setOrDelete(this.live(), "fill", value);
|
|
228
|
+
}
|
|
229
|
+
get stroke() {
|
|
230
|
+
return this.live().stroke;
|
|
231
|
+
}
|
|
232
|
+
set stroke(value) {
|
|
233
|
+
requireValidStroke(value);
|
|
234
|
+
setOrDelete(this.live(), "stroke", value);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
function buildLineItem(init) {
|
|
238
|
+
requirePositive(init.widthPt, "widthPt");
|
|
239
|
+
return {
|
|
240
|
+
kind: "line",
|
|
241
|
+
x1Pt: init.x1Pt,
|
|
242
|
+
y1Pt: init.y1Pt,
|
|
243
|
+
x2Pt: init.x2Pt,
|
|
244
|
+
y2Pt: init.y2Pt,
|
|
245
|
+
color: init.color,
|
|
246
|
+
widthPt: init.widthPt,
|
|
247
|
+
style: init.style
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
var PdfLineItem = class extends PdfItemBase {
|
|
251
|
+
kind = "line";
|
|
252
|
+
constructor(container, node) {
|
|
253
|
+
super(container, node, "PdfLineItem");
|
|
254
|
+
}
|
|
255
|
+
get x1Pt() {
|
|
256
|
+
return this.live().x1Pt;
|
|
257
|
+
}
|
|
258
|
+
set x1Pt(value) {
|
|
259
|
+
this.live().x1Pt = value;
|
|
260
|
+
}
|
|
261
|
+
get y1Pt() {
|
|
262
|
+
return this.live().y1Pt;
|
|
263
|
+
}
|
|
264
|
+
set y1Pt(value) {
|
|
265
|
+
this.live().y1Pt = value;
|
|
266
|
+
}
|
|
267
|
+
get x2Pt() {
|
|
268
|
+
return this.live().x2Pt;
|
|
269
|
+
}
|
|
270
|
+
set x2Pt(value) {
|
|
271
|
+
this.live().x2Pt = value;
|
|
272
|
+
}
|
|
273
|
+
get y2Pt() {
|
|
274
|
+
return this.live().y2Pt;
|
|
275
|
+
}
|
|
276
|
+
set y2Pt(value) {
|
|
277
|
+
this.live().y2Pt = value;
|
|
278
|
+
}
|
|
279
|
+
get color() {
|
|
280
|
+
return this.live().color;
|
|
281
|
+
}
|
|
282
|
+
set color(value) {
|
|
283
|
+
this.live().color = value;
|
|
284
|
+
}
|
|
285
|
+
get widthPt() {
|
|
286
|
+
return this.live().widthPt;
|
|
287
|
+
}
|
|
288
|
+
set widthPt(value) {
|
|
289
|
+
requirePositive(value, "widthPt");
|
|
290
|
+
this.live().widthPt = value;
|
|
291
|
+
}
|
|
292
|
+
get style() {
|
|
293
|
+
return this.live().style;
|
|
294
|
+
}
|
|
295
|
+
set style(value) {
|
|
296
|
+
setOrDelete(this.live(), "style", value);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
function buildPathItem(init) {
|
|
300
|
+
requireValidStroke(init.stroke);
|
|
301
|
+
return {
|
|
302
|
+
kind: "path",
|
|
303
|
+
subpaths: [...init.subpaths],
|
|
304
|
+
fill: init.fill,
|
|
305
|
+
fillRule: init.fillRule,
|
|
306
|
+
stroke: init.stroke,
|
|
307
|
+
style: init.style
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
var PdfPathItem = class extends PdfItemBase {
|
|
311
|
+
kind = "path";
|
|
312
|
+
constructor(container, node) {
|
|
313
|
+
super(container, node, "PdfPathItem");
|
|
314
|
+
}
|
|
315
|
+
get subpaths() {
|
|
316
|
+
return this.live().subpaths;
|
|
317
|
+
}
|
|
318
|
+
set subpaths(value) {
|
|
319
|
+
this.live().subpaths = [...value];
|
|
320
|
+
}
|
|
321
|
+
get fill() {
|
|
322
|
+
return this.live().fill;
|
|
323
|
+
}
|
|
324
|
+
set fill(value) {
|
|
325
|
+
setOrDelete(this.live(), "fill", value);
|
|
326
|
+
}
|
|
327
|
+
get fillRule() {
|
|
328
|
+
return this.live().fillRule;
|
|
329
|
+
}
|
|
330
|
+
set fillRule(value) {
|
|
331
|
+
setOrDelete(this.live(), "fillRule", value);
|
|
332
|
+
}
|
|
333
|
+
get stroke() {
|
|
334
|
+
return this.live().stroke;
|
|
335
|
+
}
|
|
336
|
+
set stroke(value) {
|
|
337
|
+
requireValidStroke(value);
|
|
338
|
+
setOrDelete(this.live(), "stroke", value);
|
|
339
|
+
}
|
|
340
|
+
get style() {
|
|
341
|
+
return this.live().style;
|
|
342
|
+
}
|
|
343
|
+
set style(value) {
|
|
344
|
+
setOrDelete(this.live(), "style", value);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
function buildImageItem(init, images) {
|
|
348
|
+
requirePositive(init.widthPt, "widthPt");
|
|
349
|
+
requirePositive(init.heightPt, "heightPt");
|
|
350
|
+
return {
|
|
351
|
+
kind: "image",
|
|
352
|
+
imageId: require_edit_pdf_util.registerImageBytes(init.bytes, init.format, images),
|
|
353
|
+
xPt: init.xPt,
|
|
354
|
+
yPt: init.yPt,
|
|
355
|
+
widthPt: init.widthPt,
|
|
356
|
+
heightPt: init.heightPt,
|
|
357
|
+
rotationDeg: init.rotationDeg
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
var PdfImageItem = class extends PdfItemBase {
|
|
361
|
+
kind = "image";
|
|
362
|
+
images;
|
|
363
|
+
constructor(container, node, images) {
|
|
364
|
+
super(container, node, "PdfImageItem");
|
|
365
|
+
this.images = images;
|
|
366
|
+
}
|
|
367
|
+
get imageId() {
|
|
368
|
+
return this.live().imageId;
|
|
369
|
+
}
|
|
370
|
+
get xPt() {
|
|
371
|
+
return this.live().xPt;
|
|
372
|
+
}
|
|
373
|
+
set xPt(value) {
|
|
374
|
+
this.live().xPt = value;
|
|
375
|
+
}
|
|
376
|
+
get yPt() {
|
|
377
|
+
return this.live().yPt;
|
|
378
|
+
}
|
|
379
|
+
set yPt(value) {
|
|
380
|
+
this.live().yPt = value;
|
|
381
|
+
}
|
|
382
|
+
get widthPt() {
|
|
383
|
+
return this.live().widthPt;
|
|
384
|
+
}
|
|
385
|
+
set widthPt(value) {
|
|
386
|
+
requirePositive(value, "widthPt");
|
|
387
|
+
this.live().widthPt = value;
|
|
388
|
+
}
|
|
389
|
+
get heightPt() {
|
|
390
|
+
return this.live().heightPt;
|
|
391
|
+
}
|
|
392
|
+
set heightPt(value) {
|
|
393
|
+
requirePositive(value, "heightPt");
|
|
394
|
+
this.live().heightPt = value;
|
|
395
|
+
}
|
|
396
|
+
get rotationDeg() {
|
|
397
|
+
return this.live().rotationDeg;
|
|
398
|
+
}
|
|
399
|
+
set rotationDeg(value) {
|
|
400
|
+
setOrDelete(this.live(), "rotationDeg", value);
|
|
401
|
+
}
|
|
402
|
+
setImage(bytes, format) {
|
|
403
|
+
const node = this.live();
|
|
404
|
+
node.imageId = require_edit_pdf_util.registerImageBytes(bytes, format, this.images);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
function buildLinkItem(init) {
|
|
408
|
+
requireNonNegative(init.widthPt, "widthPt");
|
|
409
|
+
requireNonNegative(init.heightPt, "heightPt");
|
|
410
|
+
return {
|
|
411
|
+
kind: "link",
|
|
412
|
+
uri: init.uri,
|
|
413
|
+
xPt: init.xPt,
|
|
414
|
+
yPt: init.yPt,
|
|
415
|
+
widthPt: init.widthPt,
|
|
416
|
+
heightPt: init.heightPt
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
var PdfLinkItem = class extends PdfItemBase {
|
|
420
|
+
kind = "link";
|
|
421
|
+
constructor(container, node) {
|
|
422
|
+
super(container, node, "PdfLinkItem");
|
|
423
|
+
}
|
|
424
|
+
get uri() {
|
|
425
|
+
return this.live().uri;
|
|
426
|
+
}
|
|
427
|
+
set uri(value) {
|
|
428
|
+
this.live().uri = value;
|
|
429
|
+
}
|
|
430
|
+
get xPt() {
|
|
431
|
+
return this.live().xPt;
|
|
432
|
+
}
|
|
433
|
+
set xPt(value) {
|
|
434
|
+
this.live().xPt = value;
|
|
435
|
+
}
|
|
436
|
+
get yPt() {
|
|
437
|
+
return this.live().yPt;
|
|
438
|
+
}
|
|
439
|
+
set yPt(value) {
|
|
440
|
+
this.live().yPt = value;
|
|
441
|
+
}
|
|
442
|
+
get widthPt() {
|
|
443
|
+
return this.live().widthPt;
|
|
444
|
+
}
|
|
445
|
+
set widthPt(value) {
|
|
446
|
+
requireNonNegative(value, "widthPt");
|
|
447
|
+
this.live().widthPt = value;
|
|
448
|
+
}
|
|
449
|
+
get heightPt() {
|
|
450
|
+
return this.live().heightPt;
|
|
451
|
+
}
|
|
452
|
+
set heightPt(value) {
|
|
453
|
+
requireNonNegative(value, "heightPt");
|
|
454
|
+
this.live().heightPt = value;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
function wrapItem(container, node, images) {
|
|
458
|
+
switch (node.kind) {
|
|
459
|
+
case "text": return new PdfTextItem(container, node);
|
|
460
|
+
case "image": return new PdfImageItem(container, node, images);
|
|
461
|
+
case "rect": return new PdfRectItem(container, node);
|
|
462
|
+
case "ellipse": return new PdfEllipseItem(container, node);
|
|
463
|
+
case "line": return new PdfLineItem(container, node);
|
|
464
|
+
case "path": return new PdfPathItem(container, node);
|
|
465
|
+
case "link": return new PdfLinkItem(container, node);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
exports.PdfEllipseItem = PdfEllipseItem;
|
|
470
|
+
exports.PdfImageItem = PdfImageItem;
|
|
471
|
+
exports.PdfLineItem = PdfLineItem;
|
|
472
|
+
exports.PdfLinkItem = PdfLinkItem;
|
|
473
|
+
exports.PdfPathItem = PdfPathItem;
|
|
474
|
+
exports.PdfRectItem = PdfRectItem;
|
|
475
|
+
exports.PdfTextItem = PdfTextItem;
|
|
476
|
+
exports.buildEllipseItem = buildEllipseItem;
|
|
477
|
+
exports.buildImageItem = buildImageItem;
|
|
478
|
+
exports.buildLineItem = buildLineItem;
|
|
479
|
+
exports.buildLinkItem = buildLinkItem;
|
|
480
|
+
exports.buildPathItem = buildPathItem;
|
|
481
|
+
exports.buildRectItem = buildRectItem;
|
|
482
|
+
exports.buildTextItem = buildTextItem;
|
|
483
|
+
exports.wrapItem = wrapItem;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as wrapItem, S as buildTextItem, _ as buildImageItem, a as PdfItem, b as buildPathItem, c as PdfLinkInit, d as PdfPathItem, f as PdfRectInit, g as buildEllipseItem, h as PdfTextItem, i as PdfImageItem, l as PdfLinkItem, m as PdfTextInit, n as PdfEllipseItem, o as PdfLineInit, p as PdfRectItem, r as PdfImageInit, s as PdfLineItem, t as PdfEllipseInit, u as PdfPathInit, v as buildLineItem, x as buildRectItem, y as buildLinkItem } from "../../item-DhYRoAvM.cjs";
|
|
2
|
+
export { PdfEllipseInit, PdfEllipseItem, PdfImageInit, PdfImageItem, PdfItem, PdfLineInit, PdfLineItem, PdfLinkInit, PdfLinkItem, PdfPathInit, PdfPathItem, PdfRectInit, PdfRectItem, PdfTextInit, PdfTextItem, buildEllipseItem, buildImageItem, buildLineItem, buildLinkItem, buildPathItem, buildRectItem, buildTextItem, wrapItem };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as wrapItem, S as buildTextItem, _ as buildImageItem, a as PdfItem, b as buildPathItem, c as PdfLinkInit, d as PdfPathItem, f as PdfRectInit, g as buildEllipseItem, h as PdfTextItem, i as PdfImageItem, l as PdfLinkItem, m as PdfTextInit, n as PdfEllipseItem, o as PdfLineInit, p as PdfRectItem, r as PdfImageInit, s as PdfLineItem, t as PdfEllipseInit, u as PdfPathInit, v as buildLineItem, x as buildRectItem, y as buildLinkItem } from "../../item-CNEgqooo.js";
|
|
2
|
+
export { PdfEllipseInit, PdfEllipseItem, PdfImageInit, PdfImageItem, PdfItem, PdfLineInit, PdfLineItem, PdfLinkInit, PdfLinkItem, PdfPathInit, PdfPathItem, PdfRectInit, PdfRectItem, PdfTextInit, PdfTextItem, buildEllipseItem, buildImageItem, buildLineItem, buildLinkItem, buildPathItem, buildRectItem, buildTextItem, wrapItem };
|