pdf-parser.js 5.2.29 → 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 +2 -2
- 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,36 @@
|
|
|
1
|
+
import { pdfArray, pdfDict, pdfName, pdfNull, pdfNum, pdfRef } from "./objects.js";
|
|
2
|
+
//#region src/write-pages.ts
|
|
3
|
+
function emitStructParentTree(state) {
|
|
4
|
+
const { objects, structElementNumById, markedStructureByPage, structureRoots, structRootNum, structParentTreeNum } = state;
|
|
5
|
+
if (structRootNum !== void 0 && structParentTreeNum !== void 0) {
|
|
6
|
+
const nums = [];
|
|
7
|
+
for (const [pageIndex, marks] of markedStructureByPage) {
|
|
8
|
+
const maxMcid = Math.max(...marks.map((mark) => mark.mcid));
|
|
9
|
+
const byMcid = Array.from({ length: maxMcid + 1 }, (_, mcid) => {
|
|
10
|
+
const mark = marks.find((candidate) => candidate.mcid === mcid);
|
|
11
|
+
const elementNum = mark === void 0 ? void 0 : structElementNumById.get(mark.structureId);
|
|
12
|
+
return elementNum === void 0 ? pdfNull() : pdfRef(elementNum, 0);
|
|
13
|
+
});
|
|
14
|
+
nums.push(pdfNum(pageIndex), pdfArray(byMcid));
|
|
15
|
+
}
|
|
16
|
+
objects.push({
|
|
17
|
+
num: structParentTreeNum,
|
|
18
|
+
value: pdfDict({ Nums: pdfArray(nums) })
|
|
19
|
+
});
|
|
20
|
+
const rootEntries = [
|
|
21
|
+
["Type", pdfName("StructTreeRoot")],
|
|
22
|
+
["K", pdfArray(structureRoots.map((element) => {
|
|
23
|
+
const num = structElementNumById.get(element.id);
|
|
24
|
+
if (num === void 0) throw new Error(`structure element "${element.id}" was not allocated — this is a writePdf internal invariant violation`);
|
|
25
|
+
return pdfRef(num, 0);
|
|
26
|
+
}))],
|
|
27
|
+
["ParentTree", pdfRef(structParentTreeNum, 0)]
|
|
28
|
+
];
|
|
29
|
+
objects.push({
|
|
30
|
+
num: structRootNum,
|
|
31
|
+
value: pdfDict(Object.fromEntries(rootEntries))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { emitStructParentTree };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
3
|
+
require("./write-images.cjs");
|
|
4
|
+
//#region src/write-strings.ts
|
|
5
|
+
function textToPdfString(text) {
|
|
6
|
+
const bytes = new Uint8Array(2 + text.length * 2);
|
|
7
|
+
bytes[0] = 254;
|
|
8
|
+
bytes[1] = 255;
|
|
9
|
+
let offset = 2;
|
|
10
|
+
for (const unit of text.split("")) {
|
|
11
|
+
const code = unit.charCodeAt(0);
|
|
12
|
+
bytes[offset] = code >> 8 & 255;
|
|
13
|
+
bytes[offset + 1] = code & 255;
|
|
14
|
+
offset += 2;
|
|
15
|
+
}
|
|
16
|
+
return require_objects.pdfHexString(bytes);
|
|
17
|
+
}
|
|
18
|
+
function pad2(n) {
|
|
19
|
+
return n.toString().padStart(2, "0");
|
|
20
|
+
}
|
|
21
|
+
function formatPdfDate(iso) {
|
|
22
|
+
const date = new Date(iso);
|
|
23
|
+
return `D:${date.getUTCFullYear()}${pad2(date.getUTCMonth() + 1)}${pad2(date.getUTCDate())}${pad2(date.getUTCHours())}${pad2(date.getUTCMinutes())}${pad2(date.getUTCSeconds())}Z`;
|
|
24
|
+
}
|
|
25
|
+
function buildInfoDict(doc) {
|
|
26
|
+
const entries = /* @__PURE__ */ new Map();
|
|
27
|
+
entries.set("Producer", textToPdfString("documents.js"));
|
|
28
|
+
if (doc.metadata.title !== void 0) entries.set("Title", textToPdfString(doc.metadata.title));
|
|
29
|
+
if (doc.metadata.author !== void 0) entries.set("Author", textToPdfString(doc.metadata.author));
|
|
30
|
+
if (doc.metadata.subject !== void 0) entries.set("Subject", textToPdfString(doc.metadata.subject));
|
|
31
|
+
if (doc.metadata.keywords !== void 0) entries.set("Keywords", textToPdfString(doc.metadata.keywords.join(", ")));
|
|
32
|
+
if (doc.metadata.creator !== void 0) entries.set("Creator", textToPdfString(doc.metadata.creator));
|
|
33
|
+
if (doc.metadata.createdIso !== void 0) entries.set("CreationDate", textToPdfString(formatPdfDate(doc.metadata.createdIso)));
|
|
34
|
+
if (doc.metadata.modifiedIso !== void 0) entries.set("ModDate", textToPdfString(formatPdfDate(doc.metadata.modifiedIso)));
|
|
35
|
+
return require_objects.pdfDict(entries);
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.buildInfoDict = buildInfoDict;
|
|
39
|
+
exports.formatPdfDate = formatPdfDate;
|
|
40
|
+
exports.pad2 = pad2;
|
|
41
|
+
exports.textToPdfString = textToPdfString;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
2
|
+
import { LayoutDocument } from "./layout.cjs";
|
|
3
|
+
//#region src/write-strings.d.ts
|
|
4
|
+
declare function textToPdfString(text: string): PdfObject;
|
|
5
|
+
declare function pad2(n: number): string;
|
|
6
|
+
declare function formatPdfDate(iso: string): string;
|
|
7
|
+
declare function buildInfoDict(doc: LayoutDocument): PdfDict;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { buildInfoDict, formatPdfDate, pad2, textToPdfString };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
2
|
+
import { LayoutDocument } from "./layout.js";
|
|
3
|
+
//#region src/write-strings.d.ts
|
|
4
|
+
declare function textToPdfString(text: string): PdfObject;
|
|
5
|
+
declare function pad2(n: number): string;
|
|
6
|
+
declare function formatPdfDate(iso: string): string;
|
|
7
|
+
declare function buildInfoDict(doc: LayoutDocument): PdfDict;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { buildInfoDict, formatPdfDate, pad2, textToPdfString };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { pdfDict, pdfHexString } from "./objects.js";
|
|
2
|
+
import "./write-images.js";
|
|
3
|
+
//#region src/write-strings.ts
|
|
4
|
+
function textToPdfString(text) {
|
|
5
|
+
const bytes = new Uint8Array(2 + text.length * 2);
|
|
6
|
+
bytes[0] = 254;
|
|
7
|
+
bytes[1] = 255;
|
|
8
|
+
let offset = 2;
|
|
9
|
+
for (const unit of text.split("")) {
|
|
10
|
+
const code = unit.charCodeAt(0);
|
|
11
|
+
bytes[offset] = code >> 8 & 255;
|
|
12
|
+
bytes[offset + 1] = code & 255;
|
|
13
|
+
offset += 2;
|
|
14
|
+
}
|
|
15
|
+
return pdfHexString(bytes);
|
|
16
|
+
}
|
|
17
|
+
function pad2(n) {
|
|
18
|
+
return n.toString().padStart(2, "0");
|
|
19
|
+
}
|
|
20
|
+
function formatPdfDate(iso) {
|
|
21
|
+
const date = new Date(iso);
|
|
22
|
+
return `D:${date.getUTCFullYear()}${pad2(date.getUTCMonth() + 1)}${pad2(date.getUTCDate())}${pad2(date.getUTCHours())}${pad2(date.getUTCMinutes())}${pad2(date.getUTCSeconds())}Z`;
|
|
23
|
+
}
|
|
24
|
+
function buildInfoDict(doc) {
|
|
25
|
+
const entries = /* @__PURE__ */ new Map();
|
|
26
|
+
entries.set("Producer", textToPdfString("documents.js"));
|
|
27
|
+
if (doc.metadata.title !== void 0) entries.set("Title", textToPdfString(doc.metadata.title));
|
|
28
|
+
if (doc.metadata.author !== void 0) entries.set("Author", textToPdfString(doc.metadata.author));
|
|
29
|
+
if (doc.metadata.subject !== void 0) entries.set("Subject", textToPdfString(doc.metadata.subject));
|
|
30
|
+
if (doc.metadata.keywords !== void 0) entries.set("Keywords", textToPdfString(doc.metadata.keywords.join(", ")));
|
|
31
|
+
if (doc.metadata.creator !== void 0) entries.set("Creator", textToPdfString(doc.metadata.creator));
|
|
32
|
+
if (doc.metadata.createdIso !== void 0) entries.set("CreationDate", textToPdfString(formatPdfDate(doc.metadata.createdIso)));
|
|
33
|
+
if (doc.metadata.modifiedIso !== void 0) entries.set("ModDate", textToPdfString(formatPdfDate(doc.metadata.modifiedIso)));
|
|
34
|
+
return pdfDict(entries);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { buildInfoDict, formatPdfDate, pad2, textToPdfString };
|