pdf-parser.js 3.0.8 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -54
- package/dist/{afm-widths-Dxucrg7D.js → afm-widths-BTu0IDp2.cjs} +1517 -4
- package/dist/{afm-widths-DyDq56Ph.d.cts → afm-widths-CneRyu5l.d.cts} +1 -1
- package/dist/{afm-widths-DyDq56Ph.d.ts → afm-widths-CneRyu5l.d.ts} +1 -1
- package/dist/{afm-widths-BoeTOK2r.cjs → afm-widths-De_QMWgC.js} +1416 -51
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.d.cts +1 -1
- package/dist/afm-widths.d.ts +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.cjs +104 -0
- package/dist/annotations.d.cts +9 -0
- package/dist/annotations.d.ts +9 -0
- package/dist/annotations.js +103 -0
- package/dist/attachments.cjs +65 -0
- package/dist/attachments.d.cts +8 -0
- package/dist/attachments.d.ts +8 -0
- package/dist/attachments.js +64 -0
- package/dist/builtin-encoding.cjs +221 -0
- package/dist/builtin-encoding.d.cts +8 -0
- package/dist/builtin-encoding.d.ts +8 -0
- package/dist/builtin-encoding.js +220 -0
- package/dist/bytes/flate.cjs +1 -1
- package/dist/bytes/flate.js +1 -1
- package/dist/cff.cjs +14 -0
- package/dist/cff.d.cts +4 -1
- package/dist/cff.d.ts +4 -1
- package/dist/cff.js +12 -1
- package/dist/cmap-table.cjs +76 -13
- package/dist/cmap-table.d.cts +9 -1
- package/dist/cmap-table.d.ts +9 -1
- package/dist/cmap-table.js +77 -15
- package/dist/codec.cjs +1 -1
- package/dist/codec.d.cts +134 -0
- package/dist/codec.d.ts +134 -0
- package/dist/codec.js +1 -1
- package/dist/content-read.cjs +1 -1
- package/dist/content-read.d.cts +3 -3
- package/dist/content-read.d.ts +3 -3
- package/dist/content-read.js +1 -1
- package/dist/content-write.cjs +32 -10
- package/dist/content-write.d.cts +12 -5
- package/dist/content-write.d.ts +12 -5
- package/dist/content-write.js +32 -10
- package/dist/crypto/random.cjs +9 -0
- package/dist/crypto/random.d.cts +4 -0
- package/dist/crypto/random.d.ts +4 -0
- package/dist/crypto/random.js +8 -0
- package/dist/diagnostics.d.cts +1 -1
- package/dist/diagnostics.d.ts +1 -1
- package/dist/document.cjs +12 -3
- package/dist/document.d.cts +3 -1
- package/dist/document.d.ts +3 -1
- package/dist/document.js +12 -3
- package/dist/{embedded-font-fREdbxnr.d.ts → embedded-font-B4p9a3O3.d.ts} +3 -1
- package/dist/{embedded-font-BU6Jgcof.d.cts → embedded-font-oc65VGlr.d.cts} +3 -1
- package/dist/embedded-font-write.cjs +1 -1
- package/dist/embedded-font-write.d.cts +3 -3
- package/dist/embedded-font-write.d.ts +3 -3
- package/dist/embedded-font-write.js +1 -1
- package/dist/embedded-font.cjs +46 -15
- package/dist/embedded-font.d.cts +1 -1
- package/dist/embedded-font.d.ts +1 -1
- package/dist/embedded-font.js +46 -15
- package/dist/encoding.cjs +10 -1
- package/dist/encoding.d.cts +10 -1
- package/dist/encoding.d.ts +10 -1
- package/dist/encoding.js +2 -2
- package/dist/encrypt-write.cjs +234 -0
- package/dist/encrypt-write.d.cts +31 -0
- package/dist/encrypt-write.d.ts +31 -0
- package/dist/encrypt-write.js +231 -0
- package/dist/encrypt.cjs +51 -21
- package/dist/encrypt.d.cts +19 -3
- package/dist/encrypt.d.ts +19 -3
- package/dist/encrypt.js +36 -22
- package/dist/filters.cjs +18 -14
- package/dist/filters.d.cts +1 -1
- package/dist/filters.d.ts +1 -1
- package/dist/filters.js +18 -14
- package/dist/font-read.cjs +68 -13
- package/dist/font-read.d.cts +1 -1
- package/dist/font-read.d.ts +1 -1
- package/dist/font-read.js +69 -14
- package/dist/font-registry.cjs +1 -1
- package/dist/font-registry.d.cts +4 -4
- package/dist/font-registry.d.ts +4 -4
- package/dist/font-registry.js +1 -1
- package/dist/font-substitutes.d.cts +1 -1
- package/dist/font-substitutes.d.ts +1 -1
- package/dist/font-tables.cjs +31 -0
- package/dist/font-tables.d.cts +3 -1
- package/dist/font-tables.d.ts +3 -1
- package/dist/font-tables.js +31 -2
- package/dist/fonts.d.cts +2 -2
- package/dist/fonts.d.ts +2 -2
- package/dist/form.cjs +138 -0
- package/dist/form.d.cts +9 -0
- package/dist/form.d.ts +9 -0
- package/dist/form.js +137 -0
- package/dist/gsub-table-BRTQ8EUW.d.ts +10 -0
- package/dist/gsub-table-URczLd85.d.cts +10 -0
- package/dist/gsub-table.cjs +225 -0
- package/dist/gsub-table.d.cts +2 -0
- package/dist/gsub-table.d.ts +2 -0
- package/dist/gsub-table.js +224 -0
- package/dist/image/ccitt-encode.cjs +119 -0
- package/dist/image/ccitt-encode.d.cts +9 -0
- package/dist/image/ccitt-encode.d.ts +9 -0
- package/dist/image/ccitt-encode.js +118 -0
- package/dist/image/ccitt.cjs +3 -0
- package/dist/image/ccitt.d.cts +4 -1
- package/dist/image/ccitt.d.ts +4 -1
- package/dist/image/ccitt.js +1 -1
- package/dist/image/jbig2-bitmap.d.cts +1 -1
- package/dist/image/jbig2-bitmap.d.ts +1 -1
- package/dist/image/jbig2.cjs +3 -1
- package/dist/image/jbig2.js +3 -1
- package/dist/image/jp2-boxes.d.cts +1 -1
- package/dist/image/jp2-boxes.d.ts +1 -1
- package/dist/image/jpeg2000-codestream.d.cts +3 -3
- package/dist/image/jpeg2000-codestream.d.ts +3 -3
- package/dist/image/jpeg2000-t1.d.cts +1 -1
- package/dist/image/jpeg2000-t1.d.ts +1 -1
- package/dist/image/jpeg2000.cjs +1 -0
- package/dist/image/jpeg2000.d.cts +3 -0
- package/dist/image/jpeg2000.d.ts +3 -0
- package/dist/image/jpeg2000.js +1 -0
- package/dist/image/png-decode.cjs +1 -1
- package/dist/image/png-decode.js +1 -1
- package/dist/image/png-filter.d.cts +1 -1
- package/dist/image/png-filter.d.ts +1 -1
- package/dist/images-read.cjs +18 -12
- package/dist/images-read.d.cts +2 -2
- package/dist/images-read.d.ts +2 -2
- package/dist/images-read.js +15 -9
- package/dist/index.cjs +17 -4
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -5
- package/dist/interpret.cjs +178 -56
- package/dist/interpret.d.cts +27 -12
- package/dist/interpret.d.ts +27 -12
- package/dist/interpret.js +178 -56
- package/dist/layout.cjs +149 -2
- package/dist/layout.d.cts +394 -1
- package/dist/layout.d.ts +394 -1
- package/dist/layout.js +140 -4
- package/dist/lexer.d.cts +9 -9
- package/dist/lexer.d.ts +9 -9
- package/dist/math-content-write.cjs +1 -1
- package/dist/math-content-write.js +1 -1
- package/dist/math-font-write.cjs +1 -1
- package/dist/math-font-write.d.cts +1 -1
- package/dist/math-font-write.d.ts +1 -1
- package/dist/math-font-write.js +1 -1
- package/dist/math-font.cjs +2 -2
- package/dist/math-font.d.cts +1 -1
- package/dist/math-font.d.ts +1 -1
- package/dist/math-font.js +2 -2
- package/dist/{math-stretch-a_rHNRvc.d.ts → math-stretch-BbC2o4Br.d.ts} +1 -1
- package/dist/{math-stretch-E26z6byT.d.cts → math-stretch-C2JanDAz.d.cts} +1 -1
- package/dist/math-stretch.d.cts +1 -1
- package/dist/math-stretch.d.ts +1 -1
- package/dist/measure.cjs +1 -1
- package/dist/measure.d.cts +1 -1
- package/dist/measure.d.ts +1 -1
- package/dist/measure.js +1 -1
- package/dist/names.cjs +41 -0
- package/dist/names.d.cts +11 -0
- package/dist/names.d.ts +11 -0
- package/dist/names.js +40 -0
- package/dist/navigation.cjs +210 -0
- package/dist/navigation.d.cts +18 -0
- package/dist/navigation.d.ts +18 -0
- package/dist/navigation.js +207 -0
- package/dist/notes-annotation-author.cjs +5 -0
- package/dist/notes-annotation-author.d.cts +4 -0
- package/dist/notes-annotation-author.d.ts +4 -0
- package/dist/notes-annotation-author.js +4 -0
- package/dist/objects-B7HdMeWS.d.cts +59 -0
- package/dist/objects-B7HdMeWS.d.ts +59 -0
- package/dist/objects.d.cts +1 -58
- package/dist/objects.d.ts +1 -58
- package/dist/optional-content.cjs +63 -0
- package/dist/optional-content.d.cts +12 -0
- package/dist/optional-content.d.ts +12 -0
- package/dist/optional-content.js +62 -0
- package/dist/parse.cjs +1 -1
- package/dist/parse.d.cts +2 -2
- package/dist/parse.d.ts +2 -2
- package/dist/parse.js +1 -1
- package/dist/pdf-text.cjs +21 -0
- package/dist/pdf-text.d.cts +5 -0
- package/dist/pdf-text.d.ts +5 -0
- package/dist/pdf-text.js +19 -0
- package/dist/predictors.d.cts +1 -1
- package/dist/predictors.d.ts +1 -1
- package/dist/read.cjs +287 -72
- package/dist/read.d.cts +2 -4
- package/dist/read.d.ts +2 -4
- package/dist/read.js +284 -67
- package/dist/serialize.cjs +5 -1
- package/dist/serialize.d.cts +3 -2
- package/dist/serialize.d.ts +3 -2
- package/dist/serialize.js +5 -2
- package/dist/sfnt-subset.cjs +10 -3
- package/dist/sfnt-subset.d.cts +1 -1
- package/dist/sfnt-subset.d.ts +1 -1
- package/dist/sfnt-subset.js +10 -3
- package/dist/structure.cjs +184 -0
- package/dist/structure.d.cts +12 -0
- package/dist/structure.d.ts +12 -0
- package/dist/structure.js +183 -0
- package/dist/tounicode.cjs +8 -3
- package/dist/tounicode.d.cts +2 -2
- package/dist/tounicode.d.ts +2 -2
- package/dist/tounicode.js +8 -3
- package/dist/util/base64.cjs +4 -4
- package/dist/util/base64.js +4 -4
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.d.cts +1 -1
- package/dist/winansi.d.ts +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +464 -21
- package/dist/write.d.cts +4 -3
- package/dist/write.d.ts +4 -3
- package/dist/write.js +464 -20
- package/dist/xmp.cjs +46 -0
- package/dist/xmp.d.cts +14 -0
- package/dist/xmp.d.ts +14 -0
- package/dist/xmp.js +45 -0
- package/dist/xref.cjs +2 -2
- package/dist/xref.d.cts +3 -3
- package/dist/xref.d.ts +3 -3
- package/dist/xref.js +2 -2
- package/package.json +46 -31
- package/dist/image/png-encode.cjs +0 -64
- package/dist/image/png-encode.d.cts +0 -8
- package/dist/image/png-encode.d.ts +0 -8
- package/dist/image/png-encode.js +0 -63
package/dist/objects.d.ts
CHANGED
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
type PdfObject = {
|
|
3
|
-
kind: 'null';
|
|
4
|
-
} | {
|
|
5
|
-
kind: 'bool';
|
|
6
|
-
value: boolean;
|
|
7
|
-
} | {
|
|
8
|
-
kind: 'number';
|
|
9
|
-
value: number;
|
|
10
|
-
} | {
|
|
11
|
-
kind: 'name';
|
|
12
|
-
name: string;
|
|
13
|
-
} | {
|
|
14
|
-
kind: 'string';
|
|
15
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
16
|
-
hex: boolean;
|
|
17
|
-
} | {
|
|
18
|
-
kind: 'array';
|
|
19
|
-
items: PdfObject[];
|
|
20
|
-
} | {
|
|
21
|
-
kind: 'dict';
|
|
22
|
-
entries: Map<string, PdfObject>;
|
|
23
|
-
} | {
|
|
24
|
-
kind: 'stream';
|
|
25
|
-
dict: PdfDict;
|
|
26
|
-
raw: Uint8Array<ArrayBuffer>;
|
|
27
|
-
} | {
|
|
28
|
-
kind: 'ref';
|
|
29
|
-
num: number;
|
|
30
|
-
gen: number;
|
|
31
|
-
};
|
|
32
|
-
type PdfDict = Extract<PdfObject, {
|
|
33
|
-
kind: 'dict';
|
|
34
|
-
}>;
|
|
35
|
-
type PdfArray = Extract<PdfObject, {
|
|
36
|
-
kind: 'array';
|
|
37
|
-
}>;
|
|
38
|
-
type PdfStream = Extract<PdfObject, {
|
|
39
|
-
kind: 'stream';
|
|
40
|
-
}>;
|
|
41
|
-
declare function pdfNull(): PdfObject;
|
|
42
|
-
declare function pdfBool(value: boolean): PdfObject;
|
|
43
|
-
declare function pdfNum(value: number): PdfObject;
|
|
44
|
-
declare function pdfName(name: string): PdfObject;
|
|
45
|
-
declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
46
|
-
declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
47
|
-
declare function pdfArray(items: PdfObject[]): PdfObject;
|
|
48
|
-
declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
|
|
49
|
-
declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
|
|
50
|
-
declare function pdfRef(num: number, gen: number): PdfObject;
|
|
51
|
-
declare function isName(obj: PdfObject | undefined, name: string): boolean;
|
|
52
|
-
declare function asNumber(obj: PdfObject | undefined): number | undefined;
|
|
53
|
-
declare function asName(obj: PdfObject | undefined): string | undefined;
|
|
54
|
-
declare function asBool(obj: PdfObject | undefined): boolean | undefined;
|
|
55
|
-
declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
|
|
56
|
-
declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
|
|
57
|
-
declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
|
|
58
|
-
//#endregion
|
|
1
|
+
import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-B7HdMeWS.js";
|
|
59
2
|
export { PdfArray, PdfDict, PdfObject, PdfStream, asArray, asBool, asDict, asName, asNumber, dictGet, isName, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
3
|
+
const require_pdf_text = require("./pdf-text.cjs");
|
|
4
|
+
//#region src/optional-content.ts
|
|
5
|
+
function readOptionalContent(catalog, resolver, sink) {
|
|
6
|
+
const ocProperties = resolver.resolveDict(require_objects.dictGet(catalog, "OCProperties"));
|
|
7
|
+
if (ocProperties === void 0) return {
|
|
8
|
+
layers: [],
|
|
9
|
+
layerNameOf: () => void 0
|
|
10
|
+
};
|
|
11
|
+
const nameByGroup = /* @__PURE__ */ new Map();
|
|
12
|
+
const groups = [];
|
|
13
|
+
const ocgs = require_objects.asArray(resolver.resolve(require_objects.dictGet(ocProperties, "OCGs"))) ?? [];
|
|
14
|
+
for (const ocgRef of ocgs) {
|
|
15
|
+
const ocg = resolver.resolveDict(ocgRef);
|
|
16
|
+
if (ocg === void 0) {
|
|
17
|
+
sink({
|
|
18
|
+
code: "pdf/ocg-unresolved",
|
|
19
|
+
severity: "warning",
|
|
20
|
+
message: "an entry in /OCProperties /OCGs did not resolve to a dictionary; skipping it"
|
|
21
|
+
});
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const nameObj = require_objects.dictGet(ocg, "Name");
|
|
25
|
+
const name = nameObj?.kind === "string" ? require_pdf_text.decodePdfString(nameObj.bytes) : mintLayerName(nameByGroup);
|
|
26
|
+
nameByGroup.set(ocg, name);
|
|
27
|
+
groups.push({
|
|
28
|
+
dict: ocg,
|
|
29
|
+
name
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const defaultConfig = resolver.resolveDict(require_objects.dictGet(ocProperties, "D"));
|
|
33
|
+
const baseVisible = defaultConfig === void 0 || require_objects.asName(require_objects.dictGet(defaultConfig, "BaseState")) !== "OFF";
|
|
34
|
+
const groupsIn = (key) => {
|
|
35
|
+
const set = /* @__PURE__ */ new Set();
|
|
36
|
+
const arr = defaultConfig === void 0 ? void 0 : require_objects.asArray(resolver.resolve(require_objects.dictGet(defaultConfig, key)));
|
|
37
|
+
if (arr !== void 0) for (const entry of arr) {
|
|
38
|
+
const dict = resolver.resolveDict(entry);
|
|
39
|
+
if (dict !== void 0) set.add(dict);
|
|
40
|
+
}
|
|
41
|
+
return set;
|
|
42
|
+
};
|
|
43
|
+
const on = groupsIn("ON");
|
|
44
|
+
const off = groupsIn("OFF");
|
|
45
|
+
return {
|
|
46
|
+
layers: groups.map(({ dict, name }) => ({
|
|
47
|
+
name,
|
|
48
|
+
visible: off.has(dict) ? false : on.has(dict) ? true : baseVisible
|
|
49
|
+
})),
|
|
50
|
+
layerNameOf: (obj) => {
|
|
51
|
+
const dict = resolver.resolveDict(obj);
|
|
52
|
+
return dict !== void 0 ? nameByGroup.get(dict) : void 0;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function mintLayerName(taken) {
|
|
57
|
+
const used = new Set(taken.values());
|
|
58
|
+
let n = 1;
|
|
59
|
+
while (used.has(`layer${n}`)) n++;
|
|
60
|
+
return `layer${n}`;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.readOptionalContent = readOptionalContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
|
|
3
|
+
import { PdfObjectResolver } from "./interpret.cjs";
|
|
4
|
+
import { LayoutLayer } from "./layout.cjs";
|
|
5
|
+
//#region src/optional-content.d.ts
|
|
6
|
+
interface OptionalContentContext {
|
|
7
|
+
readonly layers: readonly LayoutLayer[];
|
|
8
|
+
readonly layerNameOf: (obj: PdfObject | undefined) => string | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare function readOptionalContent(catalog: PdfDict, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): OptionalContentContext;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OptionalContentContext, readOptionalContent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
|
|
3
|
+
import { PdfObjectResolver } from "./interpret.js";
|
|
4
|
+
import { LayoutLayer } from "./layout.js";
|
|
5
|
+
//#region src/optional-content.d.ts
|
|
6
|
+
interface OptionalContentContext {
|
|
7
|
+
readonly layers: readonly LayoutLayer[];
|
|
8
|
+
readonly layerNameOf: (obj: PdfObject | undefined) => string | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare function readOptionalContent(catalog: PdfDict, resolver: PdfObjectResolver, sink: PdfDiagnosticSink): OptionalContentContext;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OptionalContentContext, readOptionalContent };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { asArray, asName, dictGet } from "./objects.js";
|
|
2
|
+
import { decodePdfString } from "./pdf-text.js";
|
|
3
|
+
//#region src/optional-content.ts
|
|
4
|
+
function readOptionalContent(catalog, resolver, sink) {
|
|
5
|
+
const ocProperties = resolver.resolveDict(dictGet(catalog, "OCProperties"));
|
|
6
|
+
if (ocProperties === void 0) return {
|
|
7
|
+
layers: [],
|
|
8
|
+
layerNameOf: () => void 0
|
|
9
|
+
};
|
|
10
|
+
const nameByGroup = /* @__PURE__ */ new Map();
|
|
11
|
+
const groups = [];
|
|
12
|
+
const ocgs = asArray(resolver.resolve(dictGet(ocProperties, "OCGs"))) ?? [];
|
|
13
|
+
for (const ocgRef of ocgs) {
|
|
14
|
+
const ocg = resolver.resolveDict(ocgRef);
|
|
15
|
+
if (ocg === void 0) {
|
|
16
|
+
sink({
|
|
17
|
+
code: "pdf/ocg-unresolved",
|
|
18
|
+
severity: "warning",
|
|
19
|
+
message: "an entry in /OCProperties /OCGs did not resolve to a dictionary; skipping it"
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const nameObj = dictGet(ocg, "Name");
|
|
24
|
+
const name = nameObj?.kind === "string" ? decodePdfString(nameObj.bytes) : mintLayerName(nameByGroup);
|
|
25
|
+
nameByGroup.set(ocg, name);
|
|
26
|
+
groups.push({
|
|
27
|
+
dict: ocg,
|
|
28
|
+
name
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const defaultConfig = resolver.resolveDict(dictGet(ocProperties, "D"));
|
|
32
|
+
const baseVisible = defaultConfig === void 0 || asName(dictGet(defaultConfig, "BaseState")) !== "OFF";
|
|
33
|
+
const groupsIn = (key) => {
|
|
34
|
+
const set = /* @__PURE__ */ new Set();
|
|
35
|
+
const arr = defaultConfig === void 0 ? void 0 : asArray(resolver.resolve(dictGet(defaultConfig, key)));
|
|
36
|
+
if (arr !== void 0) for (const entry of arr) {
|
|
37
|
+
const dict = resolver.resolveDict(entry);
|
|
38
|
+
if (dict !== void 0) set.add(dict);
|
|
39
|
+
}
|
|
40
|
+
return set;
|
|
41
|
+
};
|
|
42
|
+
const on = groupsIn("ON");
|
|
43
|
+
const off = groupsIn("OFF");
|
|
44
|
+
return {
|
|
45
|
+
layers: groups.map(({ dict, name }) => ({
|
|
46
|
+
name,
|
|
47
|
+
visible: off.has(dict) ? false : on.has(dict) ? true : baseVisible
|
|
48
|
+
})),
|
|
49
|
+
layerNameOf: (obj) => {
|
|
50
|
+
const dict = resolver.resolveDict(obj);
|
|
51
|
+
return dict !== void 0 ? nameByGroup.get(dict) : void 0;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function mintLayerName(taken) {
|
|
56
|
+
const used = new Set(taken.values());
|
|
57
|
+
let n = 1;
|
|
58
|
+
while (used.has(`layer${n}`)) n++;
|
|
59
|
+
return `layer${n}`;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { readOptionalContent };
|
package/dist/parse.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_lexer = require("./lexer.cjs");
|
|
3
2
|
const require_objects = require("./objects.cjs");
|
|
3
|
+
const require_lexer = require("./lexer.cjs");
|
|
4
4
|
//#region src/parse.ts
|
|
5
5
|
function parseValue(reader, sink) {
|
|
6
6
|
const token = require_lexer.nextToken(reader);
|
package/dist/parse.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ByteReader } from "./bytes/reader.cjs";
|
|
2
1
|
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
3
|
-
import { PdfObject } from "./objects.cjs";
|
|
2
|
+
import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
|
|
3
|
+
import { ByteReader } from "./bytes/reader.cjs";
|
|
4
4
|
//#region src/parse.d.ts
|
|
5
5
|
declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
|
|
6
6
|
interface ParsedIndirectObject {
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ByteReader } from "./bytes/reader.js";
|
|
2
1
|
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
3
|
-
import { PdfObject } from "./objects.js";
|
|
2
|
+
import { r as PdfObject } from "./objects-B7HdMeWS.js";
|
|
3
|
+
import { ByteReader } from "./bytes/reader.js";
|
|
4
4
|
//#region src/parse.d.ts
|
|
5
5
|
declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
|
|
6
6
|
interface ParsedIndirectObject {
|
package/dist/parse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { nextToken } from "./lexer.js";
|
|
2
1
|
import { dictGet, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream } from "./objects.js";
|
|
2
|
+
import { nextToken } from "./lexer.js";
|
|
3
3
|
//#region src/parse.ts
|
|
4
4
|
function parseValue(reader, sink) {
|
|
5
5
|
const token = nextToken(reader);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/pdf-text.ts
|
|
3
|
+
function decodePdfString(bytes) {
|
|
4
|
+
if (bytes.length >= 2 && bytes[0] === 254 && bytes[1] === 255) {
|
|
5
|
+
let out = "";
|
|
6
|
+
for (let i = 2; i + 1 < bytes.length; i += 2) out += String.fromCharCode((bytes[i] ?? 0) << 8 | (bytes[i + 1] ?? 0));
|
|
7
|
+
return out;
|
|
8
|
+
}
|
|
9
|
+
return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
|
|
10
|
+
}
|
|
11
|
+
const PDF_DATE_PATTERN = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?'?$/;
|
|
12
|
+
function parsePdfDate(raw) {
|
|
13
|
+
if (raw === void 0) return;
|
|
14
|
+
const match = PDF_DATE_PATTERN.exec(raw);
|
|
15
|
+
if (match === null) return;
|
|
16
|
+
const [, year, month = "01", day = "01", hour = "00", minute = "00", second = "00", tzSign, tzHour = "00", tzMinute = "00"] = match;
|
|
17
|
+
return `${year}-${month}-${day}T${hour}:${minute}:${second}${tzSign === void 0 || tzSign === "Z" ? "Z" : `${tzSign}${tzHour}:${tzMinute}`}`;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.decodePdfString = decodePdfString;
|
|
21
|
+
exports.parsePdfDate = parsePdfDate;
|
package/dist/pdf-text.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/pdf-text.ts
|
|
2
|
+
function decodePdfString(bytes) {
|
|
3
|
+
if (bytes.length >= 2 && bytes[0] === 254 && bytes[1] === 255) {
|
|
4
|
+
let out = "";
|
|
5
|
+
for (let i = 2; i + 1 < bytes.length; i += 2) out += String.fromCharCode((bytes[i] ?? 0) << 8 | (bytes[i + 1] ?? 0));
|
|
6
|
+
return out;
|
|
7
|
+
}
|
|
8
|
+
return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
|
|
9
|
+
}
|
|
10
|
+
const PDF_DATE_PATTERN = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?'?$/;
|
|
11
|
+
function parsePdfDate(raw) {
|
|
12
|
+
if (raw === void 0) return;
|
|
13
|
+
const match = PDF_DATE_PATTERN.exec(raw);
|
|
14
|
+
if (match === null) return;
|
|
15
|
+
const [, year, month = "01", day = "01", hour = "00", minute = "00", second = "00", tzSign, tzHour = "00", tzMinute = "00"] = match;
|
|
16
|
+
return `${year}-${month}-${day}T${hour}:${minute}:${second}${tzSign === void 0 || tzSign === "Z" ? "Z" : `${tzSign}${tzHour}:${tzMinute}`}`;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { decodePdfString, parsePdfDate };
|
package/dist/predictors.d.cts
CHANGED
package/dist/predictors.d.ts
CHANGED