pdf-codec 3.1.4 → 3.2.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/README.md +2 -2
- 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/bytes/flate.cjs +1 -1
- package/dist/bytes/flate.js +1 -1
- package/dist/codec.d.cts +109 -0
- package/dist/codec.d.ts +109 -0
- package/dist/content-read.cjs +1 -1
- package/dist/content-read.js +1 -1
- package/dist/content-write.cjs +2 -2
- package/dist/content-write.js +2 -2
- package/dist/document.cjs +12 -3
- package/dist/document.d.cts +2 -0
- package/dist/document.d.ts +2 -0
- package/dist/document.js +12 -3
- package/dist/embedded-font-write.cjs +1 -1
- package/dist/embedded-font-write.js +1 -1
- package/dist/encrypt.cjs +1 -1
- package/dist/encrypt.js +1 -1
- package/dist/filters.cjs +1 -1
- package/dist/filters.js +1 -1
- package/dist/font-read.cjs +1 -1
- package/dist/font-read.js +1 -1
- package/dist/font-registry.cjs +1 -1
- package/dist/font-registry.js +1 -1
- 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/image/png-decode.cjs +1 -1
- package/dist/image/png-decode.js +1 -1
- package/dist/image/png-encode.cjs +1 -1
- package/dist/image/png-encode.js +1 -1
- package/dist/index.cjs +12 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/interpret.cjs +70 -10
- package/dist/interpret.d.cts +9 -1
- package/dist/interpret.d.ts +9 -1
- package/dist/interpret.js +70 -10
- package/dist/layout.cjs +132 -2
- package/dist/layout.d.cts +335 -1
- package/dist/layout.d.ts +335 -1
- package/dist/layout.js +124 -4
- package/dist/math-content-write.cjs +1 -1
- package/dist/math-content-write.js +1 -1
- package/dist/math-font.cjs +1 -1
- package/dist/math-font.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/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 +1 -1
- package/dist/parse.d.ts +1 -1
- 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/read.cjs +128 -58
- package/dist/read.d.cts +2 -4
- package/dist/read.d.ts +2 -4
- package/dist/read.js +125 -53
- 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/write.cjs +51 -5
- package/dist/write.js +51 -5
- 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.js +2 -2
- package/package.json +2 -2
package/dist/codec.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LayoutFormField, LayoutOutlineItem } from "./layout.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
//#region src/codec.d.ts
|
|
3
4
|
declare const PdfBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
@@ -12,6 +13,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
12
13
|
producer: z.ZodOptional<z.ZodString>;
|
|
13
14
|
createdIso: z.ZodOptional<z.ZodString>;
|
|
14
15
|
modifiedIso: z.ZodOptional<z.ZodString>;
|
|
16
|
+
language: z.ZodOptional<z.ZodString>;
|
|
15
17
|
}, z.core.$strip>;
|
|
16
18
|
pages: z.ZodArray<z.ZodObject<{
|
|
17
19
|
widthPt: z.ZodNumber;
|
|
@@ -41,6 +43,9 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
41
43
|
widthPt: z.ZodOptional<z.ZodNumber>;
|
|
42
44
|
rotationDeg: z.ZodOptional<z.ZodNumber>;
|
|
43
45
|
underline: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
47
|
+
actualText: z.ZodOptional<z.ZodString>;
|
|
48
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
44
49
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
45
50
|
}, z.core.$strip>, z.ZodObject<{
|
|
46
51
|
kind: z.ZodLiteral<"image">;
|
|
@@ -50,6 +55,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
50
55
|
widthPt: z.ZodNumber;
|
|
51
56
|
heightPt: z.ZodNumber;
|
|
52
57
|
rotationDeg: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
53
59
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
54
60
|
}, z.core.$strip>, z.ZodObject<{
|
|
55
61
|
kind: z.ZodLiteral<"rect">;
|
|
@@ -70,6 +76,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
70
76
|
}, z.core.$strip>;
|
|
71
77
|
widthPt: z.ZodNumber;
|
|
72
78
|
}, z.core.$strip>>;
|
|
79
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
73
80
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
74
81
|
}, z.core.$strip>, z.ZodObject<{
|
|
75
82
|
kind: z.ZodLiteral<"line">;
|
|
@@ -89,6 +96,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
89
96
|
dotted: "dotted";
|
|
90
97
|
double: "double";
|
|
91
98
|
}>>;
|
|
99
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
92
100
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
93
101
|
}, z.core.$strip>, z.ZodObject<{
|
|
94
102
|
kind: z.ZodLiteral<"ellipse">;
|
|
@@ -109,6 +117,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
109
117
|
}, z.core.$strip>;
|
|
110
118
|
widthPt: z.ZodNumber;
|
|
111
119
|
}, z.core.$strip>>;
|
|
120
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
112
121
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
113
122
|
}, z.core.$strip>, z.ZodObject<{
|
|
114
123
|
kind: z.ZodLiteral<"path">;
|
|
@@ -153,6 +162,7 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
153
162
|
dotted: "dotted";
|
|
154
163
|
double: "double";
|
|
155
164
|
}>>;
|
|
165
|
+
layer: z.ZodOptional<z.ZodString>;
|
|
156
166
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
157
167
|
}, z.core.$strip>, z.ZodObject<{
|
|
158
168
|
kind: z.ZodLiteral<"link">;
|
|
@@ -161,8 +171,57 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
161
171
|
yPt: z.ZodNumber;
|
|
162
172
|
widthPt: z.ZodNumber;
|
|
163
173
|
heightPt: z.ZodNumber;
|
|
174
|
+
title: z.ZodOptional<z.ZodString>;
|
|
164
175
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
177
|
+
kind: z.ZodLiteral<"internalLink">;
|
|
178
|
+
destination: z.ZodString;
|
|
179
|
+
xPt: z.ZodNumber;
|
|
180
|
+
yPt: z.ZodNumber;
|
|
181
|
+
widthPt: z.ZodNumber;
|
|
182
|
+
heightPt: z.ZodNumber;
|
|
183
|
+
title: z.ZodOptional<z.ZodString>;
|
|
165
184
|
}, z.core.$strip>], "kind">>;
|
|
185
|
+
annotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
186
|
+
subtype: z.ZodString;
|
|
187
|
+
xPt: z.ZodNumber;
|
|
188
|
+
yPt: z.ZodNumber;
|
|
189
|
+
widthPt: z.ZodNumber;
|
|
190
|
+
heightPt: z.ZodNumber;
|
|
191
|
+
contents: z.ZodOptional<z.ZodString>;
|
|
192
|
+
author: z.ZodOptional<z.ZodString>;
|
|
193
|
+
modifiedIso: z.ZodOptional<z.ZodString>;
|
|
194
|
+
quads: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodObject<{
|
|
195
|
+
xPt: z.ZodNumber;
|
|
196
|
+
yPt: z.ZodNumber;
|
|
197
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
198
|
+
xPt: z.ZodNumber;
|
|
199
|
+
yPt: z.ZodNumber;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
xPt: z.ZodNumber;
|
|
202
|
+
yPt: z.ZodNumber;
|
|
203
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
204
|
+
xPt: z.ZodNumber;
|
|
205
|
+
yPt: z.ZodNumber;
|
|
206
|
+
}, z.core.$strip>], null>>>;
|
|
207
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
208
|
+
format: z.ZodEnum<{
|
|
209
|
+
docx: "docx";
|
|
210
|
+
pptx: "pptx";
|
|
211
|
+
xlsx: "xlsx";
|
|
212
|
+
odt: "odt";
|
|
213
|
+
ods: "ods";
|
|
214
|
+
odp: "odp";
|
|
215
|
+
odg: "odg";
|
|
216
|
+
odm: "odm";
|
|
217
|
+
odb: "odb";
|
|
218
|
+
odf: "odf";
|
|
219
|
+
markdown: "markdown";
|
|
220
|
+
pdf: "pdf";
|
|
221
|
+
}>;
|
|
222
|
+
xml: z.ZodString;
|
|
223
|
+
}, z.core.$strict>>;
|
|
224
|
+
}, z.core.$strip>>>;
|
|
166
225
|
notes: z.ZodOptional<z.ZodString>;
|
|
167
226
|
}, z.core.$strip>>;
|
|
168
227
|
images: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -174,6 +233,56 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
174
233
|
widthPx: z.ZodNumber;
|
|
175
234
|
heightPx: z.ZodNumber;
|
|
176
235
|
}, z.core.$strip>>;
|
|
236
|
+
destinations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
pageIndex: z.ZodNumber;
|
|
239
|
+
target: z.ZodObject<{
|
|
240
|
+
kind: z.ZodEnum<{
|
|
241
|
+
xyz: "xyz";
|
|
242
|
+
fit: "fit";
|
|
243
|
+
fitH: "fitH";
|
|
244
|
+
fitV: "fitV";
|
|
245
|
+
fitR: "fitR";
|
|
246
|
+
fitB: "fitB";
|
|
247
|
+
fitBH: "fitBH";
|
|
248
|
+
fitBV: "fitBV";
|
|
249
|
+
}>;
|
|
250
|
+
leftPt: z.ZodOptional<z.ZodNumber>;
|
|
251
|
+
topPt: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
bottomPt: z.ZodOptional<z.ZodNumber>;
|
|
253
|
+
rightPt: z.ZodOptional<z.ZodNumber>;
|
|
254
|
+
zoom: z.ZodOptional<z.ZodNumber>;
|
|
255
|
+
}, z.core.$strip>;
|
|
256
|
+
}, z.core.$strip>>>;
|
|
257
|
+
outline: z.ZodOptional<z.ZodArray<z.ZodType<LayoutOutlineItem, LayoutOutlineItem, z.core.$ZodTypeInternals<LayoutOutlineItem, LayoutOutlineItem>>>>;
|
|
258
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
259
|
+
name: z.ZodString;
|
|
260
|
+
description: z.ZodOptional<z.ZodString>;
|
|
261
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
262
|
+
base64: z.ZodString;
|
|
263
|
+
}, z.core.$strip>>>;
|
|
264
|
+
layers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
265
|
+
name: z.ZodString;
|
|
266
|
+
visible: z.ZodBoolean;
|
|
267
|
+
}, z.core.$strip>>>;
|
|
268
|
+
form: z.ZodOptional<z.ZodArray<z.ZodType<LayoutFormField, LayoutFormField, z.core.$ZodTypeInternals<LayoutFormField, LayoutFormField>>>>;
|
|
269
|
+
source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
270
|
+
format: z.ZodEnum<{
|
|
271
|
+
docx: "docx";
|
|
272
|
+
pptx: "pptx";
|
|
273
|
+
xlsx: "xlsx";
|
|
274
|
+
odt: "odt";
|
|
275
|
+
ods: "ods";
|
|
276
|
+
odp: "odp";
|
|
277
|
+
odg: "odg";
|
|
278
|
+
odm: "odm";
|
|
279
|
+
odb: "odb";
|
|
280
|
+
odf: "odf";
|
|
281
|
+
markdown: "markdown";
|
|
282
|
+
pdf: "pdf";
|
|
283
|
+
}>;
|
|
284
|
+
xml: z.ZodString;
|
|
285
|
+
}, z.core.$strict>>>;
|
|
177
286
|
}, z.core.$strip>>;
|
|
178
287
|
//#endregion
|
|
179
288
|
export { PdfBytesSchema, pdfCodec };
|
package/dist/content-read.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
2
3
|
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
3
4
|
const require_lexer = require("./lexer.cjs");
|
|
4
|
-
const require_objects = require("./objects.cjs");
|
|
5
5
|
const require_parse = require("./parse.cjs");
|
|
6
6
|
//#region src/content-read.ts
|
|
7
7
|
function readContentStream(bytes, sink) {
|
package/dist/content-read.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { asNumber, dictGet, pdfDict } from "./objects.js";
|
|
1
2
|
import { ByteReader, isAsciiWhitespace } from "./bytes/reader.js";
|
|
2
3
|
import { nextToken } from "./lexer.js";
|
|
3
|
-
import { asNumber, dictGet, pdfDict } from "./objects.js";
|
|
4
4
|
import { parseValue } from "./parse.js";
|
|
5
5
|
//#region src/content-read.ts
|
|
6
6
|
function readContentStream(bytes, sink) {
|
package/dist/content-write.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
|
|
3
|
-
const require_bytes_writer = require("./bytes/writer.cjs");
|
|
4
3
|
const require_objects = require("./objects.cjs");
|
|
4
|
+
const require_bytes_writer = require("./bytes/writer.cjs");
|
|
5
|
+
const require_serialize = require("./serialize.cjs");
|
|
5
6
|
const require_matrix = require("./matrix.cjs");
|
|
6
7
|
const require_embedded_font = require("./embedded-font.cjs");
|
|
7
|
-
const require_serialize = require("./serialize.cjs");
|
|
8
8
|
//#region src/content-write.ts
|
|
9
9
|
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
10
10
|
const EMBEDDED_HORIZONTAL_SCALE_PERCENT = 100;
|
package/dist/content-write.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { o as encodeForShow } from "./afm-widths-Dxucrg7D.js";
|
|
2
|
-
import { ByteWriter } from "./bytes/writer.js";
|
|
3
2
|
import { pdfArray, pdfHexString, pdfNum } from "./objects.js";
|
|
3
|
+
import { ByteWriter } from "./bytes/writer.js";
|
|
4
|
+
import { formatNumber, writeObject } from "./serialize.js";
|
|
4
5
|
import { BEZIER_KAPPA, multiplyMatrices, rotationMatrix, scaleMatrix, translationMatrix } from "./matrix.js";
|
|
5
6
|
import { encodeForShowEmbedded } from "./embedded-font.js";
|
|
6
|
-
import { formatNumber, writeObject } from "./serialize.js";
|
|
7
7
|
//#region src/content-write.ts
|
|
8
8
|
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
9
9
|
const EMBEDDED_HORIZONTAL_SCALE_PERCENT = 100;
|
package/dist/document.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
2
3
|
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
4
|
+
const require_filters = require("./filters.cjs");
|
|
3
5
|
const require_lexer = require("./lexer.cjs");
|
|
4
6
|
const require_diagnostics = require("./diagnostics.cjs");
|
|
5
|
-
const require_objects = require("./objects.cjs");
|
|
6
7
|
const require_encrypt = require("./encrypt.cjs");
|
|
7
|
-
const require_filters = require("./filters.cjs");
|
|
8
8
|
const require_parse = require("./parse.cjs");
|
|
9
9
|
const require_xref = require("./xref.cjs");
|
|
10
10
|
//#region src/document.ts
|
|
@@ -150,10 +150,12 @@ function openPdfDocument(bytes, sink) {
|
|
|
150
150
|
decryptor = require_encrypt.createStandardDecryptor(encryptDict, firstFileId(xref.trailer), sink);
|
|
151
151
|
}
|
|
152
152
|
const catalog = requireCatalog(resolveDict(require_objects.dictGet(xref.trailer, "Root")));
|
|
153
|
+
const originalLeaves = /* @__PURE__ */ new Map();
|
|
153
154
|
function pages() {
|
|
154
155
|
const pagesRoot = resolveDict(require_objects.dictGet(catalog, "Pages"));
|
|
155
156
|
if (pagesRoot === void 0) return [];
|
|
156
157
|
const result = [];
|
|
158
|
+
originalLeaves.clear();
|
|
157
159
|
walkPageTree(pagesRoot, {}, /* @__PURE__ */ new Set(), result);
|
|
158
160
|
return result;
|
|
159
161
|
}
|
|
@@ -176,6 +178,7 @@ function openPdfDocument(bytes, sink) {
|
|
|
176
178
|
if (kids === void 0) {
|
|
177
179
|
const entries = new Map(node.entries);
|
|
178
180
|
for (const key of INHERITABLE_PAGE_KEYS) if (!entries.has(key) && merged[key] !== void 0) entries.set(key, merged[key]);
|
|
181
|
+
originalLeaves.set(node, result.length);
|
|
179
182
|
result.push({
|
|
180
183
|
kind: "dict",
|
|
181
184
|
entries
|
|
@@ -187,11 +190,17 @@ function openPdfDocument(bytes, sink) {
|
|
|
187
190
|
if (kidDict !== void 0) walkPageTree(kidDict, merged, visited, result);
|
|
188
191
|
}
|
|
189
192
|
}
|
|
193
|
+
function pageIndex(obj) {
|
|
194
|
+
const dict = require_objects.asDict(resolve(obj));
|
|
195
|
+
return dict !== void 0 ? originalLeaves.get(dict) : void 0;
|
|
196
|
+
}
|
|
190
197
|
return {
|
|
191
198
|
trailer: xref.trailer,
|
|
199
|
+
catalog,
|
|
192
200
|
resolve,
|
|
193
201
|
resolveDict,
|
|
194
|
-
pages
|
|
202
|
+
pages,
|
|
203
|
+
pageIndex
|
|
195
204
|
};
|
|
196
205
|
}
|
|
197
206
|
//#endregion
|
package/dist/document.d.cts
CHANGED
|
@@ -3,9 +3,11 @@ import { PdfDict, PdfObject } from "./objects.cjs";
|
|
|
3
3
|
//#region src/document.d.ts
|
|
4
4
|
interface PdfDocument {
|
|
5
5
|
readonly trailer: PdfDict;
|
|
6
|
+
readonly catalog: PdfDict;
|
|
6
7
|
resolve(obj: PdfObject | undefined): PdfObject | undefined;
|
|
7
8
|
resolveDict(obj: PdfObject | undefined): PdfDict | undefined;
|
|
8
9
|
pages(): PdfDict[];
|
|
10
|
+
pageIndex(obj: PdfObject | undefined): number | undefined;
|
|
9
11
|
}
|
|
10
12
|
declare function openPdfDocument(bytes: Uint8Array<ArrayBuffer>, sink: PdfDiagnosticSink): PdfDocument;
|
|
11
13
|
//#endregion
|
package/dist/document.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import { PdfDict, PdfObject } from "./objects.js";
|
|
|
3
3
|
//#region src/document.d.ts
|
|
4
4
|
interface PdfDocument {
|
|
5
5
|
readonly trailer: PdfDict;
|
|
6
|
+
readonly catalog: PdfDict;
|
|
6
7
|
resolve(obj: PdfObject | undefined): PdfObject | undefined;
|
|
7
8
|
resolveDict(obj: PdfObject | undefined): PdfDict | undefined;
|
|
8
9
|
pages(): PdfDict[];
|
|
10
|
+
pageIndex(obj: PdfObject | undefined): number | undefined;
|
|
9
11
|
}
|
|
10
12
|
declare function openPdfDocument(bytes: Uint8Array<ArrayBuffer>, sink: PdfDiagnosticSink): PdfDocument;
|
|
11
13
|
//#endregion
|
package/dist/document.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { asArray, asDict, asNumber, dictGet, isName, pdfNull } from "./objects.js";
|
|
1
2
|
import { ByteReader } from "./bytes/reader.js";
|
|
3
|
+
import { decodeStream } from "./filters.js";
|
|
2
4
|
import { nextToken } from "./lexer.js";
|
|
3
5
|
import { PdfEncryptedError, PdfParseError } from "./diagnostics.js";
|
|
4
|
-
import { asArray, asDict, asNumber, dictGet, isName, pdfNull } from "./objects.js";
|
|
5
6
|
import { createStandardDecryptor } from "./encrypt.js";
|
|
6
|
-
import { decodeStream } from "./filters.js";
|
|
7
7
|
import { parseIndirectObject, parseValue } from "./parse.js";
|
|
8
8
|
import { readXref } from "./xref.js";
|
|
9
9
|
//#region src/document.ts
|
|
@@ -149,10 +149,12 @@ function openPdfDocument(bytes, sink) {
|
|
|
149
149
|
decryptor = createStandardDecryptor(encryptDict, firstFileId(xref.trailer), sink);
|
|
150
150
|
}
|
|
151
151
|
const catalog = requireCatalog(resolveDict(dictGet(xref.trailer, "Root")));
|
|
152
|
+
const originalLeaves = /* @__PURE__ */ new Map();
|
|
152
153
|
function pages() {
|
|
153
154
|
const pagesRoot = resolveDict(dictGet(catalog, "Pages"));
|
|
154
155
|
if (pagesRoot === void 0) return [];
|
|
155
156
|
const result = [];
|
|
157
|
+
originalLeaves.clear();
|
|
156
158
|
walkPageTree(pagesRoot, {}, /* @__PURE__ */ new Set(), result);
|
|
157
159
|
return result;
|
|
158
160
|
}
|
|
@@ -175,6 +177,7 @@ function openPdfDocument(bytes, sink) {
|
|
|
175
177
|
if (kids === void 0) {
|
|
176
178
|
const entries = new Map(node.entries);
|
|
177
179
|
for (const key of INHERITABLE_PAGE_KEYS) if (!entries.has(key) && merged[key] !== void 0) entries.set(key, merged[key]);
|
|
180
|
+
originalLeaves.set(node, result.length);
|
|
178
181
|
result.push({
|
|
179
182
|
kind: "dict",
|
|
180
183
|
entries
|
|
@@ -186,11 +189,17 @@ function openPdfDocument(bytes, sink) {
|
|
|
186
189
|
if (kidDict !== void 0) walkPageTree(kidDict, merged, visited, result);
|
|
187
190
|
}
|
|
188
191
|
}
|
|
192
|
+
function pageIndex(obj) {
|
|
193
|
+
const dict = asDict(resolve(obj));
|
|
194
|
+
return dict !== void 0 ? originalLeaves.get(dict) : void 0;
|
|
195
|
+
}
|
|
189
196
|
return {
|
|
190
197
|
trailer: xref.trailer,
|
|
198
|
+
catalog,
|
|
191
199
|
resolve,
|
|
192
200
|
resolveDict,
|
|
193
|
-
pages
|
|
201
|
+
pages,
|
|
202
|
+
pageIndex
|
|
194
203
|
};
|
|
195
204
|
}
|
|
196
205
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_bytes_crc32 = require("./bytes/crc32.cjs");
|
|
3
2
|
const require_objects = require("./objects.cjs");
|
|
4
3
|
const require_bytes_flate = require("./bytes/flate.cjs");
|
|
4
|
+
const require_bytes_crc32 = require("./bytes/crc32.cjs");
|
|
5
5
|
const require_tounicode = require("./tounicode.cjs");
|
|
6
6
|
//#region src/embedded-font-write.ts
|
|
7
7
|
const FLAG_SERIF = 2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { crc32 } from "./bytes/crc32.js";
|
|
2
1
|
import { pdfArray, pdfDict, pdfHexString, pdfName, pdfNum, pdfStream } from "./objects.js";
|
|
3
2
|
import { deflate } from "./bytes/flate.js";
|
|
3
|
+
import { crc32 } from "./bytes/crc32.js";
|
|
4
4
|
import { buildToUnicodeCMap } from "./tounicode.js";
|
|
5
5
|
//#region src/embedded-font-write.ts
|
|
6
6
|
const FLAG_SERIF = 2;
|
package/dist/encrypt.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_objects = require("./objects.cjs");
|
|
2
3
|
const require_bytes_writer = require("./bytes/writer.cjs");
|
|
3
4
|
const require_diagnostics = require("./diagnostics.cjs");
|
|
4
5
|
const require_crypto_aes = require("./crypto/aes.cjs");
|
|
5
6
|
const require_crypto_md5 = require("./crypto/md5.cjs");
|
|
6
7
|
const require_crypto_rc4 = require("./crypto/rc4.cjs");
|
|
7
8
|
const require_crypto_sha2 = require("./crypto/sha2.cjs");
|
|
8
|
-
const require_objects = require("./objects.cjs");
|
|
9
9
|
//#region src/encrypt.ts
|
|
10
10
|
const PASSWORD_PADDING = new Uint8Array([
|
|
11
11
|
40,
|
package/dist/encrypt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { asDict, asName, asNumber, dictGet } from "./objects.js";
|
|
1
2
|
import { concatBytes } from "./bytes/writer.js";
|
|
2
3
|
import { PdfEncryptedError, PdfPasswordRequiredError } from "./diagnostics.js";
|
|
3
4
|
import { aesCbcDecrypt, aesCbcEncrypt } from "./crypto/aes.js";
|
|
4
5
|
import { md5 } from "./crypto/md5.js";
|
|
5
6
|
import { rc4 } from "./crypto/rc4.js";
|
|
6
7
|
import { sha256, sha384, sha512 } from "./crypto/sha2.js";
|
|
7
|
-
import { asDict, asName, asNumber, dictGet } from "./objects.js";
|
|
8
8
|
//#region src/encrypt.ts
|
|
9
9
|
const PASSWORD_PADDING = new Uint8Array([
|
|
10
10
|
40,
|
package/dist/filters.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
3
2
|
const require_objects = require("./objects.cjs");
|
|
3
|
+
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
4
4
|
const require_bytes_flate = require("./bytes/flate.cjs");
|
|
5
5
|
const require_image_ccitt = require("./image/ccitt.cjs");
|
|
6
6
|
const require_image_jbig2 = require("./image/jbig2.cjs");
|
package/dist/filters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isAsciiWhitespace } from "./bytes/reader.js";
|
|
2
1
|
import { asArray, asBool, asDict, asName, asNumber, dictGet } from "./objects.js";
|
|
2
|
+
import { isAsciiWhitespace } from "./bytes/reader.js";
|
|
3
3
|
import { inflateTolerant } from "./bytes/flate.js";
|
|
4
4
|
import { decodeCcittFax } from "./image/ccitt.js";
|
|
5
5
|
import { decodeJbig2Embedded } from "./image/jbig2.js";
|
package/dist/font-read.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
|
|
3
|
-
const require_cmap = require("./cmap.cjs");
|
|
4
3
|
const require_objects = require("./objects.cjs");
|
|
5
4
|
const require_filters = require("./filters.cjs");
|
|
5
|
+
const require_cmap = require("./cmap.cjs");
|
|
6
6
|
const require_fonts = require("./fonts.cjs");
|
|
7
7
|
const require_font_style = require("./font-style.cjs");
|
|
8
8
|
//#region src/font-read.ts
|
package/dist/font-read.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as winAnsiGlyphName, i as glyphNameToUnicode, n as widthOfCode } from "./afm-widths-Dxucrg7D.js";
|
|
2
|
-
import { parseToUnicodeCMap } from "./cmap.js";
|
|
3
2
|
import { asArray, asName, asNumber, dictGet } from "./objects.js";
|
|
4
3
|
import { decodeStream } from "./filters.js";
|
|
4
|
+
import { parseToUnicodeCMap } from "./cmap.js";
|
|
5
5
|
import { resolveStandardFont } from "./fonts.js";
|
|
6
6
|
import { styleFromBaseFontName } from "./font-style.js";
|
|
7
7
|
//#region src/font-read.ts
|
package/dist/font-registry.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sfnt = require("./sfnt.cjs");
|
|
3
2
|
const require_util_base64 = require("./util/base64.cjs");
|
|
3
|
+
const require_sfnt = require("./sfnt.cjs");
|
|
4
4
|
const require_fonts = require("./fonts.cjs");
|
|
5
5
|
const require_embedded_font = require("./embedded-font.cjs");
|
|
6
6
|
const require_assets_caladea_bold = require("./assets/caladea-bold.cjs");
|
package/dist/font-registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { parseSfnt } from "./sfnt.js";
|
|
2
1
|
import { base64ToBytes } from "./util/base64.js";
|
|
2
|
+
import { parseSfnt } from "./sfnt.js";
|
|
3
3
|
import { normalizeFamilyName, resolveStandardFont } from "./fonts.js";
|
|
4
4
|
import { loadEmbeddedFace } from "./embedded-font.js";
|
|
5
5
|
import { CALADEA_BOLD_FONT_DEFLATED_BASE64 } from "./assets/caladea-bold.js";
|
package/dist/form.cjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
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/form.ts
|
|
5
|
+
const FLAG_READ_ONLY = 1;
|
|
6
|
+
const FLAG_PUSHBUTTON = 4;
|
|
7
|
+
const FLAG_RADIO = 32768;
|
|
8
|
+
const FLAG_COMBO = 131072;
|
|
9
|
+
function readAcroForm(catalog, resolver, pageIndex, sink) {
|
|
10
|
+
const acroForm = resolver.resolveDict(require_objects.dictGet(catalog, "AcroForm"));
|
|
11
|
+
if (acroForm === void 0) return [];
|
|
12
|
+
const fields = [];
|
|
13
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const fieldRef of require_objects.asArray(resolver.resolve(require_objects.dictGet(acroForm, "Fields"))) ?? []) {
|
|
15
|
+
const fieldDict = resolver.resolveDict(fieldRef);
|
|
16
|
+
if (fieldDict !== void 0) readField(fieldDict, "", resolver, pageIndex, sink, fields, visited);
|
|
17
|
+
}
|
|
18
|
+
return fields;
|
|
19
|
+
}
|
|
20
|
+
function readField(node, parentName, resolver, pageIndex, sink, out, visited) {
|
|
21
|
+
if (visited.has(node)) {
|
|
22
|
+
sink({
|
|
23
|
+
code: "pdf/form-field-cycle",
|
|
24
|
+
severity: "warning",
|
|
25
|
+
message: "the AcroForm field tree contains a cycle; stopping descent at the repeated field"
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
visited.add(node);
|
|
30
|
+
const ownName = annotText(node, "T");
|
|
31
|
+
const name = ownName === void 0 ? parentName : parentName.length > 0 ? `${parentName}.${ownName}` : ownName;
|
|
32
|
+
const fieldObj = require_objects.dictGet(node, "FT");
|
|
33
|
+
const fieldType = require_objects.asName(fieldObj);
|
|
34
|
+
if (fieldType === void 0) {
|
|
35
|
+
const children = [];
|
|
36
|
+
for (const kidRef of require_objects.asArray(resolver.resolve(require_objects.dictGet(node, "Kids"))) ?? []) {
|
|
37
|
+
const kid = resolver.resolveDict(kidRef);
|
|
38
|
+
if (kid !== void 0) readField(kid, name, resolver, pageIndex, sink, children, visited);
|
|
39
|
+
}
|
|
40
|
+
out.push({
|
|
41
|
+
name,
|
|
42
|
+
fieldType: "group",
|
|
43
|
+
widgets: [],
|
|
44
|
+
children
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const flags = require_objects.asNumber(resolver.resolve(require_objects.dictGet(node, "Ff"))) ?? 0;
|
|
49
|
+
const value = fieldValue(node, resolver);
|
|
50
|
+
const options = fieldOptions(node, resolver);
|
|
51
|
+
const alias = annotText(node, "TU");
|
|
52
|
+
const widgets = [];
|
|
53
|
+
for (const kidRef of require_objects.asArray(resolver.resolve(require_objects.dictGet(node, "Kids"))) ?? []) {
|
|
54
|
+
const kid = resolver.resolveDict(kidRef);
|
|
55
|
+
if (kid === void 0 || require_objects.dictGet(kid, "FT") !== void 0) continue;
|
|
56
|
+
const widget = widgetPlacement(kid, pageIndex);
|
|
57
|
+
if (widget !== void 0) widgets.push(widget);
|
|
58
|
+
}
|
|
59
|
+
if (widgets.length === 0 && require_objects.dictGet(node, "Rect") !== void 0) {
|
|
60
|
+
const widget = widgetPlacement(node, pageIndex);
|
|
61
|
+
if (widget !== void 0) widgets.push(widget);
|
|
62
|
+
}
|
|
63
|
+
out.push({
|
|
64
|
+
name,
|
|
65
|
+
fieldType: mapFieldType(fieldType, flags),
|
|
66
|
+
...valueFields(fieldType, value),
|
|
67
|
+
...options !== void 0 ? { options } : {},
|
|
68
|
+
...alias !== void 0 ? { alias } : {},
|
|
69
|
+
...(flags & FLAG_READ_ONLY) !== 0 ? { readOnly: true } : {},
|
|
70
|
+
widgets,
|
|
71
|
+
children: []
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function mapFieldType(fieldType, flags) {
|
|
75
|
+
if (fieldType === "Tx") return "text";
|
|
76
|
+
if (fieldType === "Btn") {
|
|
77
|
+
if ((flags & FLAG_PUSHBUTTON) !== 0) return "button";
|
|
78
|
+
if ((flags & FLAG_RADIO) !== 0) return "radio";
|
|
79
|
+
return "checkbox";
|
|
80
|
+
}
|
|
81
|
+
if (fieldType === "Ch") return (flags & FLAG_COMBO) !== 0 ? "combobox" : "listbox";
|
|
82
|
+
return "signature";
|
|
83
|
+
}
|
|
84
|
+
function valueFields(fieldType, value) {
|
|
85
|
+
if (value === void 0) return {};
|
|
86
|
+
if (fieldType === "Btn") return {
|
|
87
|
+
checked: value !== "Off",
|
|
88
|
+
...value !== "Off" ? { value } : {}
|
|
89
|
+
};
|
|
90
|
+
if (fieldType === "Sig") return {};
|
|
91
|
+
return { value };
|
|
92
|
+
}
|
|
93
|
+
function fieldValue(node, resolver) {
|
|
94
|
+
const value = resolver.resolve(require_objects.dictGet(node, "V"));
|
|
95
|
+
if (value?.kind === "string") return require_pdf_text.decodePdfString(value.bytes);
|
|
96
|
+
if (value?.kind === "name") return value.name;
|
|
97
|
+
if (value?.kind === "number") return String(value.value);
|
|
98
|
+
}
|
|
99
|
+
function fieldOptions(node, resolver) {
|
|
100
|
+
const opts = require_objects.asArray(resolver.resolve(require_objects.dictGet(node, "Opt")));
|
|
101
|
+
if (opts === void 0) return;
|
|
102
|
+
const values = [];
|
|
103
|
+
for (const opt of opts) {
|
|
104
|
+
const resolved = resolver.resolve(opt);
|
|
105
|
+
if (resolved?.kind === "string") values.push(require_pdf_text.decodePdfString(resolved.bytes));
|
|
106
|
+
else if (resolved?.kind === "array") {
|
|
107
|
+
const first = resolved.items[0];
|
|
108
|
+
const exportValue = first?.kind === "string" ? require_pdf_text.decodePdfString(first.bytes) : first?.kind === "name" ? first.name : void 0;
|
|
109
|
+
if (exportValue !== void 0) values.push(exportValue);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return values.length > 0 ? values : void 0;
|
|
113
|
+
}
|
|
114
|
+
function widgetPlacement(widget, pageIndex) {
|
|
115
|
+
const pageNo = pageIndex(require_objects.dictGet(widget, "P"));
|
|
116
|
+
if (pageNo === void 0) return;
|
|
117
|
+
return rectWidget(require_objects.asArray(require_objects.dictGet(widget, "Rect")), pageNo);
|
|
118
|
+
}
|
|
119
|
+
function rectWidget(rect, pageNo) {
|
|
120
|
+
if (rect === void 0) return;
|
|
121
|
+
const x1 = require_objects.asNumber(rect[0]) ?? 0;
|
|
122
|
+
const y1 = require_objects.asNumber(rect[1]) ?? 0;
|
|
123
|
+
const x2 = require_objects.asNumber(rect[2]) ?? 0;
|
|
124
|
+
const y2 = require_objects.asNumber(rect[3]) ?? 0;
|
|
125
|
+
return {
|
|
126
|
+
pageIndex: pageNo,
|
|
127
|
+
xPt: Math.min(x1, x2),
|
|
128
|
+
yPt: Math.min(y1, y2),
|
|
129
|
+
widthPt: Math.abs(x2 - x1),
|
|
130
|
+
heightPt: Math.abs(y2 - y1)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function annotText(dict, key) {
|
|
134
|
+
const obj = require_objects.dictGet(dict, key);
|
|
135
|
+
return obj?.kind === "string" ? require_pdf_text.decodePdfString(obj.bytes) : void 0;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
exports.readAcroForm = readAcroForm;
|
package/dist/form.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
|
+
import { PdfDict } from "./objects.cjs";
|
|
3
|
+
import { PdfObjectResolver } from "./interpret.cjs";
|
|
4
|
+
import { LayoutFormField } from "./layout.cjs";
|
|
5
|
+
import { PageIndexLookup } from "./navigation.cjs";
|
|
6
|
+
//#region src/form.d.ts
|
|
7
|
+
declare function readAcroForm(catalog: PdfDict, resolver: PdfObjectResolver, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): LayoutFormField[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { readAcroForm };
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
|
+
import { PdfDict } from "./objects.js";
|
|
3
|
+
import { PdfObjectResolver } from "./interpret.js";
|
|
4
|
+
import { LayoutFormField } from "./layout.js";
|
|
5
|
+
import { PageIndexLookup } from "./navigation.js";
|
|
6
|
+
//#region src/form.d.ts
|
|
7
|
+
declare function readAcroForm(catalog: PdfDict, resolver: PdfObjectResolver, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): LayoutFormField[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { readAcroForm };
|