pdf-parser.js 5.2.30 → 5.3.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/{afm-widths-BHD2HZIL.cjs → afm-widths-C6U0SQj9.cjs} +5 -1448
- package/dist/{afm-widths-B_IGbGky.js → afm-widths-p3UfaXme.js} +3 -1398
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.d.cts +3 -3
- package/dist/annotations.d.ts +3 -3
- package/dist/attachments.d.cts +2 -2
- package/dist/attachments.d.ts +2 -2
- package/dist/builtin-encoding.cjs +4 -3
- package/dist/builtin-encoding.js +2 -1
- package/dist/cmap.d.cts +1 -1
- package/dist/cmap.d.ts +1 -1
- package/dist/content-read.d.cts +1 -1
- package/dist/content-read.d.ts +1 -1
- package/dist/content-write.cjs +1 -1
- package/dist/content-write.d.cts +1 -1
- package/dist/content-write.d.ts +1 -1
- package/dist/content-write.js +1 -1
- package/dist/diagnostics-C9FxfZ6H.d.cts +22 -0
- package/dist/diagnostics-C9FxfZ6H.d.ts +22 -0
- package/dist/diagnostics.d.cts +1 -21
- package/dist/diagnostics.d.ts +1 -21
- package/dist/document.d.cts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/{embedded-font-ByD7ZiQS.d.ts → embedded-font-CQZbTTDM.d.ts} +1 -1
- package/dist/{embedded-font-DgVBedw6.d.cts → embedded-font-CqePfvrl.d.cts} +1 -1
- package/dist/embedded-font-write.d.cts +1 -1
- package/dist/embedded-font-write.d.ts +1 -1
- package/dist/embedded-font.cjs +2 -2
- package/dist/embedded-font.d.cts +1 -1
- package/dist/embedded-font.d.ts +1 -1
- package/dist/embedded-font.js +2 -2
- package/dist/encoding-glyph-unicode.cjs +353 -0
- package/dist/encoding-glyph-unicode.d.cts +4 -0
- package/dist/encoding-glyph-unicode.d.ts +4 -0
- package/dist/encoding-glyph-unicode.js +352 -0
- package/dist/encoding-standard-tables.cjs +531 -0
- package/dist/encoding-standard-tables.d.cts +7 -0
- package/dist/encoding-standard-tables.d.ts +7 -0
- package/dist/encoding-standard-tables.js +527 -0
- package/dist/encoding-symbol-tables.cjs +531 -0
- package/dist/encoding-symbol-tables.d.cts +7 -0
- package/dist/encoding-symbol-tables.d.ts +7 -0
- package/dist/encoding-symbol-tables.js +527 -0
- package/dist/encoding.cjs +1 -9
- package/dist/encoding.d.cts +1 -9
- package/dist/encoding.d.ts +1 -9
- package/dist/encoding.js +2 -2
- package/dist/encrypt.d.cts +1 -1
- package/dist/encrypt.d.ts +1 -1
- package/dist/filters.d.cts +1 -1
- package/dist/filters.d.ts +1 -1
- package/dist/font-read.cjs +4 -3
- package/dist/font-read.d.cts +2 -2
- package/dist/font-read.d.ts +2 -2
- package/dist/font-read.js +2 -1
- package/dist/font-registry.d.cts +1 -1
- package/dist/font-registry.d.ts +1 -1
- package/dist/form.d.cts +2 -2
- package/dist/form.d.ts +2 -2
- package/dist/gdef-table-D0Hzn4KD.d.cts +15 -0
- package/dist/gdef-table-DL0V8wEZ.d.ts +15 -0
- package/dist/gdef-table.d.cts +1 -14
- package/dist/gdef-table.d.ts +1 -14
- package/dist/glyf-contours.d.cts +12 -1
- package/dist/glyf-contours.d.ts +12 -1
- package/dist/gsub-context.cjs +13 -0
- package/dist/gsub-context.d.cts +34 -0
- package/dist/gsub-context.d.ts +34 -0
- package/dist/gsub-context.js +2 -0
- package/dist/gsub-table-BDpJWqpf.d.ts +52 -0
- package/dist/gsub-table-D6niKeLi.js +556 -0
- package/dist/gsub-table-DW7Wmi9V.d.cts +52 -0
- package/dist/gsub-table-hFfYmf1W.cjs +741 -0
- package/dist/gsub-table.cjs +21 -556
- package/dist/gsub-table.d.cts +2 -2
- package/dist/gsub-table.d.ts +2 -2
- package/dist/gsub-table.js +2 -554
- package/dist/images-read.d.cts +2 -2
- package/dist/images-read.d.ts +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/interpret-CqXdXgkY.cjs +712 -0
- package/dist/interpret-aWWhdIzr.js +677 -0
- package/dist/interpret-colors.cjs +6 -0
- package/dist/interpret-colors.d.cts +9 -0
- package/dist/interpret-colors.d.ts +9 -0
- package/dist/interpret-colors.js +2 -0
- package/dist/interpret-marked.cjs +25 -0
- package/dist/interpret-marked.d.cts +11 -0
- package/dist/interpret-marked.d.ts +11 -0
- package/dist/interpret-marked.js +23 -0
- package/dist/interpret-shapes.cjs +212 -0
- package/dist/interpret-shapes.d.cts +32 -0
- package/dist/interpret-shapes.d.ts +32 -0
- package/dist/interpret-shapes.js +199 -0
- package/dist/interpret-types.cjs +0 -0
- package/dist/interpret-types.d.cts +123 -0
- package/dist/interpret-types.d.ts +123 -0
- package/dist/interpret-types.js +0 -0
- package/dist/interpret.cjs +3 -887
- package/dist/interpret.d.cts +5 -116
- package/dist/interpret.d.ts +5 -116
- package/dist/interpret.js +2 -887
- package/dist/math-font.cjs +1 -1
- package/dist/math-font.js +1 -1
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/names.d.cts +2 -2
- package/dist/names.d.ts +2 -2
- package/dist/navigation.d.cts +2 -2
- package/dist/navigation.d.ts +2 -2
- package/dist/optional-content.d.cts +2 -2
- package/dist/optional-content.d.ts +2 -2
- package/dist/ot-layout-common-BcsGRFBS.d.cts +10 -0
- package/dist/ot-layout-common-BcsGRFBS.d.ts +10 -0
- package/dist/ot-layout-common.d.cts +1 -9
- package/dist/ot-layout-common.d.ts +1 -9
- package/dist/parse.d.cts +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/predictors.d.cts +1 -1
- package/dist/predictors.d.ts +1 -1
- package/dist/raster-Cdm3idP_.js +794 -0
- package/dist/raster-EG2KYRZ0.cjs +829 -0
- package/dist/raster-text.cjs +5 -0
- package/dist/raster-text.d.cts +20 -0
- package/dist/raster-text.d.ts +20 -0
- package/dist/raster-text.js +2 -0
- package/dist/raster.cjs +4 -795
- package/dist/raster.d.cts +17 -6
- package/dist/raster.d.ts +17 -6
- package/dist/raster.js +2 -792
- package/dist/read-convert.cjs +310 -0
- package/dist/read-convert.d.cts +58 -0
- package/dist/read-convert.d.ts +58 -0
- package/dist/read-convert.js +295 -0
- package/dist/read.cjs +5 -293
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/read.js +4 -292
- package/dist/structure.d.cts +2 -2
- package/dist/structure.d.ts +2 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write-annotations.cjs +132 -0
- package/dist/write-annotations.d.cts +29 -0
- package/dist/write-annotations.d.ts +29 -0
- package/dist/write-annotations.js +121 -0
- package/dist/write-font-objects.cjs +76 -0
- package/dist/write-font-objects.d.cts +35 -0
- package/dist/write-font-objects.d.ts +35 -0
- package/dist/write-font-objects.js +75 -0
- package/dist/write-form.cjs +91 -0
- package/dist/write-form.d.cts +19 -0
- package/dist/write-form.d.ts +19 -0
- package/dist/write-form.js +89 -0
- package/dist/write-images.cjs +148 -0
- package/dist/write-images.d.cts +25 -0
- package/dist/write-images.d.ts +25 -0
- package/dist/write-images.js +140 -0
- package/dist/write-outline.cjs +46 -0
- package/dist/write-outline.d.cts +18 -0
- package/dist/write-outline.d.ts +18 -0
- package/dist/write-outline.js +45 -0
- package/dist/write-page-emit.cjs +97 -0
- package/dist/write-page-emit.d.cts +63 -0
- package/dist/write-page-emit.d.ts +63 -0
- package/dist/write-page-emit.js +96 -0
- package/dist/write-pages.cjs +37 -0
- package/dist/write-pages.d.cts +21 -0
- package/dist/write-pages.d.ts +21 -0
- package/dist/write-pages.js +36 -0
- package/dist/write-strings.cjs +41 -0
- package/dist/write-strings.d.cts +9 -0
- package/dist/write-strings.d.ts +9 -0
- package/dist/write-strings.js +37 -0
- package/dist/write.cjs +53 -553
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +49 -549
- package/dist/xref.d.cts +1 -1
- package/dist/xref.d.ts +1 -1
- package/package.json +1 -1
- package/dist/glyf-contours-B1PsI9oA.d.ts +0 -13
- package/dist/glyf-contours-NHBpgks-.d.cts +0 -13
- package/dist/gsub-table-Bm9kSMzk.d.cts +0 -16
- package/dist/gsub-table-CdfESH2-.d.ts +0 -16
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
3
|
+
const require_math_content_write = require("./math-content-write.cjs");
|
|
4
|
+
const require_math_font = require("./math-font.cjs");
|
|
5
|
+
const require_sfnt_subset = require("./sfnt-subset.cjs");
|
|
6
|
+
const require_math_font_write = require("./math-font-write.cjs");
|
|
7
|
+
const require_embedded_font_write = require("./embedded-font-write.cjs");
|
|
8
|
+
const require_embedded_font = require("./embedded-font.cjs");
|
|
9
|
+
//#region src/write-font-objects.ts
|
|
10
|
+
function emitFontObjects(state) {
|
|
11
|
+
const { objects, formulas, mathFontAlloc, embeddedAllocs, compress } = state;
|
|
12
|
+
const mathFont = mathFontAlloc === void 0 ? void 0 : require_math_font.loadMathFont();
|
|
13
|
+
const usedGlyphs = mathFontAlloc === void 0 || mathFont === void 0 ? void 0 : require_math_content_write.collectUsedGlyphs(formulas, mathFont.font);
|
|
14
|
+
if (mathFontAlloc !== void 0 && mathFont !== void 0 && usedGlyphs !== void 0) {
|
|
15
|
+
const built = require_math_font_write.buildMathFontObjects(mathFont.font, usedGlyphs, {
|
|
16
|
+
cidFontRef: require_objects.pdfRef(mathFontAlloc.cidFontNum, 0),
|
|
17
|
+
descriptorRef: require_objects.pdfRef(mathFontAlloc.descriptorNum, 0),
|
|
18
|
+
fontFileRef: require_objects.pdfRef(mathFontAlloc.fontFileNum, 0),
|
|
19
|
+
toUnicodeRef: require_objects.pdfRef(mathFontAlloc.toUnicodeNum, 0)
|
|
20
|
+
}, compress);
|
|
21
|
+
objects.push({
|
|
22
|
+
num: mathFontAlloc.type0Num,
|
|
23
|
+
value: built.type0
|
|
24
|
+
});
|
|
25
|
+
objects.push({
|
|
26
|
+
num: mathFontAlloc.cidFontNum,
|
|
27
|
+
value: built.cidFont
|
|
28
|
+
});
|
|
29
|
+
objects.push({
|
|
30
|
+
num: mathFontAlloc.descriptorNum,
|
|
31
|
+
value: built.descriptor
|
|
32
|
+
});
|
|
33
|
+
objects.push({
|
|
34
|
+
num: mathFontAlloc.fontFileNum,
|
|
35
|
+
value: built.fontFile
|
|
36
|
+
});
|
|
37
|
+
objects.push({
|
|
38
|
+
num: mathFontAlloc.toUnicodeNum,
|
|
39
|
+
value: built.toUnicode
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
for (const [face, alloc] of embeddedAllocs) {
|
|
43
|
+
const faceUsedGlyphs = require_embedded_font.collectEmbeddedGlyphs(alloc.texts, face);
|
|
44
|
+
const subset = require_sfnt_subset.subsetSfnt(face.font, [...alloc.codePoints], [...faceUsedGlyphs.keys()]);
|
|
45
|
+
if (subset === void 0) throw new Error(`font "${face.postScriptName}" resolved to an embeddable face, but its glyph outlines could not be subsetted — only TrueType-outline ('glyf') fonts can be embedded, so supply a TrueType face for this family or drop it from the registry`);
|
|
46
|
+
const built = require_embedded_font_write.buildEmbeddedFontObjects(face, subset, faceUsedGlyphs, {
|
|
47
|
+
cidFontRef: require_objects.pdfRef(alloc.cidFontNum, 0),
|
|
48
|
+
descriptorRef: require_objects.pdfRef(alloc.descriptorNum, 0),
|
|
49
|
+
fontFileRef: require_objects.pdfRef(alloc.fontFileNum, 0),
|
|
50
|
+
toUnicodeRef: require_objects.pdfRef(alloc.toUnicodeNum, 0)
|
|
51
|
+
}, compress);
|
|
52
|
+
objects.push({
|
|
53
|
+
num: alloc.type0Num,
|
|
54
|
+
value: built.type0
|
|
55
|
+
});
|
|
56
|
+
objects.push({
|
|
57
|
+
num: alloc.cidFontNum,
|
|
58
|
+
value: built.cidFont
|
|
59
|
+
});
|
|
60
|
+
objects.push({
|
|
61
|
+
num: alloc.descriptorNum,
|
|
62
|
+
value: built.descriptor
|
|
63
|
+
});
|
|
64
|
+
objects.push({
|
|
65
|
+
num: alloc.fontFileNum,
|
|
66
|
+
value: built.fontFile
|
|
67
|
+
});
|
|
68
|
+
objects.push({
|
|
69
|
+
num: alloc.toUnicodeNum,
|
|
70
|
+
value: built.toUnicode
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return mathFont === void 0 ? void 0 : { font: mathFont };
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.emitFontObjects = emitFontObjects;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
2
|
+
import { t as EmbeddedFace } from "./embedded-font-CqePfvrl.cjs";
|
|
3
|
+
import { loadMathFont } from "./math-font.cjs";
|
|
4
|
+
import { PositionedFormula } from "document-schema.js";
|
|
5
|
+
//#region src/write-font-objects.d.ts
|
|
6
|
+
interface FontObjectEmitState {
|
|
7
|
+
readonly objects: {
|
|
8
|
+
num: number;
|
|
9
|
+
value: PdfObject;
|
|
10
|
+
}[];
|
|
11
|
+
readonly formulas: readonly PositionedFormula[];
|
|
12
|
+
readonly mathFontAlloc: {
|
|
13
|
+
type0Num: number;
|
|
14
|
+
cidFontNum: number;
|
|
15
|
+
descriptorNum: number;
|
|
16
|
+
fontFileNum: number;
|
|
17
|
+
toUnicodeNum: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
readonly embeddedAllocs: Iterable<[EmbeddedFace, {
|
|
20
|
+
type0Num: number;
|
|
21
|
+
cidFontNum: number;
|
|
22
|
+
descriptorNum: number;
|
|
23
|
+
fontFileNum: number;
|
|
24
|
+
toUnicodeNum: number;
|
|
25
|
+
texts: readonly string[];
|
|
26
|
+
resourceName: string;
|
|
27
|
+
codePoints: ReadonlySet<number>;
|
|
28
|
+
}]>;
|
|
29
|
+
readonly compress: boolean;
|
|
30
|
+
}
|
|
31
|
+
declare function emitFontObjects(state: FontObjectEmitState): {
|
|
32
|
+
font: ReturnType<typeof loadMathFont>;
|
|
33
|
+
} | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { FontObjectEmitState, emitFontObjects };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
2
|
+
import { t as EmbeddedFace } from "./embedded-font-CQZbTTDM.js";
|
|
3
|
+
import { loadMathFont } from "./math-font.js";
|
|
4
|
+
import { PositionedFormula } from "document-schema.js";
|
|
5
|
+
//#region src/write-font-objects.d.ts
|
|
6
|
+
interface FontObjectEmitState {
|
|
7
|
+
readonly objects: {
|
|
8
|
+
num: number;
|
|
9
|
+
value: PdfObject;
|
|
10
|
+
}[];
|
|
11
|
+
readonly formulas: readonly PositionedFormula[];
|
|
12
|
+
readonly mathFontAlloc: {
|
|
13
|
+
type0Num: number;
|
|
14
|
+
cidFontNum: number;
|
|
15
|
+
descriptorNum: number;
|
|
16
|
+
fontFileNum: number;
|
|
17
|
+
toUnicodeNum: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
readonly embeddedAllocs: Iterable<[EmbeddedFace, {
|
|
20
|
+
type0Num: number;
|
|
21
|
+
cidFontNum: number;
|
|
22
|
+
descriptorNum: number;
|
|
23
|
+
fontFileNum: number;
|
|
24
|
+
toUnicodeNum: number;
|
|
25
|
+
texts: readonly string[];
|
|
26
|
+
resourceName: string;
|
|
27
|
+
codePoints: ReadonlySet<number>;
|
|
28
|
+
}]>;
|
|
29
|
+
readonly compress: boolean;
|
|
30
|
+
}
|
|
31
|
+
declare function emitFontObjects(state: FontObjectEmitState): {
|
|
32
|
+
font: ReturnType<typeof loadMathFont>;
|
|
33
|
+
} | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { FontObjectEmitState, emitFontObjects };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { pdfRef } from "./objects.js";
|
|
2
|
+
import { collectUsedGlyphs } from "./math-content-write.js";
|
|
3
|
+
import { loadMathFont } from "./math-font.js";
|
|
4
|
+
import { subsetSfnt } from "./sfnt-subset.js";
|
|
5
|
+
import { buildMathFontObjects } from "./math-font-write.js";
|
|
6
|
+
import { buildEmbeddedFontObjects } from "./embedded-font-write.js";
|
|
7
|
+
import { collectEmbeddedGlyphs } from "./embedded-font.js";
|
|
8
|
+
//#region src/write-font-objects.ts
|
|
9
|
+
function emitFontObjects(state) {
|
|
10
|
+
const { objects, formulas, mathFontAlloc, embeddedAllocs, compress } = state;
|
|
11
|
+
const mathFont = mathFontAlloc === void 0 ? void 0 : loadMathFont();
|
|
12
|
+
const usedGlyphs = mathFontAlloc === void 0 || mathFont === void 0 ? void 0 : collectUsedGlyphs(formulas, mathFont.font);
|
|
13
|
+
if (mathFontAlloc !== void 0 && mathFont !== void 0 && usedGlyphs !== void 0) {
|
|
14
|
+
const built = buildMathFontObjects(mathFont.font, usedGlyphs, {
|
|
15
|
+
cidFontRef: pdfRef(mathFontAlloc.cidFontNum, 0),
|
|
16
|
+
descriptorRef: pdfRef(mathFontAlloc.descriptorNum, 0),
|
|
17
|
+
fontFileRef: pdfRef(mathFontAlloc.fontFileNum, 0),
|
|
18
|
+
toUnicodeRef: pdfRef(mathFontAlloc.toUnicodeNum, 0)
|
|
19
|
+
}, compress);
|
|
20
|
+
objects.push({
|
|
21
|
+
num: mathFontAlloc.type0Num,
|
|
22
|
+
value: built.type0
|
|
23
|
+
});
|
|
24
|
+
objects.push({
|
|
25
|
+
num: mathFontAlloc.cidFontNum,
|
|
26
|
+
value: built.cidFont
|
|
27
|
+
});
|
|
28
|
+
objects.push({
|
|
29
|
+
num: mathFontAlloc.descriptorNum,
|
|
30
|
+
value: built.descriptor
|
|
31
|
+
});
|
|
32
|
+
objects.push({
|
|
33
|
+
num: mathFontAlloc.fontFileNum,
|
|
34
|
+
value: built.fontFile
|
|
35
|
+
});
|
|
36
|
+
objects.push({
|
|
37
|
+
num: mathFontAlloc.toUnicodeNum,
|
|
38
|
+
value: built.toUnicode
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
for (const [face, alloc] of embeddedAllocs) {
|
|
42
|
+
const faceUsedGlyphs = collectEmbeddedGlyphs(alloc.texts, face);
|
|
43
|
+
const subset = subsetSfnt(face.font, [...alloc.codePoints], [...faceUsedGlyphs.keys()]);
|
|
44
|
+
if (subset === void 0) throw new Error(`font "${face.postScriptName}" resolved to an embeddable face, but its glyph outlines could not be subsetted — only TrueType-outline ('glyf') fonts can be embedded, so supply a TrueType face for this family or drop it from the registry`);
|
|
45
|
+
const built = buildEmbeddedFontObjects(face, subset, faceUsedGlyphs, {
|
|
46
|
+
cidFontRef: pdfRef(alloc.cidFontNum, 0),
|
|
47
|
+
descriptorRef: pdfRef(alloc.descriptorNum, 0),
|
|
48
|
+
fontFileRef: pdfRef(alloc.fontFileNum, 0),
|
|
49
|
+
toUnicodeRef: pdfRef(alloc.toUnicodeNum, 0)
|
|
50
|
+
}, compress);
|
|
51
|
+
objects.push({
|
|
52
|
+
num: alloc.type0Num,
|
|
53
|
+
value: built.type0
|
|
54
|
+
});
|
|
55
|
+
objects.push({
|
|
56
|
+
num: alloc.cidFontNum,
|
|
57
|
+
value: built.cidFont
|
|
58
|
+
});
|
|
59
|
+
objects.push({
|
|
60
|
+
num: alloc.descriptorNum,
|
|
61
|
+
value: built.descriptor
|
|
62
|
+
});
|
|
63
|
+
objects.push({
|
|
64
|
+
num: alloc.fontFileNum,
|
|
65
|
+
value: built.fontFile
|
|
66
|
+
});
|
|
67
|
+
objects.push({
|
|
68
|
+
num: alloc.toUnicodeNum,
|
|
69
|
+
value: built.toUnicode
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return mathFont === void 0 ? void 0 : { font: mathFont };
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { emitFontObjects };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
3
|
+
//#region src/write-form.ts
|
|
4
|
+
function noteWidgetAnnot(state, widget, ref) {
|
|
5
|
+
const existing = state.widgetAnnotsByPage.get(widget.pageIndex);
|
|
6
|
+
if (existing === void 0) state.widgetAnnotsByPage.set(widget.pageIndex, [ref]);
|
|
7
|
+
else existing.push(ref);
|
|
8
|
+
}
|
|
9
|
+
function widgetRectArray(widget) {
|
|
10
|
+
return require_objects.pdfArray([
|
|
11
|
+
widget.xPt,
|
|
12
|
+
widget.yPt,
|
|
13
|
+
widget.xPt + widget.widthPt,
|
|
14
|
+
widget.yPt + widget.heightPt
|
|
15
|
+
].map((n) => require_objects.pdfNum(n)));
|
|
16
|
+
}
|
|
17
|
+
function widgetDict(state, widget) {
|
|
18
|
+
return require_objects.pdfDict({
|
|
19
|
+
Subtype: require_objects.pdfName("Widget"),
|
|
20
|
+
Rect: widgetRectArray(widget),
|
|
21
|
+
P: require_objects.pdfRef(state.pageAllocs[widget.pageIndex].pageNum, 0)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const FIELD_TYPE_PDF_NAME = {
|
|
25
|
+
text: "Tx",
|
|
26
|
+
checkbox: "Btn",
|
|
27
|
+
radio: "Btn",
|
|
28
|
+
button: "Btn",
|
|
29
|
+
listbox: "Ch",
|
|
30
|
+
combobox: "Ch",
|
|
31
|
+
signature: "Sig"
|
|
32
|
+
};
|
|
33
|
+
function emitFormObjectsWalk(state, fields, parentName) {
|
|
34
|
+
for (const field of fields) {
|
|
35
|
+
const ownName = parentName === void 0 ? field.name : field.name.startsWith(`${parentName}.`) ? field.name.slice(parentName.length + 1) : field.name;
|
|
36
|
+
const entries = [];
|
|
37
|
+
if (ownName.length > 0) entries.push(["T", require_objects.pdfLiteralString(new TextEncoder().encode(ownName))]);
|
|
38
|
+
if (field.alias !== void 0) entries.push(["TU", require_objects.pdfLiteralString(new TextEncoder().encode(field.alias))]);
|
|
39
|
+
if (field.fieldType === "group") entries.push(["Kids", require_objects.pdfArray(field.children.map((child) => require_objects.pdfRef(state.formNumOf(child), 0)))]);
|
|
40
|
+
else {
|
|
41
|
+
entries.push(["FT", require_objects.pdfName(FIELD_TYPE_PDF_NAME[field.fieldType])]);
|
|
42
|
+
const FLAG_READ_ONLY = 1;
|
|
43
|
+
const FLAG_PUSHBUTTON = 4;
|
|
44
|
+
const FLAG_RADIO = 32768;
|
|
45
|
+
const FLAG_COMBO = 131072;
|
|
46
|
+
let flags = 0;
|
|
47
|
+
if (field.readOnly === true) flags |= FLAG_READ_ONLY;
|
|
48
|
+
if (field.fieldType === "button") flags |= FLAG_PUSHBUTTON;
|
|
49
|
+
if (field.fieldType === "radio") flags |= FLAG_RADIO;
|
|
50
|
+
if (field.fieldType === "combobox") flags |= FLAG_COMBO;
|
|
51
|
+
if (flags !== 0) entries.push(["Ff", require_objects.pdfNum(flags)]);
|
|
52
|
+
if (field.fieldType === "text" || field.fieldType === "listbox" || field.fieldType === "combobox") {
|
|
53
|
+
if (field.value !== void 0) entries.push(["V", require_objects.pdfLiteralString(new TextEncoder().encode(field.value))]);
|
|
54
|
+
} else if (field.fieldType === "checkbox" || field.fieldType === "radio") entries.push(["V", require_objects.pdfName(field.value ?? (field.checked === true ? "Yes" : "Off"))]);
|
|
55
|
+
if (field.options !== void 0) entries.push(["Opt", require_objects.pdfArray(field.options.map((option) => require_objects.pdfLiteralString(new TextEncoder().encode(option))))]);
|
|
56
|
+
const firstWidget = field.widgets[0];
|
|
57
|
+
if (field.widgets.length === 1 && firstWidget !== void 0) {
|
|
58
|
+
entries.push(["Subtype", require_objects.pdfName("Widget")]);
|
|
59
|
+
entries.push(["Rect", widgetRectArray(firstWidget)]);
|
|
60
|
+
entries.push(["P", require_objects.pdfRef(state.pageAllocs[firstWidget.pageIndex].pageNum, 0)]);
|
|
61
|
+
noteWidgetAnnot(state, firstWidget, require_objects.pdfRef(state.formNumOf(field), 0));
|
|
62
|
+
} else if (state.formExtraWidgetNums.has(field)) {
|
|
63
|
+
const extraNums = state.formExtraWidgetNums.get(field) ?? [];
|
|
64
|
+
entries.push(["Kids", require_objects.pdfArray(extraNums.map((num) => require_objects.pdfRef(num, 0)))]);
|
|
65
|
+
for (const [index, num] of extraNums.entries()) {
|
|
66
|
+
const widget = field.widgets[index];
|
|
67
|
+
if (widget !== void 0) noteWidgetAnnot(state, widget, require_objects.pdfRef(num, 0));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
state.objects.push({
|
|
72
|
+
num: state.formNumOf(field),
|
|
73
|
+
value: require_objects.pdfDict(Object.fromEntries(entries))
|
|
74
|
+
});
|
|
75
|
+
const extraNums = state.formExtraWidgetNums.get(field) ?? [];
|
|
76
|
+
for (const [index, num] of extraNums.entries()) {
|
|
77
|
+
const widget = field.widgets[index];
|
|
78
|
+
if (widget !== void 0) state.objects.push({
|
|
79
|
+
num,
|
|
80
|
+
value: widgetDict(state, widget)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
emitFormObjectsWalk(state, field.children, field.name);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function emitFormObjects(state, fields) {
|
|
87
|
+
emitFormObjectsWalk(state, fields, void 0);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.emitFormObjects = emitFormObjects;
|
|
91
|
+
exports.emitFormObjectsWalk = emitFormObjectsWalk;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
2
|
+
import { LayoutFormField } from "./layout.cjs";
|
|
3
|
+
//#region src/write-form.d.ts
|
|
4
|
+
interface FormEmitState {
|
|
5
|
+
readonly objects: {
|
|
6
|
+
num: number;
|
|
7
|
+
value: PdfObject;
|
|
8
|
+
}[];
|
|
9
|
+
readonly widgetAnnotsByPage: Map<number, PdfObject[]>;
|
|
10
|
+
readonly pageAllocs: readonly {
|
|
11
|
+
pageNum: number;
|
|
12
|
+
}[];
|
|
13
|
+
readonly formNumOf: (field: LayoutFormField) => number;
|
|
14
|
+
readonly formExtraWidgetNums: ReadonlyMap<LayoutFormField, number[]>;
|
|
15
|
+
}
|
|
16
|
+
declare function emitFormObjectsWalk(state: FormEmitState, fields: readonly LayoutFormField[], parentName: string | undefined): void;
|
|
17
|
+
declare function emitFormObjects(state: FormEmitState, fields: readonly LayoutFormField[]): void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { FormEmitState, emitFormObjects, emitFormObjectsWalk };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
2
|
+
import { LayoutFormField } from "./layout.js";
|
|
3
|
+
//#region src/write-form.d.ts
|
|
4
|
+
interface FormEmitState {
|
|
5
|
+
readonly objects: {
|
|
6
|
+
num: number;
|
|
7
|
+
value: PdfObject;
|
|
8
|
+
}[];
|
|
9
|
+
readonly widgetAnnotsByPage: Map<number, PdfObject[]>;
|
|
10
|
+
readonly pageAllocs: readonly {
|
|
11
|
+
pageNum: number;
|
|
12
|
+
}[];
|
|
13
|
+
readonly formNumOf: (field: LayoutFormField) => number;
|
|
14
|
+
readonly formExtraWidgetNums: ReadonlyMap<LayoutFormField, number[]>;
|
|
15
|
+
}
|
|
16
|
+
declare function emitFormObjectsWalk(state: FormEmitState, fields: readonly LayoutFormField[], parentName: string | undefined): void;
|
|
17
|
+
declare function emitFormObjects(state: FormEmitState, fields: readonly LayoutFormField[]): void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { FormEmitState, emitFormObjects, emitFormObjectsWalk };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { pdfArray, pdfDict, pdfLiteralString, pdfName, pdfNum, pdfRef } from "./objects.js";
|
|
2
|
+
//#region src/write-form.ts
|
|
3
|
+
function noteWidgetAnnot(state, widget, ref) {
|
|
4
|
+
const existing = state.widgetAnnotsByPage.get(widget.pageIndex);
|
|
5
|
+
if (existing === void 0) state.widgetAnnotsByPage.set(widget.pageIndex, [ref]);
|
|
6
|
+
else existing.push(ref);
|
|
7
|
+
}
|
|
8
|
+
function widgetRectArray(widget) {
|
|
9
|
+
return pdfArray([
|
|
10
|
+
widget.xPt,
|
|
11
|
+
widget.yPt,
|
|
12
|
+
widget.xPt + widget.widthPt,
|
|
13
|
+
widget.yPt + widget.heightPt
|
|
14
|
+
].map((n) => pdfNum(n)));
|
|
15
|
+
}
|
|
16
|
+
function widgetDict(state, widget) {
|
|
17
|
+
return pdfDict({
|
|
18
|
+
Subtype: pdfName("Widget"),
|
|
19
|
+
Rect: widgetRectArray(widget),
|
|
20
|
+
P: pdfRef(state.pageAllocs[widget.pageIndex].pageNum, 0)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const FIELD_TYPE_PDF_NAME = {
|
|
24
|
+
text: "Tx",
|
|
25
|
+
checkbox: "Btn",
|
|
26
|
+
radio: "Btn",
|
|
27
|
+
button: "Btn",
|
|
28
|
+
listbox: "Ch",
|
|
29
|
+
combobox: "Ch",
|
|
30
|
+
signature: "Sig"
|
|
31
|
+
};
|
|
32
|
+
function emitFormObjectsWalk(state, fields, parentName) {
|
|
33
|
+
for (const field of fields) {
|
|
34
|
+
const ownName = parentName === void 0 ? field.name : field.name.startsWith(`${parentName}.`) ? field.name.slice(parentName.length + 1) : field.name;
|
|
35
|
+
const entries = [];
|
|
36
|
+
if (ownName.length > 0) entries.push(["T", pdfLiteralString(new TextEncoder().encode(ownName))]);
|
|
37
|
+
if (field.alias !== void 0) entries.push(["TU", pdfLiteralString(new TextEncoder().encode(field.alias))]);
|
|
38
|
+
if (field.fieldType === "group") entries.push(["Kids", pdfArray(field.children.map((child) => pdfRef(state.formNumOf(child), 0)))]);
|
|
39
|
+
else {
|
|
40
|
+
entries.push(["FT", pdfName(FIELD_TYPE_PDF_NAME[field.fieldType])]);
|
|
41
|
+
const FLAG_READ_ONLY = 1;
|
|
42
|
+
const FLAG_PUSHBUTTON = 4;
|
|
43
|
+
const FLAG_RADIO = 32768;
|
|
44
|
+
const FLAG_COMBO = 131072;
|
|
45
|
+
let flags = 0;
|
|
46
|
+
if (field.readOnly === true) flags |= FLAG_READ_ONLY;
|
|
47
|
+
if (field.fieldType === "button") flags |= FLAG_PUSHBUTTON;
|
|
48
|
+
if (field.fieldType === "radio") flags |= FLAG_RADIO;
|
|
49
|
+
if (field.fieldType === "combobox") flags |= FLAG_COMBO;
|
|
50
|
+
if (flags !== 0) entries.push(["Ff", pdfNum(flags)]);
|
|
51
|
+
if (field.fieldType === "text" || field.fieldType === "listbox" || field.fieldType === "combobox") {
|
|
52
|
+
if (field.value !== void 0) entries.push(["V", pdfLiteralString(new TextEncoder().encode(field.value))]);
|
|
53
|
+
} else if (field.fieldType === "checkbox" || field.fieldType === "radio") entries.push(["V", pdfName(field.value ?? (field.checked === true ? "Yes" : "Off"))]);
|
|
54
|
+
if (field.options !== void 0) entries.push(["Opt", pdfArray(field.options.map((option) => pdfLiteralString(new TextEncoder().encode(option))))]);
|
|
55
|
+
const firstWidget = field.widgets[0];
|
|
56
|
+
if (field.widgets.length === 1 && firstWidget !== void 0) {
|
|
57
|
+
entries.push(["Subtype", pdfName("Widget")]);
|
|
58
|
+
entries.push(["Rect", widgetRectArray(firstWidget)]);
|
|
59
|
+
entries.push(["P", pdfRef(state.pageAllocs[firstWidget.pageIndex].pageNum, 0)]);
|
|
60
|
+
noteWidgetAnnot(state, firstWidget, pdfRef(state.formNumOf(field), 0));
|
|
61
|
+
} else if (state.formExtraWidgetNums.has(field)) {
|
|
62
|
+
const extraNums = state.formExtraWidgetNums.get(field) ?? [];
|
|
63
|
+
entries.push(["Kids", pdfArray(extraNums.map((num) => pdfRef(num, 0)))]);
|
|
64
|
+
for (const [index, num] of extraNums.entries()) {
|
|
65
|
+
const widget = field.widgets[index];
|
|
66
|
+
if (widget !== void 0) noteWidgetAnnot(state, widget, pdfRef(num, 0));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
state.objects.push({
|
|
71
|
+
num: state.formNumOf(field),
|
|
72
|
+
value: pdfDict(Object.fromEntries(entries))
|
|
73
|
+
});
|
|
74
|
+
const extraNums = state.formExtraWidgetNums.get(field) ?? [];
|
|
75
|
+
for (const [index, num] of extraNums.entries()) {
|
|
76
|
+
const widget = field.widgets[index];
|
|
77
|
+
if (widget !== void 0) state.objects.push({
|
|
78
|
+
num,
|
|
79
|
+
value: widgetDict(state, widget)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
emitFormObjectsWalk(state, field.children, field.name);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function emitFormObjects(state, fields) {
|
|
86
|
+
emitFormObjectsWalk(state, fields, void 0);
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { emitFormObjects, emitFormObjectsWalk };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
3
|
+
const require_bytes_flate = require("./bytes/flate.cjs");
|
|
4
|
+
const require_image_ccitt_encode = require("./image/ccitt-encode.cjs");
|
|
5
|
+
const require_image_png_decode = require("./image/png-decode.cjs");
|
|
6
|
+
const require_image_jpeg_info = require("./image/jpeg-info.cjs");
|
|
7
|
+
let byte_codec = require("byte-codec");
|
|
8
|
+
//#region src/write-images.ts
|
|
9
|
+
const BITS_PER_BYTE = 8;
|
|
10
|
+
const BYTE_SHIFT = Math.log2(8);
|
|
11
|
+
const BYTE_MASK = 255;
|
|
12
|
+
const PACKED_BIT_MSB_MASK = 128;
|
|
13
|
+
const BIT_INDEX_MASK = 7;
|
|
14
|
+
const JPEG_COMPONENTS_CMYK = 4;
|
|
15
|
+
function prepareJpegImage(bytes) {
|
|
16
|
+
const info = require_image_jpeg_info.readJpegInfo(bytes);
|
|
17
|
+
const colorSpace = info.components === 1 ? "DeviceGray" : info.components === JPEG_COMPONENTS_CMYK ? "DeviceCMYK" : "DeviceRGB";
|
|
18
|
+
const entries = /* @__PURE__ */ new Map([
|
|
19
|
+
["Type", require_objects.pdfName("XObject")],
|
|
20
|
+
["Subtype", require_objects.pdfName("Image")],
|
|
21
|
+
["Width", require_objects.pdfNum(info.width)],
|
|
22
|
+
["Height", require_objects.pdfNum(info.height)],
|
|
23
|
+
["ColorSpace", require_objects.pdfName(colorSpace)],
|
|
24
|
+
["BitsPerComponent", require_objects.pdfNum(info.precision)],
|
|
25
|
+
["Filter", require_objects.pdfName("DCTDecode")]
|
|
26
|
+
]);
|
|
27
|
+
if (info.components === JPEG_COMPONENTS_CMYK && (info.adobeTransform === 2 || info.adobeTransform === void 0)) entries.set("Decode", require_objects.pdfArray([
|
|
28
|
+
1,
|
|
29
|
+
0,
|
|
30
|
+
1,
|
|
31
|
+
0,
|
|
32
|
+
1,
|
|
33
|
+
0,
|
|
34
|
+
1,
|
|
35
|
+
0
|
|
36
|
+
].map((n) => require_objects.pdfNum(n))));
|
|
37
|
+
return {
|
|
38
|
+
dict: require_objects.pdfDict(entries),
|
|
39
|
+
raw: bytes
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function pngImageDict(width, height, colorSpace, compress) {
|
|
43
|
+
const entries = /* @__PURE__ */ new Map([
|
|
44
|
+
["Type", require_objects.pdfName("XObject")],
|
|
45
|
+
["Subtype", require_objects.pdfName("Image")],
|
|
46
|
+
["Width", require_objects.pdfNum(width)],
|
|
47
|
+
["Height", require_objects.pdfNum(height)],
|
|
48
|
+
["ColorSpace", require_objects.pdfName(colorSpace)],
|
|
49
|
+
["BitsPerComponent", require_objects.pdfNum(8)]
|
|
50
|
+
]);
|
|
51
|
+
if (compress) entries.set("Filter", require_objects.pdfName("FlateDecode"));
|
|
52
|
+
return require_objects.pdfDict(entries);
|
|
53
|
+
}
|
|
54
|
+
function packBilevel(raw) {
|
|
55
|
+
const rowBytes = raw.width + BIT_INDEX_MASK >> BYTE_SHIFT;
|
|
56
|
+
const packed = new Uint8Array(rowBytes * raw.height);
|
|
57
|
+
const view = new DataView(packed.buffer);
|
|
58
|
+
for (let index = 0; index < raw.data.length; index++) {
|
|
59
|
+
const sample = raw.data[index];
|
|
60
|
+
if (sample !== 0 && sample !== 255) return;
|
|
61
|
+
if (sample === 255) {
|
|
62
|
+
const x = index % raw.width;
|
|
63
|
+
const byteIndex = Math.floor(index / raw.width) * rowBytes + (x >> BYTE_SHIFT);
|
|
64
|
+
view.setUint8(byteIndex, view.getUint8(byteIndex) | PACKED_BIT_MSB_MASK >> (x & BIT_INDEX_MASK));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return packed;
|
|
68
|
+
}
|
|
69
|
+
function preparePngImage(bytes, compress) {
|
|
70
|
+
const raw = require_image_png_decode.decodePng(bytes);
|
|
71
|
+
const colorSpace = raw.channels === 1 ? "DeviceGray" : "DeviceRGB";
|
|
72
|
+
if (compress && raw.channels === 1 && raw.alpha === void 0) {
|
|
73
|
+
const bilevel = packBilevel(raw);
|
|
74
|
+
if (bilevel !== void 0) {
|
|
75
|
+
const flate = require_bytes_flate.deflate(raw.data);
|
|
76
|
+
const g4 = require_image_ccitt_encode.encodeCcittFax(bilevel, {
|
|
77
|
+
columns: raw.width,
|
|
78
|
+
rows: raw.height,
|
|
79
|
+
maxBytes: flate.length
|
|
80
|
+
});
|
|
81
|
+
if (g4 !== void 0) return {
|
|
82
|
+
dict: require_objects.pdfDict(/* @__PURE__ */ new Map([
|
|
83
|
+
["Type", require_objects.pdfName("XObject")],
|
|
84
|
+
["Subtype", require_objects.pdfName("Image")],
|
|
85
|
+
["Width", require_objects.pdfNum(raw.width)],
|
|
86
|
+
["Height", require_objects.pdfNum(raw.height)],
|
|
87
|
+
["ColorSpace", require_objects.pdfName("DeviceGray")],
|
|
88
|
+
["BitsPerComponent", require_objects.pdfNum(1)],
|
|
89
|
+
["Filter", require_objects.pdfName("CCITTFaxDecode")],
|
|
90
|
+
["DecodeParms", require_objects.pdfDict(/* @__PURE__ */ new Map([
|
|
91
|
+
["K", require_objects.pdfNum(-1)],
|
|
92
|
+
["Columns", require_objects.pdfNum(raw.width)],
|
|
93
|
+
["Rows", require_objects.pdfNum(raw.height)],
|
|
94
|
+
["BlackIs1", require_objects.pdfBool(false)]
|
|
95
|
+
]))]
|
|
96
|
+
])),
|
|
97
|
+
raw: g4,
|
|
98
|
+
alpha: void 0
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
dict: pngImageDict(raw.width, raw.height, colorSpace, true),
|
|
102
|
+
raw: flate,
|
|
103
|
+
alpha: void 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
dict: pngImageDict(raw.width, raw.height, colorSpace, compress),
|
|
109
|
+
raw: compress ? require_bytes_flate.deflate(raw.data) : raw.data,
|
|
110
|
+
alpha: raw.alpha === void 0 ? void 0 : {
|
|
111
|
+
dict: pngImageDict(raw.width, raw.height, "DeviceGray", compress),
|
|
112
|
+
raw: compress ? require_bytes_flate.deflate(raw.alpha) : raw.alpha
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function preparePassthroughImage(asset, original, compress) {
|
|
117
|
+
const png = preparePngImage((0, byte_codec.base64ToBytes)(asset.base64), compress);
|
|
118
|
+
const entries = /* @__PURE__ */ new Map([
|
|
119
|
+
["Type", require_objects.pdfName("XObject")],
|
|
120
|
+
["Subtype", require_objects.pdfName("Image")],
|
|
121
|
+
["Width", require_objects.pdfNum(asset.widthPx)],
|
|
122
|
+
["Height", require_objects.pdfNum(asset.heightPx)],
|
|
123
|
+
["Filter", require_objects.pdfName(original.filter === "jbig2" ? "JBIG2Decode" : "JPXDecode")]
|
|
124
|
+
]);
|
|
125
|
+
if (original.filter === "jbig2") {
|
|
126
|
+
entries.set("ColorSpace", require_objects.pdfName("DeviceGray"));
|
|
127
|
+
entries.set("BitsPerComponent", require_objects.pdfNum(1));
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
dict: require_objects.pdfDict(entries),
|
|
131
|
+
raw: (0, byte_codec.base64ToBytes)(original.base64),
|
|
132
|
+
alpha: png.alpha
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function prepareImage(asset, compress) {
|
|
136
|
+
if (asset.original !== void 0) return preparePassthroughImage(asset, asset.original, compress);
|
|
137
|
+
const bytes = (0, byte_codec.base64ToBytes)(asset.base64);
|
|
138
|
+
return asset.format === "jpeg" ? prepareJpegImage(bytes) : preparePngImage(bytes, compress);
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.BITS_PER_BYTE = BITS_PER_BYTE;
|
|
142
|
+
exports.BYTE_MASK = BYTE_MASK;
|
|
143
|
+
exports.packBilevel = packBilevel;
|
|
144
|
+
exports.pngImageDict = pngImageDict;
|
|
145
|
+
exports.prepareImage = prepareImage;
|
|
146
|
+
exports.prepareJpegImage = prepareJpegImage;
|
|
147
|
+
exports.preparePassthroughImage = preparePassthroughImage;
|
|
148
|
+
exports.preparePngImage = preparePngImage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { n as PdfDict } from "./objects-e2RS3-yT.cjs";
|
|
2
|
+
import { LayoutImageAsset } from "./layout.cjs";
|
|
3
|
+
//#region src/write-images.d.ts
|
|
4
|
+
declare const BITS_PER_BYTE = 8;
|
|
5
|
+
declare const BYTE_MASK: number;
|
|
6
|
+
interface PreparedImage {
|
|
7
|
+
readonly dict: PdfDict;
|
|
8
|
+
readonly raw: Uint8Array<ArrayBuffer>;
|
|
9
|
+
readonly alpha?: {
|
|
10
|
+
readonly dict: PdfDict;
|
|
11
|
+
readonly raw: Uint8Array<ArrayBuffer>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare function prepareJpegImage(bytes: Uint8Array<ArrayBuffer>): PreparedImage;
|
|
15
|
+
declare function pngImageDict(width: number, height: number, colorSpace: "DeviceGray" | "DeviceRGB", compress: boolean): PdfDict;
|
|
16
|
+
declare function packBilevel(raw: {
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
readonly data: Uint8Array;
|
|
20
|
+
}): Uint8Array | undefined;
|
|
21
|
+
declare function preparePngImage(bytes: Uint8Array<ArrayBuffer>, compress: boolean): PreparedImage;
|
|
22
|
+
declare function preparePassthroughImage(asset: LayoutImageAsset, original: Readonly<NonNullable<LayoutImageAsset["original"]>>, compress: boolean): PreparedImage;
|
|
23
|
+
declare function prepareImage(asset: LayoutImageAsset, compress: boolean): PreparedImage;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BITS_PER_BYTE, BYTE_MASK, PreparedImage, packBilevel, pngImageDict, prepareImage, prepareJpegImage, preparePassthroughImage, preparePngImage };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { n as PdfDict } from "./objects-e2RS3-yT.js";
|
|
2
|
+
import { LayoutImageAsset } from "./layout.js";
|
|
3
|
+
//#region src/write-images.d.ts
|
|
4
|
+
declare const BITS_PER_BYTE = 8;
|
|
5
|
+
declare const BYTE_MASK: number;
|
|
6
|
+
interface PreparedImage {
|
|
7
|
+
readonly dict: PdfDict;
|
|
8
|
+
readonly raw: Uint8Array<ArrayBuffer>;
|
|
9
|
+
readonly alpha?: {
|
|
10
|
+
readonly dict: PdfDict;
|
|
11
|
+
readonly raw: Uint8Array<ArrayBuffer>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare function prepareJpegImage(bytes: Uint8Array<ArrayBuffer>): PreparedImage;
|
|
15
|
+
declare function pngImageDict(width: number, height: number, colorSpace: "DeviceGray" | "DeviceRGB", compress: boolean): PdfDict;
|
|
16
|
+
declare function packBilevel(raw: {
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
readonly data: Uint8Array;
|
|
20
|
+
}): Uint8Array | undefined;
|
|
21
|
+
declare function preparePngImage(bytes: Uint8Array<ArrayBuffer>, compress: boolean): PreparedImage;
|
|
22
|
+
declare function preparePassthroughImage(asset: LayoutImageAsset, original: Readonly<NonNullable<LayoutImageAsset["original"]>>, compress: boolean): PreparedImage;
|
|
23
|
+
declare function prepareImage(asset: LayoutImageAsset, compress: boolean): PreparedImage;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BITS_PER_BYTE, BYTE_MASK, PreparedImage, packBilevel, pngImageDict, prepareImage, prepareJpegImage, preparePassthroughImage, preparePngImage };
|