@reportwright/pdf 0.1.0-beta.2 → 0.1.0-beta.3
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 +21 -0
- package/dist/index.js +419 -218
- package/examples/bulk.mjs +19 -0
- package/index.d.ts +29 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __export = (target, all) => {
|
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// src/core/sink.js
|
|
17
17
|
function raced(p, signal) {
|
|
18
18
|
if (!signal) return p;
|
|
19
19
|
if (signal.aborted) {
|
|
@@ -112,11 +112,11 @@ function openSink(sink) {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
var init_sink = __esm({
|
|
115
|
-
"
|
|
115
|
+
"src/core/sink.js"() {
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
//
|
|
119
|
+
// src/core/serialize.js
|
|
120
120
|
function latin1(s) {
|
|
121
121
|
const B = (
|
|
122
122
|
/** @type {any} */
|
|
@@ -129,7 +129,7 @@ function latin1(s) {
|
|
|
129
129
|
}
|
|
130
130
|
var num, hex4, utf16, text, ascii, pdfName, UTF8, DELIM, fontName, pdfDate, esc;
|
|
131
131
|
var init_serialize = __esm({
|
|
132
|
-
"
|
|
132
|
+
"src/core/serialize.js"() {
|
|
133
133
|
num = (v) => {
|
|
134
134
|
if (typeof v !== "number" || !(Math.abs(v) < 1e9)) throw new RangeError(`Not a usable number: ${v}`);
|
|
135
135
|
const r = Math.round(v * 1e3) / 1e3;
|
|
@@ -166,7 +166,7 @@ var init_serialize = __esm({
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
//
|
|
169
|
+
// ../../../reportwright/node_modules/fflate/esm/browser.js
|
|
170
170
|
function deflateSync(data, opts) {
|
|
171
171
|
return dopt(data, opts || {}, 0, 0);
|
|
172
172
|
}
|
|
@@ -183,7 +183,7 @@ function zlibSync(data, opts) {
|
|
|
183
183
|
}
|
|
184
184
|
var u8, u16, i32, fleb, fdeb, clim, freb, _a, fl, revfl, _b, fd, revfd, rev, x, i, hMap, flt, i, i, i, i, fdt, i, flm, flrm, fdm, fdrm, max, bits, bits16, shft, slc, ec, err, inflt, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, deo, et, dflt, adler, dopt, wbytes, zlh, zls, Inflate, Unzlib, td, tds;
|
|
185
185
|
var init_browser = __esm({
|
|
186
|
-
"
|
|
186
|
+
"../../../reportwright/node_modules/fflate/esm/browser.js"() {
|
|
187
187
|
u8 = Uint8Array;
|
|
188
188
|
u16 = Uint16Array;
|
|
189
189
|
i32 = Int32Array;
|
|
@@ -956,7 +956,7 @@ var init_browser = __esm({
|
|
|
956
956
|
}
|
|
957
957
|
});
|
|
958
958
|
|
|
959
|
-
//
|
|
959
|
+
// src/core/deflate.js
|
|
960
960
|
async function deflate(bytes) {
|
|
961
961
|
if (slots.free > 0) slots.free--;
|
|
962
962
|
else await new Promise((ok) => slots.wait.push(
|
|
@@ -1044,7 +1044,7 @@ function deflateStream() {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
var NODE_ZLIB, slots;
|
|
1046
1046
|
var init_deflate = __esm({
|
|
1047
|
-
"
|
|
1047
|
+
"src/core/deflate.js"() {
|
|
1048
1048
|
init_browser();
|
|
1049
1049
|
NODE_ZLIB = /** @type {any} */
|
|
1050
1050
|
globalThis.process?.getBuiltinModule?.("node:zlib");
|
|
@@ -1055,7 +1055,7 @@ var init_deflate = __esm({
|
|
|
1055
1055
|
}
|
|
1056
1056
|
});
|
|
1057
1057
|
|
|
1058
|
-
//
|
|
1058
|
+
// src/core/objects.js
|
|
1059
1059
|
function createObjects(out, o) {
|
|
1060
1060
|
let pos = 0, nextNum = 0;
|
|
1061
1061
|
const blocks = [];
|
|
@@ -1335,7 +1335,7 @@ ${xref}
|
|
|
1335
1335
|
}
|
|
1336
1336
|
var CHUNK, OBJSTM, XBITS, XB, BYTERANGE;
|
|
1337
1337
|
var init_objects = __esm({
|
|
1338
|
-
"
|
|
1338
|
+
"src/core/objects.js"() {
|
|
1339
1339
|
init_serialize();
|
|
1340
1340
|
init_deflate();
|
|
1341
1341
|
init_sink();
|
|
@@ -1347,7 +1347,7 @@ var init_objects = __esm({
|
|
|
1347
1347
|
}
|
|
1348
1348
|
});
|
|
1349
1349
|
|
|
1350
|
-
//
|
|
1350
|
+
// src/standards/xmp.js
|
|
1351
1351
|
function checkExt(x2) {
|
|
1352
1352
|
if (!NAME.test(x2.prefix)) throw new TypeError(`XMP: the schema prefix ${JSON.stringify(x2.prefix)} is not an XML name`);
|
|
1353
1353
|
if (typeof x2.ns !== "string" || !/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"'&]{1,256}$/.test(x2.ns)) throw new TypeError(`XMP: the namespace ${JSON.stringify(x2.ns)} is not a URI`);
|
|
@@ -1379,7 +1379,7 @@ ${pdfa ? `<rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/n
|
|
|
1379
1379
|
}
|
|
1380
1380
|
var PRODUCER, xml, NAME, PDFUA;
|
|
1381
1381
|
var init_xmp = __esm({
|
|
1382
|
-
"
|
|
1382
|
+
"src/standards/xmp.js"() {
|
|
1383
1383
|
PRODUCER = "@reportwright/pdf";
|
|
1384
1384
|
xml = (s) => String(s).replace(/[\0-\x08\x0b\x0c\x0e-\x1f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g, "").replace(/[<>&"']/g, (c) => (
|
|
1385
1385
|
/** @type {any} */
|
|
@@ -1396,7 +1396,7 @@ var init_xmp = __esm({
|
|
|
1396
1396
|
}
|
|
1397
1397
|
});
|
|
1398
1398
|
|
|
1399
|
-
//
|
|
1399
|
+
// src/core/brand.js
|
|
1400
1400
|
function brand(obj, kind, doc, data) {
|
|
1401
1401
|
brands.set(obj, { kind, doc, data });
|
|
1402
1402
|
return obj;
|
|
@@ -1457,14 +1457,14 @@ function guarded(api) {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
var brands, kindOf, MAX_SNAPSHOT;
|
|
1459
1459
|
var init_brand = __esm({
|
|
1460
|
-
"
|
|
1460
|
+
"src/core/brand.js"() {
|
|
1461
1461
|
brands = /* @__PURE__ */ new WeakMap();
|
|
1462
1462
|
kindOf = (v) => v !== null && typeof v === "object" ? brands.get(v)?.kind : void 0;
|
|
1463
1463
|
MAX_SNAPSHOT = 16e6;
|
|
1464
1464
|
}
|
|
1465
1465
|
});
|
|
1466
1466
|
|
|
1467
|
-
//
|
|
1467
|
+
// src/document.js
|
|
1468
1468
|
function createDoc(out, o) {
|
|
1469
1469
|
const level = o.pdfaLevel ?? (o.pdfa ? { part: 2, conformance: "b", unicode: false } : null);
|
|
1470
1470
|
const objs = createObjects(out, { compress: o.compress, signal: o.signal, encrypt: o.encrypt, hash: o.hash, classic: level?.part === 1 });
|
|
@@ -1682,7 +1682,7 @@ function createDoc(out, o) {
|
|
|
1682
1682
|
}
|
|
1683
1683
|
var LEAF, IN_FLIGHT;
|
|
1684
1684
|
var init_document = __esm({
|
|
1685
|
-
"
|
|
1685
|
+
"src/document.js"() {
|
|
1686
1686
|
init_objects();
|
|
1687
1687
|
init_deflate();
|
|
1688
1688
|
init_serialize();
|
|
@@ -1693,10 +1693,10 @@ var init_document = __esm({
|
|
|
1693
1693
|
}
|
|
1694
1694
|
});
|
|
1695
1695
|
|
|
1696
|
-
//
|
|
1696
|
+
// src/content/content.js
|
|
1697
1697
|
var Content;
|
|
1698
1698
|
var init_content = __esm({
|
|
1699
|
-
"
|
|
1699
|
+
"src/content/content.js"() {
|
|
1700
1700
|
init_serialize();
|
|
1701
1701
|
Content = class {
|
|
1702
1702
|
constructor() {
|
|
@@ -1855,7 +1855,7 @@ var init_content = __esm({
|
|
|
1855
1855
|
}
|
|
1856
1856
|
});
|
|
1857
1857
|
|
|
1858
|
-
//
|
|
1858
|
+
// src/standards/icc.js
|
|
1859
1859
|
function parseIcc(bytes, what) {
|
|
1860
1860
|
const b = toBytes(bytes, what);
|
|
1861
1861
|
const bad = (m) => new TypeError(`${what}: not a usable ICC profile (${m})`);
|
|
@@ -1887,14 +1887,14 @@ function toBytes(v, what) {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
var MAX_ICC, SPACES, tag;
|
|
1889
1889
|
var init_icc = __esm({
|
|
1890
|
-
"
|
|
1890
|
+
"src/standards/icc.js"() {
|
|
1891
1891
|
MAX_ICC = 32 << 20;
|
|
1892
1892
|
SPACES = /* @__PURE__ */ new Map([["GRAY", 1], ["RGB ", 3], ["CMYK", 4]]);
|
|
1893
1893
|
tag = (b, i2) => String.fromCharCode(b[i2], b[i2 + 1], b[i2 + 2], b[i2 + 3]);
|
|
1894
1894
|
}
|
|
1895
1895
|
});
|
|
1896
1896
|
|
|
1897
|
-
//
|
|
1897
|
+
// src/graphics/color.js
|
|
1898
1898
|
function cmyk(c, m, y, k) {
|
|
1899
1899
|
const v = [c, m, y, k];
|
|
1900
1900
|
if (!v.every(unit)) throw new RangeError(`cmyk(c, m, y, k): each is 0–1, not ${v.join(", ")}`);
|
|
@@ -1977,7 +1977,7 @@ async function iccColorSpace(doc, bytes) {
|
|
|
1977
1977
|
}
|
|
1978
1978
|
var DEVICE, unit, CSS_RGB, base, spots;
|
|
1979
1979
|
var init_color = __esm({
|
|
1980
|
-
"
|
|
1980
|
+
"src/graphics/color.js"() {
|
|
1981
1981
|
init_serialize();
|
|
1982
1982
|
init_brand();
|
|
1983
1983
|
init_icc();
|
|
@@ -1989,7 +1989,7 @@ var init_color = __esm({
|
|
|
1989
1989
|
}
|
|
1990
1990
|
});
|
|
1991
1991
|
|
|
1992
|
-
//
|
|
1992
|
+
// src/text/runs.js
|
|
1993
1993
|
function spacing(o) {
|
|
1994
1994
|
const tc = o?.characterSpacing ?? 0, tw = o?.wordSpacing ?? 0, tz = o?.horizontalScaling ?? 100;
|
|
1995
1995
|
num(tc);
|
|
@@ -2124,7 +2124,7 @@ function runOps(run2, size, rise, tw, standard, tc = 0) {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
var WS, RTL_RANGES, dirOf, maybeRtl, RTL, LTR;
|
|
2126
2126
|
var init_runs = __esm({
|
|
2127
|
-
"
|
|
2127
|
+
"src/text/runs.js"() {
|
|
2128
2128
|
init_serialize();
|
|
2129
2129
|
WS = /^\s$/u;
|
|
2130
2130
|
RTL_RANGES = "-ࣿיִ-﷿ﹰ-\uFEFF";
|
|
@@ -2138,7 +2138,7 @@ var init_runs = __esm({
|
|
|
2138
2138
|
}
|
|
2139
2139
|
});
|
|
2140
2140
|
|
|
2141
|
-
//
|
|
2141
|
+
// src/text/text.js
|
|
2142
2142
|
function fontsOf(page, o, who) {
|
|
2143
2143
|
const font = o?.font;
|
|
2144
2144
|
if (!font || typeof font.encode !== "function") throw new TypeError(`${who}: options.font is required (pdf.standardFont(name) or await pdf.embedFont(bytes))`);
|
|
@@ -2207,7 +2207,7 @@ function text2(str3, o) {
|
|
|
2207
2207
|
}
|
|
2208
2208
|
var MAX_TEXT, MODES, PLAIN, PLAIN_STATE;
|
|
2209
2209
|
var init_text = __esm({
|
|
2210
|
-
"
|
|
2210
|
+
"src/text/text.js"() {
|
|
2211
2211
|
init_color();
|
|
2212
2212
|
init_serialize();
|
|
2213
2213
|
init_brand();
|
|
@@ -2219,7 +2219,7 @@ var init_text = __esm({
|
|
|
2219
2219
|
}
|
|
2220
2220
|
});
|
|
2221
2221
|
|
|
2222
|
-
//
|
|
2222
|
+
// src/text/box.js
|
|
2223
2223
|
function textBox(str3, o) {
|
|
2224
2224
|
const fonts = fontsOf(this, o, "page.textBox");
|
|
2225
2225
|
const size = o.size ?? 12, x2 = o.x ?? 0, y = o.y ?? 0, W = o.width;
|
|
@@ -2266,12 +2266,12 @@ function textBox(str3, o) {
|
|
|
2266
2266
|
s = -1;
|
|
2267
2267
|
lw = 0;
|
|
2268
2268
|
};
|
|
2269
|
-
for (const
|
|
2269
|
+
for (const word2 of para.split(" ")) {
|
|
2270
2270
|
if (lines.length > stop) break paras;
|
|
2271
|
-
const ws = q, we = q +
|
|
2271
|
+
const ws = q, we = q + word2.length;
|
|
2272
2272
|
q = we + 1;
|
|
2273
|
-
if (!
|
|
2274
|
-
const ww = width(
|
|
2273
|
+
if (!word2 && s < 0) continue;
|
|
2274
|
+
const ww = width(word2);
|
|
2275
2275
|
if (s >= 0) {
|
|
2276
2276
|
const add2 = width(" ") + ww;
|
|
2277
2277
|
if (lw + add2 <= W + EPS2) {
|
|
@@ -2280,7 +2280,7 @@ function textBox(str3, o) {
|
|
|
2280
2280
|
continue;
|
|
2281
2281
|
}
|
|
2282
2282
|
commit(false);
|
|
2283
|
-
if (!
|
|
2283
|
+
if (!word2) continue;
|
|
2284
2284
|
}
|
|
2285
2285
|
s = ws;
|
|
2286
2286
|
e = we;
|
|
@@ -2288,7 +2288,7 @@ function textBox(str3, o) {
|
|
|
2288
2288
|
if (lw <= W + EPS2) continue;
|
|
2289
2289
|
let acc = 0;
|
|
2290
2290
|
e = s;
|
|
2291
|
-
for (const ch of
|
|
2291
|
+
for (const ch of word2) {
|
|
2292
2292
|
const cw = width(ch);
|
|
2293
2293
|
if (acc + cw > W + EPS2 && e > s) {
|
|
2294
2294
|
if (lines.length > stop) break paras;
|
|
@@ -2343,7 +2343,7 @@ function textBox(str3, o) {
|
|
|
2343
2343
|
}
|
|
2344
2344
|
var MAX_LINES;
|
|
2345
2345
|
var init_box = __esm({
|
|
2346
|
-
"
|
|
2346
|
+
"src/text/box.js"() {
|
|
2347
2347
|
init_serialize();
|
|
2348
2348
|
init_runs();
|
|
2349
2349
|
init_text();
|
|
@@ -2351,7 +2351,7 @@ var init_box = __esm({
|
|
|
2351
2351
|
}
|
|
2352
2352
|
});
|
|
2353
2353
|
|
|
2354
|
-
//
|
|
2354
|
+
// src/graphics/svg.js
|
|
2355
2355
|
function parseSvgPath(d, path2) {
|
|
2356
2356
|
if (typeof d !== "string") throw new TypeError("svgPath: the path data is a string");
|
|
2357
2357
|
if (d.length > MAX_SVG) throw new RangeError(`svgPath: the path data is ${d.length} characters; at most ${MAX_SVG} (10 MB)`);
|
|
@@ -2515,7 +2515,7 @@ function arc(path2, x0, y0, rx, ry, phi, large, sweep, x2, y) {
|
|
|
2515
2515
|
}
|
|
2516
2516
|
var MAX_SVG, ARGS;
|
|
2517
2517
|
var init_svg = __esm({
|
|
2518
|
-
"
|
|
2518
|
+
"src/graphics/svg.js"() {
|
|
2519
2519
|
init_path();
|
|
2520
2520
|
MAX_SVG = 10 * 1024 * 1024;
|
|
2521
2521
|
ARGS = /** @type {Record<string, number>} */
|
|
@@ -2523,14 +2523,14 @@ var init_svg = __esm({
|
|
|
2523
2523
|
}
|
|
2524
2524
|
});
|
|
2525
2525
|
|
|
2526
|
-
//
|
|
2526
|
+
// src/graphics/path.js
|
|
2527
2527
|
function coord(v, what) {
|
|
2528
2528
|
if (typeof v !== "number" || !(Math.abs(v) < 1e9)) throw new RangeError(`${what}: ${v} is not a usable number (finite, under 1e9 in size)`);
|
|
2529
2529
|
return v;
|
|
2530
2530
|
}
|
|
2531
2531
|
var MAX_SEGMENTS, TAU, Path;
|
|
2532
2532
|
var init_path = __esm({
|
|
2533
|
-
"
|
|
2533
|
+
"src/graphics/path.js"() {
|
|
2534
2534
|
init_serialize();
|
|
2535
2535
|
init_svg();
|
|
2536
2536
|
MAX_SEGMENTS = 1e6;
|
|
@@ -2743,7 +2743,7 @@ var init_path = __esm({
|
|
|
2743
2743
|
}
|
|
2744
2744
|
});
|
|
2745
2745
|
|
|
2746
|
-
//
|
|
2746
|
+
// src/graphics/paint.js
|
|
2747
2747
|
function oneSpace(cols, doc) {
|
|
2748
2748
|
const r = cols.map((c) => resolve(c, doc));
|
|
2749
2749
|
if (r.every((x2) => x2.cs === DEVICE[1] || x2.cs === DEVICE[3]) && r.some((x2) => x2.cs === DEVICE[3])) {
|
|
@@ -2849,7 +2849,7 @@ function tilingPattern(o, draw) {
|
|
|
2849
2849
|
}
|
|
2850
2850
|
var MAX_STOPS, shading, base2;
|
|
2851
2851
|
var init_paint = __esm({
|
|
2852
|
-
"
|
|
2852
|
+
"src/graphics/paint.js"() {
|
|
2853
2853
|
init_serialize();
|
|
2854
2854
|
init_color();
|
|
2855
2855
|
init_draw();
|
|
@@ -2860,7 +2860,7 @@ var init_paint = __esm({
|
|
|
2860
2860
|
}
|
|
2861
2861
|
});
|
|
2862
2862
|
|
|
2863
|
-
//
|
|
2863
|
+
// src/standards/level.js
|
|
2864
2864
|
function pdfaLevel(pdfa, tagged) {
|
|
2865
2865
|
if (pdfa == null || pdfa === false) return null;
|
|
2866
2866
|
if (pdfa === true) return { part: 2, conformance: "b", unicode: false };
|
|
@@ -2877,11 +2877,11 @@ function refuseInA1(doc, what, why) {
|
|
|
2877
2877
|
if (d.pdfaLevel?.part === 1) throw new TypeError(`${what}: PDF/A-1 (ISO 19005-1) ${why}; use PDF/A-2 or 3 (pdfa: { part: 2 })`);
|
|
2878
2878
|
}
|
|
2879
2879
|
var init_level = __esm({
|
|
2880
|
-
"
|
|
2880
|
+
"src/standards/level.js"() {
|
|
2881
2881
|
}
|
|
2882
2882
|
});
|
|
2883
2883
|
|
|
2884
|
-
//
|
|
2884
|
+
// src/graphics/draw.js
|
|
2885
2885
|
function state(page) {
|
|
2886
2886
|
let s = states.get(page);
|
|
2887
2887
|
if (!s) states.set(page, s = { m: [1, 0, 0, 1, 0, 0], stack: [], transparent: false, watched: false });
|
|
@@ -3066,7 +3066,7 @@ function figure(o, fn) {
|
|
|
3066
3066
|
}
|
|
3067
3067
|
var MAX_DEPTH, MAX_DEPTH_PDFA, MAX_DASH, BLEND_MODES, BLEND, CAPS, JOINS, GROUP, states, mul, flip, num6, matrix, rule;
|
|
3068
3068
|
var init_draw = __esm({
|
|
3069
|
-
"
|
|
3069
|
+
"src/graphics/draw.js"() {
|
|
3070
3070
|
init_serialize();
|
|
3071
3071
|
init_path();
|
|
3072
3072
|
init_paint();
|
|
@@ -3098,7 +3098,7 @@ var init_draw = __esm({
|
|
|
3098
3098
|
}
|
|
3099
3099
|
});
|
|
3100
3100
|
|
|
3101
|
-
//
|
|
3101
|
+
// src/graphics/shapes.js
|
|
3102
3102
|
function line(x1, y1, x2, y2, o = {}) {
|
|
3103
3103
|
const c = this.content, H = this.height;
|
|
3104
3104
|
const gs = gstate(this, o);
|
|
@@ -3138,14 +3138,14 @@ function rect(x2, y, w, h, o = {}) {
|
|
|
3138
3138
|
return this;
|
|
3139
3139
|
}
|
|
3140
3140
|
var init_shapes = __esm({
|
|
3141
|
-
"
|
|
3141
|
+
"src/graphics/shapes.js"() {
|
|
3142
3142
|
init_serialize();
|
|
3143
3143
|
init_color();
|
|
3144
3144
|
init_draw();
|
|
3145
3145
|
}
|
|
3146
3146
|
});
|
|
3147
3147
|
|
|
3148
|
-
//
|
|
3148
|
+
// src/nav/trees.js
|
|
3149
3149
|
async function writeTree(doc, kind, entries) {
|
|
3150
3150
|
let level = [];
|
|
3151
3151
|
for (let i2 = 0; i2 < entries.length; i2 += LEAF2) {
|
|
@@ -3173,14 +3173,14 @@ function setNames(doc, key, ref) {
|
|
|
3173
3173
|
}
|
|
3174
3174
|
var LEAF2, names;
|
|
3175
3175
|
var init_trees = __esm({
|
|
3176
|
-
"
|
|
3176
|
+
"src/nav/trees.js"() {
|
|
3177
3177
|
init_serialize();
|
|
3178
3178
|
LEAF2 = 64;
|
|
3179
3179
|
names = /* @__PURE__ */ new WeakMap();
|
|
3180
3180
|
}
|
|
3181
3181
|
});
|
|
3182
3182
|
|
|
3183
|
-
//
|
|
3183
|
+
// src/nav/dest.js
|
|
3184
3184
|
function pageIndex(doc, page, who) {
|
|
3185
3185
|
if (typeof page === "number") {
|
|
3186
3186
|
if (!(Number.isInteger(page) && page >= 1)) throw new RangeError(`${who}: page is a whole number from 1`);
|
|
@@ -3274,7 +3274,7 @@ function create(doc) {
|
|
|
3274
3274
|
}
|
|
3275
3275
|
var FITS, MAX_NAMES, MAX_NAME_BYTES, UTF82, hexOf, registries;
|
|
3276
3276
|
var init_dest = __esm({
|
|
3277
|
-
"
|
|
3277
|
+
"src/nav/dest.js"() {
|
|
3278
3278
|
init_serialize();
|
|
3279
3279
|
init_brand();
|
|
3280
3280
|
init_trees();
|
|
@@ -3291,7 +3291,7 @@ var init_dest = __esm({
|
|
|
3291
3291
|
}
|
|
3292
3292
|
});
|
|
3293
3293
|
|
|
3294
|
-
//
|
|
3294
|
+
// src/nav/links.js
|
|
3295
3295
|
function checkUrl(raw, allow, who) {
|
|
3296
3296
|
if (typeof raw !== "string") throw new TypeError(`${who}: url is a string`);
|
|
3297
3297
|
if (raw.length > MAX_URL) throw new RangeError(`${who}: a URL is at most ${MAX_URL} characters`);
|
|
@@ -3415,7 +3415,7 @@ function dashArray(d, who) {
|
|
|
3415
3415
|
}
|
|
3416
3416
|
var NEVER, DEFAULT_SCHEMES, ACTIVE, NAMED, MAX_URL, MAX_QUADS, HIGHLIGHT, BORDER;
|
|
3417
3417
|
var init_links = __esm({
|
|
3418
|
-
"
|
|
3418
|
+
"src/nav/links.js"() {
|
|
3419
3419
|
init_serialize();
|
|
3420
3420
|
init_color();
|
|
3421
3421
|
init_dest();
|
|
@@ -3430,7 +3430,7 @@ var init_links = __esm({
|
|
|
3430
3430
|
}
|
|
3431
3431
|
});
|
|
3432
3432
|
|
|
3433
|
-
//
|
|
3433
|
+
// src/images/png.js
|
|
3434
3434
|
function crc32(b, from, to) {
|
|
3435
3435
|
if (!CRC_TABLE) {
|
|
3436
3436
|
CRC_TABLE = new Uint32Array(256);
|
|
@@ -3748,7 +3748,7 @@ async function decodePng(p, maxDecoded = MAX_DECODED) {
|
|
|
3748
3748
|
}
|
|
3749
3749
|
var MAX_SIDE, MAX_PIXELS, MAX_DECODED, STEP, NODE_ZLIB2, SYNC_MAX, DEPTHS, CHANNELS, ADAM7, CRC_TABLE, isPng, rawSize, filterBytes;
|
|
3750
3750
|
var init_png = __esm({
|
|
3751
|
-
"
|
|
3751
|
+
"src/images/png.js"() {
|
|
3752
3752
|
init_browser();
|
|
3753
3753
|
MAX_SIDE = 65535;
|
|
3754
3754
|
MAX_PIXELS = 1e8;
|
|
@@ -3773,7 +3773,7 @@ var init_png = __esm({
|
|
|
3773
3773
|
}
|
|
3774
3774
|
});
|
|
3775
3775
|
|
|
3776
|
-
//
|
|
3776
|
+
// src/images/jpeg.js
|
|
3777
3777
|
function readJpeg(b) {
|
|
3778
3778
|
const bad = (m) => new TypeError(`JPEG: ${m}`);
|
|
3779
3779
|
if (!isJpeg(b)) throw bad("no JPEG signature (FF D8)");
|
|
@@ -3844,13 +3844,13 @@ function exifOrientation(b, t, end) {
|
|
|
3844
3844
|
}
|
|
3845
3845
|
var isJpeg;
|
|
3846
3846
|
var init_jpeg = __esm({
|
|
3847
|
-
"
|
|
3847
|
+
"src/images/jpeg.js"() {
|
|
3848
3848
|
init_png();
|
|
3849
3849
|
isJpeg = (b) => b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255;
|
|
3850
3850
|
}
|
|
3851
3851
|
});
|
|
3852
3852
|
|
|
3853
|
-
//
|
|
3853
|
+
// src/images/image.js
|
|
3854
3854
|
async function embedImage(doc, bytes, opt = {}) {
|
|
3855
3855
|
const b = toBytes(bytes, "embedImage");
|
|
3856
3856
|
const own2 = (k2) => opt != null && Object.hasOwn(opt, k2) ? (
|
|
@@ -4017,7 +4017,7 @@ function image(img, o = {}) {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
var MAX_INPUT, ORIENT, SEEN, IDS, nextId, idOf, NODE_CRYPTO, same;
|
|
4019
4019
|
var init_image = __esm({
|
|
4020
|
-
"
|
|
4020
|
+
"src/images/image.js"() {
|
|
4021
4021
|
init_serialize();
|
|
4022
4022
|
init_deflate();
|
|
4023
4023
|
init_brand();
|
|
@@ -4055,7 +4055,7 @@ var init_image = __esm({
|
|
|
4055
4055
|
}
|
|
4056
4056
|
});
|
|
4057
4057
|
|
|
4058
|
-
//
|
|
4058
|
+
// src/annotations/annot.js
|
|
4059
4059
|
function dateOf(d, who) {
|
|
4060
4060
|
if (!(d instanceof Date) || isNaN(+d)) throw new TypeError(`${who}: a date is a valid Date`);
|
|
4061
4061
|
return pdfDate(d);
|
|
@@ -4126,7 +4126,7 @@ function addAnnot(page, subtype, box, own2, common, draw) {
|
|
|
4126
4126
|
}
|
|
4127
4127
|
var FLAGS, MAX_CONTENTS, no;
|
|
4128
4128
|
var init_annot = __esm({
|
|
4129
|
-
"
|
|
4129
|
+
"src/annotations/annot.js"() {
|
|
4130
4130
|
init_serialize();
|
|
4131
4131
|
init_brand();
|
|
4132
4132
|
init_content();
|
|
@@ -4139,7 +4139,7 @@ var init_annot = __esm({
|
|
|
4139
4139
|
}
|
|
4140
4140
|
});
|
|
4141
4141
|
|
|
4142
|
-
//
|
|
4142
|
+
// src/annotations/markup.js
|
|
4143
4143
|
function boxOf(o, who) {
|
|
4144
4144
|
const b = [o?.x ?? 0, o?.y ?? 0, o?.width, o?.height];
|
|
4145
4145
|
for (const v of b) if (typeof v !== "number") throw new TypeError(`${who}: x, y, width and height are numbers`);
|
|
@@ -4342,7 +4342,7 @@ function stamp(o) {
|
|
|
4342
4342
|
}
|
|
4343
4343
|
var NOTE_ICONS, STAMPS, LINE_ENDINGS, MAX_POINTS, MAX_STROKES, dflt2, highlight, underline, strikeOut, squiggly, asciiHex;
|
|
4344
4344
|
var init_markup = __esm({
|
|
4345
|
-
"
|
|
4345
|
+
"src/annotations/markup.js"() {
|
|
4346
4346
|
init_serialize();
|
|
4347
4347
|
init_brand();
|
|
4348
4348
|
init_color();
|
|
@@ -4366,7 +4366,7 @@ var init_markup = __esm({
|
|
|
4366
4366
|
}
|
|
4367
4367
|
});
|
|
4368
4368
|
|
|
4369
|
-
//
|
|
4369
|
+
// src/core/filename.js
|
|
4370
4370
|
function checkFileName(raw, o, who, again = false) {
|
|
4371
4371
|
if (typeof raw !== "string") throw new TypeError(`${who}: name (the file name) is a string`);
|
|
4372
4372
|
if (raw.length > MAX_IN) throw new RangeError(`${who}: a file name is at most ${MAX_BYTES} bytes (UTF-8)`);
|
|
@@ -4425,7 +4425,7 @@ function check(name, allow, risky, o, who) {
|
|
|
4425
4425
|
}
|
|
4426
4426
|
var MAX_IN, MAX_BYTES, BAD, SPACES2, SLASHES, DOTS, DEVICE2, PASSIVE, MIMES, UTF83;
|
|
4427
4427
|
var init_filename = __esm({
|
|
4428
|
-
"
|
|
4428
|
+
"src/core/filename.js"() {
|
|
4429
4429
|
MAX_IN = 4096;
|
|
4430
4430
|
MAX_BYTES = 255;
|
|
4431
4431
|
BAD = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}<>:"|?*]/u;
|
|
@@ -4463,7 +4463,7 @@ var init_filename = __esm({
|
|
|
4463
4463
|
}
|
|
4464
4464
|
});
|
|
4465
4465
|
|
|
4466
|
-
//
|
|
4466
|
+
// src/core/md5.js
|
|
4467
4467
|
function md5(bytes) {
|
|
4468
4468
|
const n = bytes.length, total = (n + 8 >>> 6) + 1 << 6;
|
|
4469
4469
|
const tail = new Uint8Array(total - (n & ~63));
|
|
@@ -4514,7 +4514,7 @@ function md5(bytes) {
|
|
|
4514
4514
|
}
|
|
4515
4515
|
var S, K;
|
|
4516
4516
|
var init_md5 = __esm({
|
|
4517
|
-
"
|
|
4517
|
+
"src/core/md5.js"() {
|
|
4518
4518
|
S = [
|
|
4519
4519
|
7,
|
|
4520
4520
|
12,
|
|
@@ -4585,7 +4585,7 @@ var init_md5 = __esm({
|
|
|
4585
4585
|
}
|
|
4586
4586
|
});
|
|
4587
4587
|
|
|
4588
|
-
//
|
|
4588
|
+
// src/annotations/attach.js
|
|
4589
4589
|
function attachFile(bytes, o = (
|
|
4590
4590
|
/** @type {any} */
|
|
4591
4591
|
{}
|
|
@@ -4621,7 +4621,7 @@ function attachFile(bytes, o = (
|
|
|
4621
4621
|
}
|
|
4622
4622
|
var FILE_ICONS, MAX_FILE;
|
|
4623
4623
|
var init_attach = __esm({
|
|
4624
|
-
"
|
|
4624
|
+
"src/annotations/attach.js"() {
|
|
4625
4625
|
init_serialize();
|
|
4626
4626
|
init_filename();
|
|
4627
4627
|
init_md5();
|
|
@@ -4631,7 +4631,7 @@ var init_attach = __esm({
|
|
|
4631
4631
|
}
|
|
4632
4632
|
});
|
|
4633
4633
|
|
|
4634
|
-
//
|
|
4634
|
+
// src/standards/layers.js
|
|
4635
4635
|
function createLayers(doc) {
|
|
4636
4636
|
const all = [];
|
|
4637
4637
|
doc.onFinish(async () => {
|
|
@@ -4693,7 +4693,7 @@ function pageLayer(layer, fn) {
|
|
|
4693
4693
|
}
|
|
4694
4694
|
var MAX_LAYERS, MAX_NEST, depth;
|
|
4695
4695
|
var init_layers = __esm({
|
|
4696
|
-
"
|
|
4696
|
+
"src/standards/layers.js"() {
|
|
4697
4697
|
init_serialize();
|
|
4698
4698
|
init_brand();
|
|
4699
4699
|
init_level();
|
|
@@ -4704,7 +4704,7 @@ var init_layers = __esm({
|
|
|
4704
4704
|
}
|
|
4705
4705
|
});
|
|
4706
4706
|
|
|
4707
|
-
//
|
|
4707
|
+
// src/tags/tags.js
|
|
4708
4708
|
function createTagger(doc, opt) {
|
|
4709
4709
|
const rootRef = doc.reserve(), docRef = doc.reserve();
|
|
4710
4710
|
const docKids = [];
|
|
@@ -4913,7 +4913,7 @@ function artifact(o, fn) {
|
|
|
4913
4913
|
}
|
|
4914
4914
|
var STRUCTURE_TYPES, ART, PARENTS, NUMBERING, ARTIFACT_TYPES, ARTIFACT_SUBTYPES, MAX_TEXT2, MAX_IDS, str, idOf2;
|
|
4915
4915
|
var init_tags = __esm({
|
|
4916
|
-
"
|
|
4916
|
+
"src/tags/tags.js"() {
|
|
4917
4917
|
init_serialize();
|
|
4918
4918
|
init_trees();
|
|
4919
4919
|
init_brand();
|
|
@@ -5003,7 +5003,7 @@ var init_tags = __esm({
|
|
|
5003
5003
|
}
|
|
5004
5004
|
});
|
|
5005
5005
|
|
|
5006
|
-
//
|
|
5006
|
+
// src/page.js
|
|
5007
5007
|
function install(methods) {
|
|
5008
5008
|
for (const [name, f] of Object.entries(methods)) {
|
|
5009
5009
|
Page.prototype[name] = function(...a) {
|
|
@@ -5014,7 +5014,7 @@ function install(methods) {
|
|
|
5014
5014
|
}
|
|
5015
5015
|
var MAX_ANNOTS, Page;
|
|
5016
5016
|
var init_page = __esm({
|
|
5017
|
-
"
|
|
5017
|
+
"src/page.js"() {
|
|
5018
5018
|
init_content();
|
|
5019
5019
|
init_brand();
|
|
5020
5020
|
init_text();
|
|
@@ -5091,10 +5091,10 @@ var init_page = __esm({
|
|
|
5091
5091
|
}
|
|
5092
5092
|
});
|
|
5093
5093
|
|
|
5094
|
-
//
|
|
5094
|
+
// src/fonts/standard-metrics.js
|
|
5095
5095
|
var ENCODINGS, METRICS;
|
|
5096
5096
|
var init_standard_metrics = __esm({
|
|
5097
|
-
"
|
|
5097
|
+
"src/fonts/standard-metrics.js"() {
|
|
5098
5098
|
ENCODINGS = {
|
|
5099
5099
|
WinAnsi: [
|
|
5100
5100
|
32,
|
|
@@ -10116,7 +10116,7 @@ var init_standard_metrics = __esm({
|
|
|
10116
10116
|
}
|
|
10117
10117
|
});
|
|
10118
10118
|
|
|
10119
|
-
//
|
|
10119
|
+
// src/fonts/standard.js
|
|
10120
10120
|
function standardFont(doc, key) {
|
|
10121
10121
|
const m = typeof key === "string" && Object.hasOwn(METRICS, key) ? (
|
|
10122
10122
|
/** @type {any} */
|
|
@@ -10246,7 +10246,7 @@ function standardFont(doc, key) {
|
|
|
10246
10246
|
}
|
|
10247
10247
|
var STANDARD_NAMES, CODE;
|
|
10248
10248
|
var init_standard = __esm({
|
|
10249
|
-
"
|
|
10249
|
+
"src/fonts/standard.js"() {
|
|
10250
10250
|
init_brand();
|
|
10251
10251
|
init_standard_metrics();
|
|
10252
10252
|
init_serialize();
|
|
@@ -10257,7 +10257,7 @@ var init_standard = __esm({
|
|
|
10257
10257
|
}
|
|
10258
10258
|
});
|
|
10259
10259
|
|
|
10260
|
-
//
|
|
10260
|
+
// src/fonts/truetype.js
|
|
10261
10261
|
function sfntTables(bytes) {
|
|
10262
10262
|
if (bytes.length < 12) throw new TypeError("Not a font: too short");
|
|
10263
10263
|
const v = tagOf(bytes, 0);
|
|
@@ -10434,14 +10434,14 @@ function cmapLookup(dv) {
|
|
|
10434
10434
|
}
|
|
10435
10435
|
var broken, tagOf, view;
|
|
10436
10436
|
var init_truetype = __esm({
|
|
10437
|
-
"
|
|
10437
|
+
"src/fonts/truetype.js"() {
|
|
10438
10438
|
broken = (why) => new TypeError(`Broken font: ${why}`);
|
|
10439
10439
|
tagOf = (b, p) => String.fromCharCode(b[p], b[p + 1], b[p + 2], b[p + 3]);
|
|
10440
10440
|
view = (b) => new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
10441
10441
|
}
|
|
10442
10442
|
});
|
|
10443
10443
|
|
|
10444
|
-
//
|
|
10444
|
+
// src/fonts/subset.js
|
|
10445
10445
|
function subsetGlyf(bytes, glyphs2) {
|
|
10446
10446
|
const t = sfntTables(bytes);
|
|
10447
10447
|
const head = t.get("head"), loca = t.get("loca"), glyf = t.get("glyf"), maxp = t.get("maxp");
|
|
@@ -10537,7 +10537,7 @@ function buildSfnt(tables, version = [0, 1, 0, 0]) {
|
|
|
10537
10537
|
}
|
|
10538
10538
|
var KEEP, tableSum;
|
|
10539
10539
|
var init_subset = __esm({
|
|
10540
|
-
"
|
|
10540
|
+
"src/fonts/subset.js"() {
|
|
10541
10541
|
init_truetype();
|
|
10542
10542
|
KEEP = ["head", "hhea", "hmtx", "maxp", "cvt ", "fpgm", "prep", "OS/2", "name", "gasp"];
|
|
10543
10543
|
tableSum = (b, o, len) => {
|
|
@@ -10549,7 +10549,7 @@ var init_subset = __esm({
|
|
|
10549
10549
|
}
|
|
10550
10550
|
});
|
|
10551
10551
|
|
|
10552
|
-
//
|
|
10552
|
+
// src/fonts/cff.js
|
|
10553
10553
|
function readIndex(t, p, what) {
|
|
10554
10554
|
if (p + 2 > t.length) throw broken2(`the CFF ${what} INDEX lies outside the table`);
|
|
10555
10555
|
const count = t[p] << 8 | t[p + 1];
|
|
@@ -10812,7 +10812,7 @@ function identityCharset(t, n) {
|
|
|
10812
10812
|
}
|
|
10813
10813
|
var broken2, MAX_STACK, MAX_DEPTH2, MAX_CS, BUDGET, FONT_BUDGET, bias;
|
|
10814
10814
|
var init_cff = __esm({
|
|
10815
|
-
"
|
|
10815
|
+
"src/fonts/cff.js"() {
|
|
10816
10816
|
broken2 = (why) => new TypeError(`Broken font: ${why}`);
|
|
10817
10817
|
MAX_STACK = 48;
|
|
10818
10818
|
MAX_DEPTH2 = 10;
|
|
@@ -10823,7 +10823,7 @@ var init_cff = __esm({
|
|
|
10823
10823
|
}
|
|
10824
10824
|
});
|
|
10825
10825
|
|
|
10826
|
-
//
|
|
10826
|
+
// src/fonts/kern.js
|
|
10827
10827
|
function kerning(tables, numGlyphs, warn) {
|
|
10828
10828
|
const gpos = tables.get("GPOS"), kern = tables.get("kern");
|
|
10829
10829
|
if (gpos) {
|
|
@@ -11058,7 +11058,7 @@ function kernTable(t, numGlyphs) {
|
|
|
11058
11058
|
}
|
|
11059
11059
|
var broken3, MAX_SUBTABLES, BUDGET2, vsize;
|
|
11060
11060
|
var init_kern = __esm({
|
|
11061
|
-
"
|
|
11061
|
+
"src/fonts/kern.js"() {
|
|
11062
11062
|
broken3 = (why) => new TypeError(`Broken font: ${why}`);
|
|
11063
11063
|
MAX_SUBTABLES = 64;
|
|
11064
11064
|
BUDGET2 = 4e6;
|
|
@@ -11070,12 +11070,14 @@ var init_kern = __esm({
|
|
|
11070
11070
|
}
|
|
11071
11071
|
});
|
|
11072
11072
|
|
|
11073
|
-
//
|
|
11073
|
+
// src/fonts/embed.js
|
|
11074
11074
|
function embedFont(doc, input, opt = {}) {
|
|
11075
11075
|
const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
11076
11076
|
const f = parseFont(bytes);
|
|
11077
11077
|
const shaper = opt.shaper;
|
|
11078
11078
|
if (shaper != null && typeof shaper !== "function") throw new TypeError("embedFont: shaper is a function (text, font, { direction, kerning }) => glyphs");
|
|
11079
|
+
const textMapping = opt.textMapping ?? "carrier";
|
|
11080
|
+
if (textMapping !== "carrier" && textMapping !== "actualText") throw new TypeError(`embedFont: textMapping is 'carrier' or 'actualText', not ${JSON.stringify(textMapping)}`);
|
|
11079
11081
|
const cffTable = f.tables.get("CFF ");
|
|
11080
11082
|
const parsed = cffTable ? parseCff(cffTable, f.numGlyphs) : null, cidKeyed = !!parsed?.cids;
|
|
11081
11083
|
const sub = opt.subset ?? true;
|
|
@@ -11269,7 +11271,7 @@ function embedFont(doc, input, opt = {}) {
|
|
|
11269
11271
|
flow[0].n = flow.length;
|
|
11270
11272
|
if (glue) glued = flow[0];
|
|
11271
11273
|
}
|
|
11272
|
-
if (li >= 0 && !out[li].c) out[li].b = two(code(gl[lead].g, "")[0]);
|
|
11274
|
+
if (textMapping === "actualText" && li >= 0 && !out[li].c) out[li].b = two(code(gl[lead].g, "")[0]);
|
|
11273
11275
|
} else if (glue) glued = /** @type {any} */
|
|
11274
11276
|
{};
|
|
11275
11277
|
i2 = j;
|
|
@@ -11453,7 +11455,7 @@ function tag2(bytes) {
|
|
|
11453
11455
|
}
|
|
11454
11456
|
var OTF_KEEP;
|
|
11455
11457
|
var init_embed = __esm({
|
|
11456
|
-
"
|
|
11458
|
+
"src/fonts/embed.js"() {
|
|
11457
11459
|
init_brand();
|
|
11458
11460
|
init_truetype();
|
|
11459
11461
|
init_subset();
|
|
@@ -11465,7 +11467,7 @@ var init_embed = __esm({
|
|
|
11465
11467
|
}
|
|
11466
11468
|
});
|
|
11467
11469
|
|
|
11468
|
-
//
|
|
11470
|
+
// src/nav/outline.js
|
|
11469
11471
|
function colorOf(c) {
|
|
11470
11472
|
if (c == null) return "";
|
|
11471
11473
|
const d = device(c);
|
|
@@ -11546,7 +11548,7 @@ function createOutline(doc) {
|
|
|
11546
11548
|
}
|
|
11547
11549
|
var MAX_ENTRIES, MAX_LEVEL, MAX_TITLE;
|
|
11548
11550
|
var init_outline = __esm({
|
|
11549
|
-
"
|
|
11551
|
+
"src/nav/outline.js"() {
|
|
11550
11552
|
init_serialize();
|
|
11551
11553
|
init_color();
|
|
11552
11554
|
init_dest();
|
|
@@ -11556,7 +11558,7 @@ var init_outline = __esm({
|
|
|
11556
11558
|
}
|
|
11557
11559
|
});
|
|
11558
11560
|
|
|
11559
|
-
//
|
|
11561
|
+
// src/nav/labels.js
|
|
11560
11562
|
function createPageLabels(doc) {
|
|
11561
11563
|
let ranges = null;
|
|
11562
11564
|
doc.onFinish(async () => {
|
|
@@ -11587,7 +11589,7 @@ function createPageLabels(doc) {
|
|
|
11587
11589
|
}
|
|
11588
11590
|
var STYLES, MAX_RANGES, MAX_PREFIX;
|
|
11589
11591
|
var init_labels = __esm({
|
|
11590
|
-
"
|
|
11592
|
+
"src/nav/labels.js"() {
|
|
11591
11593
|
init_serialize();
|
|
11592
11594
|
init_trees();
|
|
11593
11595
|
STYLES = ["D", "r", "R", "a", "A"];
|
|
@@ -11596,7 +11598,7 @@ var init_labels = __esm({
|
|
|
11596
11598
|
}
|
|
11597
11599
|
});
|
|
11598
11600
|
|
|
11599
|
-
//
|
|
11601
|
+
// src/nav/viewer.js
|
|
11600
11602
|
function createViewer(doc) {
|
|
11601
11603
|
const set2 = /* @__PURE__ */ new Map();
|
|
11602
11604
|
let registered = false;
|
|
@@ -11649,7 +11651,7 @@ function createViewer(doc) {
|
|
|
11649
11651
|
}
|
|
11650
11652
|
var BOOLS, NAMES, PREF;
|
|
11651
11653
|
var init_viewer = __esm({
|
|
11652
|
-
"
|
|
11654
|
+
"src/nav/viewer.js"() {
|
|
11653
11655
|
init_dest();
|
|
11654
11656
|
BOOLS = { hideToolbar: "HideToolbar", hideMenubar: "HideMenubar", hideWindowUI: "HideWindowUI", fitWindow: "FitWindow", centerWindow: "CenterWindow", displayDocTitle: "DisplayDocTitle", pickTrayByPDFSize: "PickTrayByPDFSize" };
|
|
11655
11657
|
NAMES = {
|
|
@@ -11663,7 +11665,7 @@ var init_viewer = __esm({
|
|
|
11663
11665
|
}
|
|
11664
11666
|
});
|
|
11665
11667
|
|
|
11666
|
-
//
|
|
11668
|
+
// src/standards/pdfa.js
|
|
11667
11669
|
function addOutputIntent(doc, opt) {
|
|
11668
11670
|
const custom = opt && typeof opt === "object" && opt.outputIntent != null ? parseIcc(opt.outputIntent, "pdfa.outputIntent") : null;
|
|
11669
11671
|
if (custom && custom.n === 1) throw new TypeError("pdfa.outputIntent: an RGB or CMYK profile (not gray)");
|
|
@@ -11679,7 +11681,7 @@ function addOutputIntent(doc, opt) {
|
|
|
11679
11681
|
}
|
|
11680
11682
|
var SRGB, unbase64;
|
|
11681
11683
|
var init_pdfa = __esm({
|
|
11682
|
-
"
|
|
11684
|
+
"src/standards/pdfa.js"() {
|
|
11683
11685
|
init_icc();
|
|
11684
11686
|
init_serialize();
|
|
11685
11687
|
SRGB = "AAAC4GxjbXMCEAAAbW50clJHQiBYWVogB+IAAwAUAAkADgAdYWNzcE1TRlQAAAAAc2F3c2N0cmwAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1oYW5kk7I0qQ6wIoqY/Zqvo2eJmwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJZGVzYwAAAPAAAABfY3BydAAAAQwAAAAMd3RwdAAAARgAAAAUclhZWgAAASwAAAAUZ1hZWgAAAUAAAAAUYlhZWgAAAVQAAAAUclRSQwAAAWgAAAF4Z1RSQwAAAWgAAAF4YlRSQwAAAWgAAAF4ZGVzYwAAAAAAAAAFc1JHQgAAAAAAAAAAAAAAAHRleHQAAAAAQ0MwAFhZWiAAAAAAAADzVAABAAAAARbJWFlaIAAAAAAAAG+gAAA48gAAA49YWVogAAAAAAAAYpYAALeJAAAY2lhZWiAAAAAAAAAkoAAAD4UAALbEY3VydgAAAAAAAAC2AAAAHAA4AFQAcACMAKgAxADhAQABIgFGAW0BlQHBAfACIAJVAosCxAMBAz8DggPGBA4EWQSnBPkFTAWkBf4GXAa+ByEHigf0CGMI1QlJCcMKPwq/C0ILyQxUDOENdA4JDqIPQA/gEIURLRHaEooTPhP2FLIVcRY2Fv0XyhiZGW4aRhsiHAMc5x3QHr0friCkIZ4inCOfJKUlsSbAJ9Uo7SoKKyssUS18Lqov3jEWMlIzlDTZNiQ3czjGOiA7fDzfPkU/sEEhQpZEEEWPRxJIm0ooS7tNUU7uUI9SNVPgVZBXRVkAWr5chF5MYBth72PHZaZniWlxa19tUW9KcUZzSnVRd155cXuIfaZ/yIHwhB6GUIiJisWNCY9RkZ+T85ZLmKubDp14n+eiW6TWp1ap26xnrvexj7Qqtsy5dLwhvtXBjcRMxxDJ2syrz3/SXNU92CTbEt4E4P7j/OcB6gztHPA081D2c/mb/Mr//w==";
|
|
@@ -11691,7 +11693,7 @@ var init_pdfa = __esm({
|
|
|
11691
11693
|
}
|
|
11692
11694
|
});
|
|
11693
11695
|
|
|
11694
|
-
//
|
|
11696
|
+
// src/standards/files.js
|
|
11695
11697
|
function createFiles(doc, when) {
|
|
11696
11698
|
const tree = /* @__PURE__ */ new Map();
|
|
11697
11699
|
const af = [];
|
|
@@ -11737,7 +11739,7 @@ function createFiles(doc, when) {
|
|
|
11737
11739
|
}
|
|
11738
11740
|
var RELATIONSHIPS, MAX_FILE2, MAX_FILES, MIME;
|
|
11739
11741
|
var init_files = __esm({
|
|
11740
|
-
"
|
|
11742
|
+
"src/standards/files.js"() {
|
|
11741
11743
|
init_serialize();
|
|
11742
11744
|
init_filename();
|
|
11743
11745
|
init_md5();
|
|
@@ -11750,7 +11752,7 @@ var init_files = __esm({
|
|
|
11750
11752
|
}
|
|
11751
11753
|
});
|
|
11752
11754
|
|
|
11753
|
-
//
|
|
11755
|
+
// src/standards/facturx.js
|
|
11754
11756
|
function readInvoice(b) {
|
|
11755
11757
|
if (b.length > MAX_XML) throw new RangeError(`pdf.facturX: the XML is ${b.length} bytes, over ${MAX_XML >> 20} MB`);
|
|
11756
11758
|
let s;
|
|
@@ -11831,7 +11833,7 @@ function createFacturX(doc, attach) {
|
|
|
11831
11833
|
}
|
|
11832
11834
|
var MAX_XML, PROFILES, FX_NS;
|
|
11833
11835
|
var init_facturx = __esm({
|
|
11834
|
-
"
|
|
11836
|
+
"src/standards/facturx.js"() {
|
|
11835
11837
|
MAX_XML = 10 << 20;
|
|
11836
11838
|
PROFILES = /** @type {Record<string, [string, 'Data' | 'Alternative']>} */
|
|
11837
11839
|
{
|
|
@@ -11846,7 +11848,7 @@ var init_facturx = __esm({
|
|
|
11846
11848
|
}
|
|
11847
11849
|
});
|
|
11848
11850
|
|
|
11849
|
-
//
|
|
11851
|
+
// src/standards/boxes.js
|
|
11850
11852
|
function pageBoxes(page, o) {
|
|
11851
11853
|
const W = page.width, H = page.height, who = "addPage";
|
|
11852
11854
|
const got = {};
|
|
@@ -11884,7 +11886,7 @@ function pageBoxes(page, o) {
|
|
|
11884
11886
|
}
|
|
11885
11887
|
var BOXES, EPS;
|
|
11886
11888
|
var init_boxes = __esm({
|
|
11887
|
-
"
|
|
11889
|
+
"src/standards/boxes.js"() {
|
|
11888
11890
|
init_serialize();
|
|
11889
11891
|
init_level();
|
|
11890
11892
|
BOXES = /** @type {const} */
|
|
@@ -11893,7 +11895,7 @@ var init_boxes = __esm({
|
|
|
11893
11895
|
}
|
|
11894
11896
|
});
|
|
11895
11897
|
|
|
11896
|
-
//
|
|
11898
|
+
// src/forms/draw.js
|
|
11897
11899
|
function frame(ap, w, h, f, bg = f.bg) {
|
|
11898
11900
|
if (bg != null) ap.fill(ap.path().rect(0, 0, w, h), { fill: bg });
|
|
11899
11901
|
if (f.bw > 0) ap.stroke(ap.path().rect(f.bw / 2, f.bw / 2, w - f.bw, h - f.bw), { stroke: f.bc, width: f.bw });
|
|
@@ -12019,7 +12021,7 @@ function buttonFace(ap, w, h, f, bg, t, label, icon) {
|
|
|
12019
12021
|
}
|
|
12020
12022
|
var MARKS, PLAIN2, AUTO_MAX, AUTO_MIN, widthOf2;
|
|
12021
12023
|
var init_draw2 = __esm({
|
|
12022
|
-
"
|
|
12024
|
+
"src/forms/draw.js"() {
|
|
12023
12025
|
init_content();
|
|
12024
12026
|
init_text();
|
|
12025
12027
|
init_runs();
|
|
@@ -12035,7 +12037,7 @@ var init_draw2 = __esm({
|
|
|
12035
12037
|
}
|
|
12036
12038
|
});
|
|
12037
12039
|
|
|
12038
|
-
//
|
|
12040
|
+
// src/forms/form.js
|
|
12039
12041
|
function keys(o, allowed, who) {
|
|
12040
12042
|
if (o == null || typeof o !== "object") throw new TypeError(`${who}: options are an object`);
|
|
12041
12043
|
for (const k of Object.keys(o)) {
|
|
@@ -12419,7 +12421,7 @@ function createForm(doc, opt = {}) {
|
|
|
12419
12421
|
}
|
|
12420
12422
|
var MAX_FIELDS, MAX_BUTTONS, MAX_OPTIONS, MAX_OPTION_CHARS, MAX_WIDGETS, MAX_VALUE, MAX_NAME, MAX_DEPTH3, MAX_TOOLTIP, MAX_COMB, NAMED2, ACTIVE2, FF, BOX, LOOK, TEXT, BAD_CHAR, hexAscii;
|
|
12421
12423
|
var init_form = __esm({
|
|
12422
|
-
"
|
|
12424
|
+
"src/forms/form.js"() {
|
|
12423
12425
|
init_serialize();
|
|
12424
12426
|
init_brand();
|
|
12425
12427
|
init_annot();
|
|
@@ -12467,7 +12469,7 @@ var init_form = __esm({
|
|
|
12467
12469
|
}
|
|
12468
12470
|
});
|
|
12469
12471
|
|
|
12470
|
-
//
|
|
12472
|
+
// src/security/crypto.js
|
|
12471
12473
|
function concat(parts) {
|
|
12472
12474
|
let n = 0;
|
|
12473
12475
|
for (const p of parts) n += p.length;
|
|
@@ -12528,7 +12530,7 @@ function aesCbcDecryptSync(key, iv, data, strip = true) {
|
|
|
12528
12530
|
}
|
|
12529
12531
|
var NODE, WEB, random, HASHES, nodeName, hex, unhex;
|
|
12530
12532
|
var init_crypto = __esm({
|
|
12531
|
-
"
|
|
12533
|
+
"src/security/crypto.js"() {
|
|
12532
12534
|
init_md5();
|
|
12533
12535
|
NODE = /** @type {any} */
|
|
12534
12536
|
globalThis.process?.getBuiltinModule?.("node:crypto");
|
|
@@ -12550,7 +12552,7 @@ var init_crypto = __esm({
|
|
|
12550
12552
|
}
|
|
12551
12553
|
});
|
|
12552
12554
|
|
|
12553
|
-
//
|
|
12555
|
+
// src/security/encrypt.js
|
|
12554
12556
|
function permBits(p) {
|
|
12555
12557
|
let P = 4294963392;
|
|
12556
12558
|
for (const [k, bit] of Object.entries(PERMS)) if (p[k]) P |= 1 << bit - 1;
|
|
@@ -12743,7 +12745,7 @@ function encryptor(opt, doc) {
|
|
|
12743
12745
|
}
|
|
12744
12746
|
var MAX_PASSWORD, PERMS, PAD, UTF84;
|
|
12745
12747
|
var init_encrypt = __esm({
|
|
12746
|
-
"
|
|
12748
|
+
"src/security/encrypt.js"() {
|
|
12747
12749
|
init_crypto();
|
|
12748
12750
|
MAX_PASSWORD = 1024;
|
|
12749
12751
|
PERMS = { print: 3, modify: 4, copy: 5, annotate: 6, fillForms: 9, accessibility: 10, assemble: 11, printHighQuality: 12 };
|
|
@@ -12752,7 +12754,7 @@ var init_encrypt = __esm({
|
|
|
12752
12754
|
}
|
|
12753
12755
|
});
|
|
12754
12756
|
|
|
12755
|
-
//
|
|
12757
|
+
// src/security/der.js
|
|
12756
12758
|
function oid(s) {
|
|
12757
12759
|
const a = s.split(".").map(Number), out = [40 * a[0] + a[1]];
|
|
12758
12760
|
for (const v of a.slice(2)) {
|
|
@@ -12798,7 +12800,7 @@ function kids(b, v) {
|
|
|
12798
12800
|
}
|
|
12799
12801
|
var lenBytes, tlv, seq, set, ctx, octets, NULL, int;
|
|
12800
12802
|
var init_der = __esm({
|
|
12801
|
-
"
|
|
12803
|
+
"src/security/der.js"() {
|
|
12802
12804
|
init_crypto();
|
|
12803
12805
|
lenBytes = (n) => n < 128 ? [n] : n < 256 ? [129, n] : n < 65536 ? [130, n >> 8, n & 255] : n < 16777216 ? [131, n >> 16, n >> 8 & 255, n & 255] : [132, n >>> 24, n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
12804
12806
|
tlv = (tag3, ...parts) => {
|
|
@@ -12822,7 +12824,7 @@ var init_der = __esm({
|
|
|
12822
12824
|
}
|
|
12823
12825
|
});
|
|
12824
12826
|
|
|
12825
|
-
//
|
|
12827
|
+
// src/security/cms.js
|
|
12826
12828
|
function readCerts(certs, who) {
|
|
12827
12829
|
const list = Array.isArray(certs) ? certs : [certs];
|
|
12828
12830
|
const out = [];
|
|
@@ -12925,7 +12927,7 @@ function nodeSigner(o) {
|
|
|
12925
12927
|
}
|
|
12926
12928
|
var NODE2, MAX_CERTS, MAX_CERT, MAX_SIGNATURE, MAX_TOKEN, DIGEST, RSA, ECDSA, SIGNED_DATA, DATA, attr, algId, eq;
|
|
12927
12929
|
var init_cms = __esm({
|
|
12928
|
-
"
|
|
12930
|
+
"src/security/cms.js"() {
|
|
12929
12931
|
init_der();
|
|
12930
12932
|
init_crypto();
|
|
12931
12933
|
NODE2 = /** @type {any} */
|
|
@@ -12948,7 +12950,7 @@ var init_cms = __esm({
|
|
|
12948
12950
|
}
|
|
12949
12951
|
});
|
|
12950
12952
|
|
|
12951
|
-
//
|
|
12953
|
+
// src/security/sign.js
|
|
12952
12954
|
function createSigning(doc, form, o) {
|
|
12953
12955
|
let used = false;
|
|
12954
12956
|
return function sign(field, opt) {
|
|
@@ -13013,7 +13015,7 @@ function createSigning(doc, form, o) {
|
|
|
13013
13015
|
}
|
|
13014
13016
|
var DEFAULT_RESERVE, MAX_RESERVE, TST_OID, has, KEYS;
|
|
13015
13017
|
var init_sign = __esm({
|
|
13016
|
-
"
|
|
13018
|
+
"src/security/sign.js"() {
|
|
13017
13019
|
init_brand();
|
|
13018
13020
|
init_serialize();
|
|
13019
13021
|
init_sink();
|
|
@@ -13033,7 +13035,7 @@ var init_sign = __esm({
|
|
|
13033
13035
|
}
|
|
13034
13036
|
});
|
|
13035
13037
|
|
|
13036
|
-
//
|
|
13038
|
+
// src/reader/budget.js
|
|
13037
13039
|
function createBudget(o = {}) {
|
|
13038
13040
|
const pos = (v, d, k) => {
|
|
13039
13041
|
if (v == null) return d;
|
|
@@ -13094,7 +13096,7 @@ function createBudget(o = {}) {
|
|
|
13094
13096
|
}
|
|
13095
13097
|
var PdfReadError, fail, DEFAULTS;
|
|
13096
13098
|
var init_budget = __esm({
|
|
13097
|
-
"
|
|
13099
|
+
"src/reader/budget.js"() {
|
|
13098
13100
|
PdfReadError = class extends Error {
|
|
13099
13101
|
/** @param {Code} code @param {string} message */
|
|
13100
13102
|
constructor(code, message) {
|
|
@@ -13110,7 +13112,7 @@ var init_budget = __esm({
|
|
|
13110
13112
|
}
|
|
13111
13113
|
});
|
|
13112
13114
|
|
|
13113
|
-
//
|
|
13115
|
+
// src/reader/lexer.js
|
|
13114
13116
|
function latin12(b) {
|
|
13115
13117
|
if (b.length < 64) {
|
|
13116
13118
|
let s2 = "";
|
|
@@ -13126,6 +13128,12 @@ function latin12(b) {
|
|
|
13126
13128
|
for (let i2 = 0; i2 < b.length; i2 += 8192) s += String.fromCharCode(...b.subarray(i2, i2 + 8192));
|
|
13127
13129
|
return s;
|
|
13128
13130
|
}
|
|
13131
|
+
function word(b, i2, j) {
|
|
13132
|
+
if (j - i2 > 24) return latin12(b.subarray(i2, j));
|
|
13133
|
+
let s = "";
|
|
13134
|
+
for (let k = i2; k < j; k++) s += String.fromCharCode(b[k]);
|
|
13135
|
+
return s;
|
|
13136
|
+
}
|
|
13129
13137
|
function parseValue(lx) {
|
|
13130
13138
|
const stack = [];
|
|
13131
13139
|
for (; ; ) {
|
|
@@ -13221,7 +13229,21 @@ function add(top, v) {
|
|
|
13221
13229
|
}
|
|
13222
13230
|
function indexOf(buf, needle, from, to = buf.length) {
|
|
13223
13231
|
const n0 = needle.charCodeAt(0), L = needle.length;
|
|
13224
|
-
|
|
13232
|
+
from = Math.max(0, from);
|
|
13233
|
+
to = Math.min(to, buf.length);
|
|
13234
|
+
if (to - from > 64) {
|
|
13235
|
+
if (NodeBuffer) {
|
|
13236
|
+
const i2 = NodeBuffer.from(buf.buffer, buf.byteOffset, to).indexOf(needle, from, "latin1");
|
|
13237
|
+
return i2;
|
|
13238
|
+
}
|
|
13239
|
+
for (let i2 = buf.indexOf(n0, from); i2 >= 0 && i2 + L <= to; i2 = buf.indexOf(n0, i2 + 1)) {
|
|
13240
|
+
let j = 1;
|
|
13241
|
+
while (j < L && buf[i2 + j] === needle.charCodeAt(j)) j++;
|
|
13242
|
+
if (j === L) return i2;
|
|
13243
|
+
}
|
|
13244
|
+
return -1;
|
|
13245
|
+
}
|
|
13246
|
+
outer: for (let i2 = from; i2 + L <= to; i2++) {
|
|
13225
13247
|
if (buf[i2] !== n0) continue;
|
|
13226
13248
|
for (let j = 1; j < L; j++) if (buf[i2 + j] !== needle.charCodeAt(j)) continue outer;
|
|
13227
13249
|
return i2;
|
|
@@ -13236,9 +13258,9 @@ function lastIndexOf(buf, needle, to, span = to) {
|
|
|
13236
13258
|
}
|
|
13237
13259
|
return -1;
|
|
13238
13260
|
}
|
|
13239
|
-
var MAX_DEPTH4, MAX_ITEMS, Ref, PdfString, PdfStream, Op, CLASS, T, HEX, Lexer, parseValueEnd;
|
|
13261
|
+
var MAX_DEPTH4, MAX_ITEMS, Ref, PdfString, PdfStream, Op, CLASS, T, HEX, Lexer, parseValueEnd, NodeBuffer;
|
|
13240
13262
|
var init_lexer = __esm({
|
|
13241
|
-
"
|
|
13263
|
+
"src/reader/lexer.js"() {
|
|
13242
13264
|
init_budget();
|
|
13243
13265
|
MAX_DEPTH4 = 256;
|
|
13244
13266
|
MAX_ITEMS = 4e6;
|
|
@@ -13348,19 +13370,25 @@ var init_lexer = __esm({
|
|
|
13348
13370
|
while (j < e && CLASS[b[j]] === 0) j++;
|
|
13349
13371
|
this.pos = j;
|
|
13350
13372
|
if (c >= 48 && c <= 57 || c === 43 || c === 45 || c === 46) {
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13373
|
+
if (j - i2 < 10) {
|
|
13374
|
+
let v2 = 0, k = i2;
|
|
13375
|
+
while (k < j && b[k] >= 48 && b[k] <= 57) v2 = v2 * 10 + b[k++] - 48;
|
|
13376
|
+
if (k === j && k > i2) {
|
|
13377
|
+
this.val = v2;
|
|
13378
|
+
return T.NUM;
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
let s = "";
|
|
13382
|
+
for (let k = i2; k < j && k < i2 + 64; k++) s += String.fromCharCode(b[k]);
|
|
13383
|
+
let v = Number(s);
|
|
13354
13384
|
if (!Number.isFinite(v)) {
|
|
13355
|
-
const m = /^[+-]?(\d+\.?\d*|\.\d+)/.exec(
|
|
13385
|
+
const m = /^[+-]?(\d+\.?\d*|\.\d+)/.exec(s.replace(/^([+-])[+-]+/, "$1"));
|
|
13356
13386
|
v = m ? Number(m[0]) : 0;
|
|
13357
13387
|
}
|
|
13358
13388
|
this.val = Number.isFinite(v) ? v : 0;
|
|
13359
13389
|
return T.NUM;
|
|
13360
13390
|
}
|
|
13361
|
-
|
|
13362
|
-
for (let k = i2; k < j && k < i2 + 128; k++) s += String.fromCharCode(b[k]);
|
|
13363
|
-
this.val = s;
|
|
13391
|
+
this.val = j - i2 <= 128 ? word(b, i2, j) : word(b, i2, i2 + 128);
|
|
13364
13392
|
return T.KW;
|
|
13365
13393
|
}
|
|
13366
13394
|
/** @param {number} i after "(" */
|
|
@@ -13429,8 +13457,15 @@ var init_lexer = __esm({
|
|
|
13429
13457
|
/** @param {number} i after "/" */
|
|
13430
13458
|
name(i2) {
|
|
13431
13459
|
const b = this.buf, e = this.end;
|
|
13432
|
-
let s = "";
|
|
13433
13460
|
let j = i2;
|
|
13461
|
+
while (j < e && CLASS[b[j]] === 0 && b[j] !== 35 && j - i2 < 4096) j++;
|
|
13462
|
+
if (j - i2 < 4096 && (j >= e || b[j] !== 35)) {
|
|
13463
|
+
this.pos = j;
|
|
13464
|
+
this.val = word(b, i2, j);
|
|
13465
|
+
return T.NAME;
|
|
13466
|
+
}
|
|
13467
|
+
let s = "";
|
|
13468
|
+
j = i2;
|
|
13434
13469
|
while (j < e && CLASS[b[j]] === 0 && j - i2 < 4096) {
|
|
13435
13470
|
if (b[j] === 35 && j + 2 < e && HEX[b[j + 1]] >= 0 && HEX[b[j + 2]] >= 0) {
|
|
13436
13471
|
s += String.fromCharCode(HEX[b[j + 1]] << 4 | HEX[b[j + 2]]);
|
|
@@ -13446,10 +13481,12 @@ var init_lexer = __esm({
|
|
|
13446
13481
|
}
|
|
13447
13482
|
};
|
|
13448
13483
|
parseValueEnd = () => void 0;
|
|
13484
|
+
NodeBuffer = /** @type {any} */
|
|
13485
|
+
globalThis.Buffer;
|
|
13449
13486
|
}
|
|
13450
13487
|
});
|
|
13451
13488
|
|
|
13452
|
-
//
|
|
13489
|
+
// src/reader/filters.js
|
|
13453
13490
|
function sinkOf(budget) {
|
|
13454
13491
|
const parts = [];
|
|
13455
13492
|
let n = 0;
|
|
@@ -13705,7 +13742,7 @@ function decode(data, filters, parms, budget, resolve2) {
|
|
|
13705
13742
|
}
|
|
13706
13743
|
var PASS, CHUNK2, MAX_FILTERS, num2, clamp;
|
|
13707
13744
|
var init_filters = __esm({
|
|
13708
|
-
"
|
|
13745
|
+
"src/reader/filters.js"() {
|
|
13709
13746
|
init_browser();
|
|
13710
13747
|
init_budget();
|
|
13711
13748
|
PASS = /* @__PURE__ */ new Set(["DCTDecode", "DCT", "JPXDecode", "JBIG2Decode", "CCITTFaxDecode", "CCF"]);
|
|
@@ -13716,7 +13753,7 @@ var init_filters = __esm({
|
|
|
13716
13753
|
}
|
|
13717
13754
|
});
|
|
13718
13755
|
|
|
13719
|
-
//
|
|
13756
|
+
// src/reader/crypt.js
|
|
13720
13757
|
function pad322(pw) {
|
|
13721
13758
|
const b = [...pw].every((c) => (
|
|
13722
13759
|
/** @type {number} */
|
|
@@ -13851,7 +13888,7 @@ async function openSecurity(E, id0, password, resolve2) {
|
|
|
13851
13888
|
}
|
|
13852
13889
|
var PERMS2, bytesOf, le32, eq2;
|
|
13853
13890
|
var init_crypt = __esm({
|
|
13854
|
-
"
|
|
13891
|
+
"src/reader/crypt.js"() {
|
|
13855
13892
|
init_encrypt();
|
|
13856
13893
|
init_crypto();
|
|
13857
13894
|
init_lexer();
|
|
@@ -13867,7 +13904,7 @@ var init_crypt = __esm({
|
|
|
13867
13904
|
}
|
|
13868
13905
|
});
|
|
13869
13906
|
|
|
13870
|
-
//
|
|
13907
|
+
// src/reader/source.js
|
|
13871
13908
|
async function openSource(bytes, budget, o = {}) {
|
|
13872
13909
|
const size = bytes.length;
|
|
13873
13910
|
let xref = /* @__PURE__ */ new Map();
|
|
@@ -14061,11 +14098,11 @@ async function openSource(bytes, budget, o = {}) {
|
|
|
14061
14098
|
if (loading.has(n)) return null;
|
|
14062
14099
|
loading.add(n);
|
|
14063
14100
|
try {
|
|
14064
|
-
let v =
|
|
14101
|
+
let v = load2(n);
|
|
14065
14102
|
if (v === void 0 && !recovered) {
|
|
14066
14103
|
recover();
|
|
14067
14104
|
recoverDeep();
|
|
14068
|
-
v =
|
|
14105
|
+
v = load2(n);
|
|
14069
14106
|
}
|
|
14070
14107
|
v ??= null;
|
|
14071
14108
|
cache.set(n, v);
|
|
@@ -14074,7 +14111,7 @@ async function openSource(bytes, budget, o = {}) {
|
|
|
14074
14111
|
loading.delete(n);
|
|
14075
14112
|
}
|
|
14076
14113
|
}
|
|
14077
|
-
function
|
|
14114
|
+
function load2(n) {
|
|
14078
14115
|
const e = xref.get(n);
|
|
14079
14116
|
if (e === void 0) return null;
|
|
14080
14117
|
const [t, a, b] = unpack(e);
|
|
@@ -14323,7 +14360,7 @@ async function openSource(bytes, budget, o = {}) {
|
|
|
14323
14360
|
)[0] !== 1) continue;
|
|
14324
14361
|
let v;
|
|
14325
14362
|
try {
|
|
14326
|
-
v =
|
|
14363
|
+
v = load2(n);
|
|
14327
14364
|
} catch (e) {
|
|
14328
14365
|
if (e instanceof PdfReadError && (e.code === "E_TIMEOUT" || e.code === "E_ABORTED" || e.code === "E_BUDGET")) throw e;
|
|
14329
14366
|
continue;
|
|
@@ -14492,12 +14529,12 @@ async function openSource(bytes, budget, o = {}) {
|
|
|
14492
14529
|
return r.end;
|
|
14493
14530
|
}
|
|
14494
14531
|
const lx = new Lexer(bytes, budget);
|
|
14495
|
-
let
|
|
14532
|
+
let int1 = false, int2 = false, start1 = -1, start2 = -1, seen = 0;
|
|
14496
14533
|
for (; ; ) {
|
|
14497
14534
|
const k = lx.next();
|
|
14498
14535
|
if (k === T.EOF) break;
|
|
14499
|
-
if (k === T.KW && lx.val === "obj" &&
|
|
14500
|
-
const off =
|
|
14536
|
+
if (k === T.KW && lx.val === "obj" && seen >= 2 && int1 && int2) {
|
|
14537
|
+
const off = start1;
|
|
14501
14538
|
const end = yield* read3(off);
|
|
14502
14539
|
if (end === false) unreadable(`The object at byte ${off} cannot be read`);
|
|
14503
14540
|
lx.pos = Math.max(
|
|
@@ -14505,11 +14542,15 @@ async function openSource(bytes, budget, o = {}) {
|
|
|
14505
14542
|
/** @type {number} */
|
|
14506
14543
|
end
|
|
14507
14544
|
);
|
|
14508
|
-
|
|
14545
|
+
seen = 0;
|
|
14546
|
+
int1 = int2 = false;
|
|
14509
14547
|
continue;
|
|
14510
14548
|
}
|
|
14511
|
-
|
|
14512
|
-
|
|
14549
|
+
int1 = int2;
|
|
14550
|
+
start1 = start2;
|
|
14551
|
+
int2 = k === T.NUM && Number.isInteger(lx.val) && lx.val >= 0;
|
|
14552
|
+
start2 = lx.start;
|
|
14553
|
+
seen++;
|
|
14513
14554
|
}
|
|
14514
14555
|
const inStream = inRegion(regions, budget);
|
|
14515
14556
|
const hits = scanObjects().sort((x2, y) => x2[2] - y[2]);
|
|
@@ -14580,7 +14621,7 @@ function inRegion(regions, budget) {
|
|
|
14580
14621
|
}
|
|
14581
14622
|
var MAX_SECTIONS, MAX_RESOLVE, MAX_OBJSTM_N, OBJSTM_CACHE, OBJSTM_BYTES, CACHE_N, P48, P16, pack, unpack;
|
|
14582
14623
|
var init_source = __esm({
|
|
14583
|
-
"
|
|
14624
|
+
"src/reader/source.js"() {
|
|
14584
14625
|
init_lexer();
|
|
14585
14626
|
init_filters();
|
|
14586
14627
|
init_budget();
|
|
@@ -14598,7 +14639,7 @@ var init_source = __esm({
|
|
|
14598
14639
|
}
|
|
14599
14640
|
});
|
|
14600
14641
|
|
|
14601
|
-
//
|
|
14642
|
+
// src/reader/text.js
|
|
14602
14643
|
function decodeText(v) {
|
|
14603
14644
|
if (!(v instanceof PdfString)) return typeof v === "string" ? v : v == null ? "" : String(v);
|
|
14604
14645
|
const b = v.bytes;
|
|
@@ -14897,6 +14938,7 @@ function contentBytes(src, contents) {
|
|
|
14897
14938
|
) throw e;
|
|
14898
14939
|
}
|
|
14899
14940
|
}
|
|
14941
|
+
if (parts.length === 1) return parts[0];
|
|
14900
14942
|
let n = parts.length;
|
|
14901
14943
|
for (const p of parts) n += p.length;
|
|
14902
14944
|
const out = new Uint8Array(n);
|
|
@@ -14973,20 +15015,22 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
14973
15015
|
let chars2 = 0;
|
|
14974
15016
|
let moved = true;
|
|
14975
15017
|
const fonts = /* @__PURE__ */ new Map();
|
|
14976
|
-
const add2 = (x2, y, end, size, text3,
|
|
15018
|
+
const add2 = (x2, y, end, size, text3, d0, d1, d2, d3) => {
|
|
14977
15019
|
if (PT.length >= budget.maxTextItems) throw new PdfReadError("E_BUDGET", `A page has more than ${budget.maxTextItems.toLocaleString("en")} pieces of text (budget.maxTextItems)`);
|
|
14978
15020
|
if ((chars2 += text3.length) > MAX_TEXT_CHARS) throw new PdfReadError("E_BUDGET", `A page makes more than ${MAX_TEXT_CHARS.toLocaleString("en")} characters of text`);
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
15021
|
+
if (raw) {
|
|
15022
|
+
PX.push(x2);
|
|
15023
|
+
PY.push(y);
|
|
15024
|
+
PE.push(end);
|
|
15025
|
+
}
|
|
14982
15026
|
PS.push(size);
|
|
14983
15027
|
PT.push(text3);
|
|
14984
15028
|
PG.push(moved ? 2 : 0);
|
|
14985
15029
|
moved = false;
|
|
14986
|
-
PA.push(
|
|
14987
|
-
PAE.push(
|
|
14988
|
-
PC.push(
|
|
14989
|
-
PD.push(
|
|
15030
|
+
PA.push(d0);
|
|
15031
|
+
PAE.push(d1);
|
|
15032
|
+
PC.push(d2);
|
|
15033
|
+
PD.push(d3);
|
|
14990
15034
|
};
|
|
14991
15035
|
const held = (
|
|
14992
15036
|
/** @type {Held} */
|
|
@@ -15021,25 +15065,26 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15021
15065
|
let k = 0;
|
|
15022
15066
|
ts.font.decode(b, (text3, w, space) => {
|
|
15023
15067
|
if ((++k & 1023) === 0) budget.tick(1024);
|
|
15024
|
-
const
|
|
15025
|
-
const
|
|
15068
|
+
const sx = ts.size * ts.Th, sy = ts.size, rise = ts.Ts;
|
|
15069
|
+
const M0 = mul6(sx, 0, 0, sy, 0, rise, mul2(Tm, ctm, C0), G0);
|
|
15070
|
+
const x2 = M0[4], y = M0[5], size = (M0[2] === 0 ? Math.abs(M0[3]) : Math.hypot(M0[2], M0[3])) || ts.size;
|
|
15026
15071
|
const tx = (w / 1e3 * ts.size + ts.Tc + (space ? ts.Tw : 0)) * ts.Th;
|
|
15027
|
-
Tm =
|
|
15028
|
-
const M1 =
|
|
15029
|
-
const L = Math.hypot(M0[0], M0[1]), ux = L ? M0[0] / L : 1, uy = L ? M0[1] / L : 0;
|
|
15030
|
-
const
|
|
15072
|
+
Tm = mul6(1, 0, 0, 1, tx, 0, Tm);
|
|
15073
|
+
const M1 = mul6(sx, 0, 0, sy, 0, rise, mul2(Tm, ctm, C0), G1), end = M1[4];
|
|
15074
|
+
const L = M0[1] === 0 ? Math.abs(M0[0]) : Math.hypot(M0[0], M0[1]), ux = L ? M0[0] / L : 1, uy = L ? M0[1] / L : 0;
|
|
15075
|
+
const d0 = x2 * ux + y * uy, d1 = M1[4] * ux + M1[5] * uy, d2 = y * ux - x2 * uy, d3 = uy === 0 && ux > 0 ? uy : Math.round(Math.atan2(uy, ux) * 180 / Math.PI);
|
|
15031
15076
|
if (actual) {
|
|
15032
|
-
if (!actual.seen) Object.assign(actual, { x: x2, y, size, dir, seen: true });
|
|
15077
|
+
if (!actual.seen) Object.assign(actual, { x: x2, y, size, dir: [d0, d1, d2, d3], seen: true });
|
|
15033
15078
|
actual.end = end;
|
|
15034
|
-
actual.dir[1] =
|
|
15079
|
+
actual.dir[1] = d1;
|
|
15035
15080
|
return;
|
|
15036
15081
|
}
|
|
15037
15082
|
const n = PT.length - 1;
|
|
15038
15083
|
if (text3.includes("")) text3 = text3.replaceAll("", "");
|
|
15039
|
-
if (text3) add2(x2, y, end, size, text3,
|
|
15040
|
-
else if (n >= 0 && PAE[n] <
|
|
15041
|
-
PE[n] = end;
|
|
15042
|
-
PAE[n] =
|
|
15084
|
+
if (text3) add2(x2, y, end, size, text3, d0, d1, d2, d3);
|
|
15085
|
+
else if (n >= 0 && PAE[n] < d1 && PD[n] === d3 && Math.abs(PC[n] - d2) < 0.01) {
|
|
15086
|
+
if (raw) PE[n] = end;
|
|
15087
|
+
PAE[n] = d1;
|
|
15043
15088
|
}
|
|
15044
15089
|
});
|
|
15045
15090
|
budget.tick(1 + (k & 1023));
|
|
@@ -15104,7 +15149,7 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15104
15149
|
if (typeof a[1] === "number") ts = { ...ts, TL: -a[1] };
|
|
15105
15150
|
// falls through
|
|
15106
15151
|
case "Td":
|
|
15107
|
-
if (typeof a[0] === "number" && typeof a[1] === "number") Tm = Tlm =
|
|
15152
|
+
if (typeof a[0] === "number" && typeof a[1] === "number") Tm = Tlm = mul6(1, 0, 0, 1, a[0], a[1], Tlm);
|
|
15108
15153
|
moved = true;
|
|
15109
15154
|
break;
|
|
15110
15155
|
case "Tm": {
|
|
@@ -15114,7 +15159,7 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15114
15159
|
break;
|
|
15115
15160
|
}
|
|
15116
15161
|
case "T*":
|
|
15117
|
-
Tm = Tlm =
|
|
15162
|
+
Tm = Tlm = mul6(1, 0, 0, 1, 0, -ts.TL, Tlm);
|
|
15118
15163
|
moved = true;
|
|
15119
15164
|
break;
|
|
15120
15165
|
case "Tj":
|
|
@@ -15122,13 +15167,13 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15122
15167
|
break;
|
|
15123
15168
|
case "'":
|
|
15124
15169
|
moved = true;
|
|
15125
|
-
Tm = Tlm =
|
|
15170
|
+
Tm = Tlm = mul6(1, 0, 0, 1, 0, -ts.TL, Tlm);
|
|
15126
15171
|
if (a[0] instanceof PdfString) show(a[0].bytes, f.ctm);
|
|
15127
15172
|
break;
|
|
15128
15173
|
case '"':
|
|
15129
15174
|
if (typeof a[0] === "number") ts = { ...ts, Tw: a[0] };
|
|
15130
15175
|
if (typeof a[1] === "number") ts = { ...ts, Tc: a[1] };
|
|
15131
|
-
Tm = Tlm =
|
|
15176
|
+
Tm = Tlm = mul6(1, 0, 0, 1, 0, -ts.TL, Tlm);
|
|
15132
15177
|
moved = true;
|
|
15133
15178
|
if (a[2] instanceof PdfString) show(a[2].bytes, f.ctm);
|
|
15134
15179
|
break;
|
|
@@ -15136,7 +15181,7 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15136
15181
|
if (Array.isArray(a[0])) for (const x2 of a[0]) {
|
|
15137
15182
|
if (x2 instanceof PdfString) show(x2.bytes, f.ctm);
|
|
15138
15183
|
else if (typeof x2 === "number") {
|
|
15139
|
-
Tm =
|
|
15184
|
+
Tm = mul6(1, 0, 0, 1, -x2 / 1e3 * ts.size * ts.Th, 0, Tm);
|
|
15140
15185
|
if (x2 < -180 && PT.length) PG[PT.length - 1] |= 1;
|
|
15141
15186
|
}
|
|
15142
15187
|
}
|
|
@@ -15165,7 +15210,7 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15165
15210
|
const m = marks.pop();
|
|
15166
15211
|
if (m && m === actual) {
|
|
15167
15212
|
actual = null;
|
|
15168
|
-
if (m.seen && m.at) add2(m.x, m.y, m.end, m.size, m.at, m.dir);
|
|
15213
|
+
if (m.seen && m.at) add2(m.x, m.y, m.end, m.size, m.at, m.dir[0], m.dir[1], m.dir[2], m.dir[3]);
|
|
15169
15214
|
}
|
|
15170
15215
|
break;
|
|
15171
15216
|
}
|
|
@@ -15228,9 +15273,9 @@ function pageText(src, pageDict, resources, raw = false) {
|
|
|
15228
15273
|
}
|
|
15229
15274
|
return out.join("");
|
|
15230
15275
|
}
|
|
15231
|
-
var MAX_FORMS, MAX_CMAP, MAX_MARKS, MAX_ACTUAL, MAX_TEXT_CHARS, MAX_DST, MAX_CMAP_CHARS, MAX_HELD, MAX_W, MAX_DO, TEXT_TIMEOUT_MS, DOC, WIN, MAC_HIGH, BASE, STD_HIGH, NAMES2, ACCENT, own, STD_ALIAS, NONE, stops, MAX_CMAP_FONTS, mul2, ID, matrixOf, RTL2, STRONG_L, NUM, rev2;
|
|
15276
|
+
var MAX_FORMS, MAX_CMAP, MAX_MARKS, MAX_ACTUAL, MAX_TEXT_CHARS, MAX_DST, MAX_CMAP_CHARS, MAX_HELD, MAX_W, MAX_DO, TEXT_TIMEOUT_MS, DOC, WIN, WIN_T, MAC_HIGH, BASE, STD_HIGH, NAMES2, ACCENT, own, STD_ALIAS, NONE, stops, MAX_CMAP_FONTS, mul6, mul2, ID, matrixOf, C0, G0, G1, RTL2, STRONG_L, NUM, rev2;
|
|
15232
15277
|
var init_text2 = __esm({
|
|
15233
|
-
"
|
|
15278
|
+
"src/reader/text.js"() {
|
|
15234
15279
|
init_lexer();
|
|
15235
15280
|
init_standard_metrics();
|
|
15236
15281
|
init_budget();
|
|
@@ -15294,9 +15339,13 @@ var init_text2 = __esm({
|
|
|
15294
15339
|
for (let i2 = 0; i2 < p.length; i2 += 2) WIN.set(p[i2 + 1], p[i2]);
|
|
15295
15340
|
WIN.set(173, 173);
|
|
15296
15341
|
}
|
|
15342
|
+
WIN_T = new Int32Array(256).map((_, c) => WIN.get(c) ?? (c >= 32 && c < 127 ? c : -1));
|
|
15297
15343
|
MAC_HIGH = "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ";
|
|
15298
15344
|
BASE = {
|
|
15299
|
-
WinAnsiEncoding: (c) =>
|
|
15345
|
+
WinAnsiEncoding: (c) => {
|
|
15346
|
+
const u = WIN_T[c & 255];
|
|
15347
|
+
return c < 256 && u >= 0 ? u : WIN.get(c) ?? (c >= 32 && c < 127 ? c : void 0);
|
|
15348
|
+
},
|
|
15300
15349
|
MacRomanEncoding: (c) => c >= 128 ? MAC_HIGH.codePointAt(c - 128) : c >= 32 && c < 127 ? c : void 0,
|
|
15301
15350
|
StandardEncoding: (c) => c === 39 ? 8217 : c === 96 ? 8216 : c >= 32 && c < 127 ? c : STD_HIGH.get(c),
|
|
15302
15351
|
PDFDocEncoding: (c) => DOC.get(c) ?? c
|
|
@@ -15447,16 +15496,22 @@ var init_text2 = __esm({
|
|
|
15447
15496
|
NONE = "�";
|
|
15448
15497
|
stops = (e) => e?.code === "E_TIMEOUT" || e?.code === "E_ABORTED" || e?.code === "E_BUDGET";
|
|
15449
15498
|
MAX_CMAP_FONTS = 100;
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
[
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15499
|
+
mul6 = (a0, a1, a2, a3, a4, a5, B, o = new Float64Array(6)) => {
|
|
15500
|
+
const b0 = B[0], b1 = B[1], b2 = B[2], b3 = B[3], b4 = B[4], b5 = B[5];
|
|
15501
|
+
o[0] = a0 * b0 + a1 * b2;
|
|
15502
|
+
o[1] = a0 * b1 + a1 * b3;
|
|
15503
|
+
o[2] = a2 * b0 + a3 * b2;
|
|
15504
|
+
o[3] = a2 * b1 + a3 * b3;
|
|
15505
|
+
o[4] = a4 * b0 + a5 * b2 + b4;
|
|
15506
|
+
o[5] = a4 * b1 + a5 * b3 + b5;
|
|
15507
|
+
return o;
|
|
15508
|
+
};
|
|
15509
|
+
mul2 = (A, B, o = new Float64Array(6)) => mul6(A[0], A[1], A[2], A[3], A[4], A[5], B, o);
|
|
15510
|
+
ID = Float64Array.of(1, 0, 0, 1, 0, 0);
|
|
15511
|
+
matrixOf = (a) => a.length >= 6 && a.slice(0, 6).every((x2) => typeof x2 === "number" && Number.isFinite(x2)) ? Float64Array.from(a.slice(0, 6)) : null;
|
|
15512
|
+
C0 = new Float64Array(6);
|
|
15513
|
+
G0 = new Float64Array(6);
|
|
15514
|
+
G1 = new Float64Array(6);
|
|
15460
15515
|
RTL2 = /[\u0590-\u05ff\u0600-\u065f\u066a-\u06ef\u06fa-\u08ff\ufb1d-\ufdff\ufe70-\ufeff]/;
|
|
15461
15516
|
STRONG_L = /[\p{L}]/u;
|
|
15462
15517
|
NUM = /^[\p{Nd}.,٫٬]+$/u;
|
|
@@ -15464,7 +15519,7 @@ var init_text2 = __esm({
|
|
|
15464
15519
|
}
|
|
15465
15520
|
});
|
|
15466
15521
|
|
|
15467
|
-
//
|
|
15522
|
+
// src/reader/policy.js
|
|
15468
15523
|
function attributesOnly(a, R) {
|
|
15469
15524
|
const one = (x2) => {
|
|
15470
15525
|
const d = R(x2);
|
|
@@ -15576,7 +15631,7 @@ function utf16be(s) {
|
|
|
15576
15631
|
}
|
|
15577
15632
|
var KEEP_ACTIONS, NAMED_ACTIONS, ACTION_TYPES, KEEP_ANNOTS, ACTION_KEYS, DANGEROUS_KEYS, NAME_KEYS, isAction, isAnnot, STRUCT_TYPES, isFilespec, REWRITTEN_NAME, sameObject, refuseFile;
|
|
15578
15633
|
var init_policy = __esm({
|
|
15579
|
-
"
|
|
15634
|
+
"src/reader/policy.js"() {
|
|
15580
15635
|
init_lexer();
|
|
15581
15636
|
init_links();
|
|
15582
15637
|
init_filename();
|
|
@@ -15660,7 +15715,7 @@ var init_policy = __esm({
|
|
|
15660
15715
|
}
|
|
15661
15716
|
});
|
|
15662
15717
|
|
|
15663
|
-
//
|
|
15718
|
+
// src/reader/copy.js
|
|
15664
15719
|
function nameText(s) {
|
|
15665
15720
|
let o = "/";
|
|
15666
15721
|
for (let i2 = 0; i2 < s.length; i2++) {
|
|
@@ -15829,27 +15884,34 @@ function createCopier(t) {
|
|
|
15829
15884
|
const out = [];
|
|
15830
15885
|
const stack = [v];
|
|
15831
15886
|
const budget = owner.r.src.budget;
|
|
15887
|
+
const text3 = refText !== null && refText !== AUDIT;
|
|
15832
15888
|
while (stack.length) {
|
|
15833
15889
|
const x2 = stack.pop();
|
|
15834
15890
|
budget.tick();
|
|
15835
15891
|
if (x2 instanceof Raw) {
|
|
15836
|
-
if (
|
|
15892
|
+
if (text3) out.push(x2.s);
|
|
15837
15893
|
continue;
|
|
15838
15894
|
}
|
|
15839
15895
|
if (x2 instanceof Ref) {
|
|
15840
15896
|
if (found) found.push([owner, x2.n]);
|
|
15841
|
-
if (
|
|
15897
|
+
if (text3) out.push(
|
|
15898
|
+
/** @type {any} */
|
|
15899
|
+
refText(owner, x2)
|
|
15900
|
+
);
|
|
15842
15901
|
continue;
|
|
15843
15902
|
}
|
|
15844
15903
|
if (x2 instanceof Foreign) {
|
|
15845
15904
|
if (found) found.push([x2.owner, x2.ref.n]);
|
|
15846
|
-
if (
|
|
15905
|
+
if (text3) out.push(
|
|
15906
|
+
/** @type {any} */
|
|
15907
|
+
refText(x2.owner, x2.ref)
|
|
15908
|
+
);
|
|
15847
15909
|
continue;
|
|
15848
15910
|
}
|
|
15849
15911
|
if (Array.isArray(x2)) {
|
|
15850
|
-
stack.push(CLOSE_A);
|
|
15912
|
+
if (text3) stack.push(CLOSE_A);
|
|
15851
15913
|
for (let i2 = x2.length - 1; i2 >= 0; i2--) stack.push(x2[i2]);
|
|
15852
|
-
stack.push(OPEN_A);
|
|
15914
|
+
if (text3) stack.push(OPEN_A);
|
|
15853
15915
|
continue;
|
|
15854
15916
|
}
|
|
15855
15917
|
if (x2 instanceof Map) {
|
|
@@ -15859,7 +15921,7 @@ function createCopier(t) {
|
|
|
15859
15921
|
if ("why" in r) {
|
|
15860
15922
|
if (refText) {
|
|
15861
15923
|
t.report(r.why);
|
|
15862
|
-
out.push("null");
|
|
15924
|
+
if (text3) out.push("null");
|
|
15863
15925
|
}
|
|
15864
15926
|
continue;
|
|
15865
15927
|
}
|
|
@@ -15871,16 +15933,18 @@ function createCopier(t) {
|
|
|
15871
15933
|
}
|
|
15872
15934
|
}
|
|
15873
15935
|
}
|
|
15874
|
-
stack.push(CLOSE_D);
|
|
15875
15936
|
const es = entries(owner, x2);
|
|
15876
|
-
|
|
15877
|
-
stack.push(
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15937
|
+
if (text3) {
|
|
15938
|
+
stack.push(CLOSE_D);
|
|
15939
|
+
for (let i2 = es.length - 1; i2 >= 0; i2--) {
|
|
15940
|
+
stack.push(es[i2][1]);
|
|
15941
|
+
stack.push(new Raw(nameText(es[i2][0])));
|
|
15942
|
+
}
|
|
15943
|
+
stack.push(OPEN_D);
|
|
15944
|
+
} else for (let i2 = es.length - 1; i2 >= 0; i2--) stack.push(es[i2][1]);
|
|
15881
15945
|
continue;
|
|
15882
15946
|
}
|
|
15883
|
-
if (!
|
|
15947
|
+
if (!text3) continue;
|
|
15884
15948
|
if (x2 instanceof PdfString) out.push(hexText(x2.bytes));
|
|
15885
15949
|
else if (typeof x2 === "string") out.push(nameText(x2));
|
|
15886
15950
|
else if (typeof x2 === "number") out.push(numText(x2));
|
|
@@ -16060,7 +16124,7 @@ function createCopier(t) {
|
|
|
16060
16124
|
}
|
|
16061
16125
|
auditing = treeOf(owner).nums.has(n);
|
|
16062
16126
|
try {
|
|
16063
|
-
walk(owner, v instanceof PdfStream ? v.dict : v,
|
|
16127
|
+
walk(owner, v instanceof PdfStream ? v.dict : v, AUDIT, null);
|
|
16064
16128
|
} finally {
|
|
16065
16129
|
auditing = false;
|
|
16066
16130
|
}
|
|
@@ -16072,9 +16136,9 @@ function createCopier(t) {
|
|
|
16072
16136
|
}
|
|
16073
16137
|
};
|
|
16074
16138
|
}
|
|
16075
|
-
var SHARE, GRAY, HEXD, Raw, Foreign, OPEN_A, CLOSE_A, OPEN_D, CLOSE_D;
|
|
16139
|
+
var SHARE, GRAY, HEXD, Raw, Foreign, AUDIT, OPEN_A, CLOSE_A, OPEN_D, CLOSE_D;
|
|
16076
16140
|
var init_copy = __esm({
|
|
16077
|
-
"
|
|
16141
|
+
"src/reader/copy.js"() {
|
|
16078
16142
|
init_lexer();
|
|
16079
16143
|
init_pdf();
|
|
16080
16144
|
init_policy();
|
|
@@ -16096,6 +16160,7 @@ var init_copy = __esm({
|
|
|
16096
16160
|
this.ref = ref;
|
|
16097
16161
|
}
|
|
16098
16162
|
};
|
|
16163
|
+
AUDIT = () => "null";
|
|
16099
16164
|
OPEN_A = new Raw("[");
|
|
16100
16165
|
CLOSE_A = new Raw("]");
|
|
16101
16166
|
OPEN_D = new Raw("<<");
|
|
@@ -16103,7 +16168,7 @@ var init_copy = __esm({
|
|
|
16103
16168
|
}
|
|
16104
16169
|
});
|
|
16105
16170
|
|
|
16106
|
-
//
|
|
16171
|
+
// src/reader/fill.js
|
|
16107
16172
|
function utf162(s) {
|
|
16108
16173
|
const b = new Uint8Array(2 + s.length * 2);
|
|
16109
16174
|
b[0] = 254;
|
|
@@ -16271,7 +16336,7 @@ async function fillReplacements(self, o) {
|
|
|
16271
16336
|
}
|
|
16272
16337
|
var ALIAS;
|
|
16273
16338
|
var init_fill = __esm({
|
|
16274
|
-
"
|
|
16339
|
+
"src/reader/fill.js"() {
|
|
16275
16340
|
init_index();
|
|
16276
16341
|
init_standard();
|
|
16277
16342
|
init_lexer();
|
|
@@ -16283,7 +16348,7 @@ var init_fill = __esm({
|
|
|
16283
16348
|
}
|
|
16284
16349
|
});
|
|
16285
16350
|
|
|
16286
|
-
//
|
|
16351
|
+
// src/reader/save.js
|
|
16287
16352
|
var save_exports = {};
|
|
16288
16353
|
__export(save_exports, {
|
|
16289
16354
|
MAX_OPEN: () => MAX_OPEN,
|
|
@@ -16394,6 +16459,8 @@ async function run(self, sink, o) {
|
|
|
16394
16459
|
signal: o.signal,
|
|
16395
16460
|
timeoutMs: o.timeoutMs,
|
|
16396
16461
|
creationDate: created,
|
|
16462
|
+
metadata: !!(level || self.edits.xmp != null || self.xmp() != null),
|
|
16463
|
+
// an XMP packet only when the source had one or PDF/A needs one: a file split into pages is not a kilobyte of XMP each
|
|
16397
16464
|
title: info.title ?? void 0,
|
|
16398
16465
|
author: info.author ?? void 0,
|
|
16399
16466
|
subject: info.subject ?? void 0,
|
|
@@ -16710,7 +16777,7 @@ function sameBytes(a, b) {
|
|
|
16710
16777
|
}
|
|
16711
16778
|
var MAX_OPEN, KEYS2, OWN;
|
|
16712
16779
|
var init_save = __esm({
|
|
16713
|
-
"
|
|
16780
|
+
"src/reader/save.js"() {
|
|
16714
16781
|
init_index();
|
|
16715
16782
|
init_page();
|
|
16716
16783
|
init_annot();
|
|
@@ -16728,7 +16795,7 @@ var init_save = __esm({
|
|
|
16728
16795
|
}
|
|
16729
16796
|
});
|
|
16730
16797
|
|
|
16731
|
-
//
|
|
16798
|
+
// src/reader/active.js
|
|
16732
16799
|
function findActive(self, each) {
|
|
16733
16800
|
const found = /* @__PURE__ */ new Map();
|
|
16734
16801
|
const audit = createCopier({
|
|
@@ -16754,12 +16821,12 @@ function findActive(self, each) {
|
|
|
16754
16821
|
return [...found].map(([what, count]) => ({ what, count }));
|
|
16755
16822
|
}
|
|
16756
16823
|
var init_active = __esm({
|
|
16757
|
-
"
|
|
16824
|
+
"src/reader/active.js"() {
|
|
16758
16825
|
init_copy();
|
|
16759
16826
|
}
|
|
16760
16827
|
});
|
|
16761
16828
|
|
|
16762
|
-
//
|
|
16829
|
+
// src/reader/incremental.js
|
|
16763
16830
|
var incremental_exports = {};
|
|
16764
16831
|
__export(incremental_exports, {
|
|
16765
16832
|
MAX_WIDGET_SHARE: () => MAX_WIDGET_SHARE,
|
|
@@ -17263,7 +17330,7 @@ function checkSigned(self, sig, o, objects, who) {
|
|
|
17263
17330
|
}
|
|
17264
17331
|
var SIGN_KEYS, MAX_WIDGET_SHARE, TRANSFORMS, isSigDict;
|
|
17265
17332
|
var init_incremental = __esm({
|
|
17266
|
-
"
|
|
17333
|
+
"src/reader/incremental.js"() {
|
|
17267
17334
|
init_lexer();
|
|
17268
17335
|
init_copy();
|
|
17269
17336
|
init_active();
|
|
@@ -17283,7 +17350,7 @@ var init_incremental = __esm({
|
|
|
17283
17350
|
}
|
|
17284
17351
|
});
|
|
17285
17352
|
|
|
17286
|
-
//
|
|
17353
|
+
// src/reader/pdf.js
|
|
17287
17354
|
function internal(v, who) {
|
|
17288
17355
|
const d = v !== null && typeof v === "object" ? inside2.get(v) : void 0;
|
|
17289
17356
|
if (!d) throw new TypeError(`${who}: not a document from loadPdf`);
|
|
@@ -17990,7 +18057,7 @@ function checkValue(f, v) {
|
|
|
17990
18057
|
}
|
|
17991
18058
|
var MAX_PAGES, MAX_OUTLINE, MAX_FIELDS2, MAX_NAMES2, inside2, ACTIVE_FT;
|
|
17992
18059
|
var init_pdf = __esm({
|
|
17993
|
-
"
|
|
18060
|
+
"src/reader/pdf.js"() {
|
|
17994
18061
|
init_budget();
|
|
17995
18062
|
init_source();
|
|
17996
18063
|
init_lexer();
|
|
@@ -18005,7 +18072,137 @@ var init_pdf = __esm({
|
|
|
18005
18072
|
}
|
|
18006
18073
|
});
|
|
18007
18074
|
|
|
18008
|
-
//
|
|
18075
|
+
// src/bulk.js
|
|
18076
|
+
function bytesOf2(b) {
|
|
18077
|
+
if (b instanceof Uint8Array) return b;
|
|
18078
|
+
if (b instanceof ArrayBuffer) return new Uint8Array(b);
|
|
18079
|
+
throw new TypeError("bulk: an input is a Uint8Array or an ArrayBuffer");
|
|
18080
|
+
}
|
|
18081
|
+
async function runOne(task, input, o) {
|
|
18082
|
+
try {
|
|
18083
|
+
return { ok: true, value: await TASKS[task](input, o) };
|
|
18084
|
+
} catch (e) {
|
|
18085
|
+
return { ok: false, error: errorOf(e) };
|
|
18086
|
+
}
|
|
18087
|
+
}
|
|
18088
|
+
async function bulk(inputs, task, o = {}) {
|
|
18089
|
+
if (!Object.hasOwn(TASKS, task)) throw new TypeError(`bulk: task is one of ${BULK_TASKS.join(", ")}`);
|
|
18090
|
+
if (o == null || typeof o !== "object") throw new TypeError("bulk: options are { workers, memoryMb, password, budget, timeoutMs, encrypt, save }");
|
|
18091
|
+
const list = [...inputs];
|
|
18092
|
+
const { workers: w0, memoryMb = 512, onResult, ...taskOpts } = o;
|
|
18093
|
+
const node = (
|
|
18094
|
+
/** @type {any} */
|
|
18095
|
+
globalThis.process?.getBuiltinModule
|
|
18096
|
+
);
|
|
18097
|
+
const wt = node?.("node:worker_threads"), os = node?.("node:os");
|
|
18098
|
+
const auto = os ? Math.max(1, (os.availableParallelism?.() ?? os.cpus().length) - 1) : 1;
|
|
18099
|
+
const n = Math.min(list.length, w0 == null ? auto : w0);
|
|
18100
|
+
if (!Number.isInteger(n) || n < 0) throw new TypeError("bulk: workers is a positive integer");
|
|
18101
|
+
if (!Number.isFinite(memoryMb) || memoryMb < 16) throw new TypeError("bulk: memoryMb is at least 16");
|
|
18102
|
+
const results = new Array(list.length);
|
|
18103
|
+
const done = (i2, r) => {
|
|
18104
|
+
results[i2] = r;
|
|
18105
|
+
onResult?.(i2, r);
|
|
18106
|
+
};
|
|
18107
|
+
if (!wt || n <= 1) {
|
|
18108
|
+
for (let i2 = 0; i2 < list.length; i2++) done(i2, await runOne(task, list[i2], taskOpts));
|
|
18109
|
+
return results;
|
|
18110
|
+
}
|
|
18111
|
+
let next = 0;
|
|
18112
|
+
const url = import.meta.url;
|
|
18113
|
+
const spawn = () => new wt.Worker(`import(${JSON.stringify(url)}).then((m) => m.__bulkWorker())`, { eval: true, resourceLimits: { maxOldGenerationSizeMb: memoryMb } });
|
|
18114
|
+
const lane = async () => {
|
|
18115
|
+
let worker = spawn();
|
|
18116
|
+
try {
|
|
18117
|
+
while (next < list.length) {
|
|
18118
|
+
const i2 = next++;
|
|
18119
|
+
const r = await new Promise((resolve2) => {
|
|
18120
|
+
const off = () => {
|
|
18121
|
+
worker.off("message", ok);
|
|
18122
|
+
worker.off("error", bad);
|
|
18123
|
+
worker.off("exit", gone);
|
|
18124
|
+
};
|
|
18125
|
+
const ok = (m) => {
|
|
18126
|
+
off();
|
|
18127
|
+
resolve2(m);
|
|
18128
|
+
};
|
|
18129
|
+
const bad = (e) => {
|
|
18130
|
+
off();
|
|
18131
|
+
resolve2({ ok: false, error: { ...errorOf(e), code: "E_WORKER" }, dead: true });
|
|
18132
|
+
};
|
|
18133
|
+
const gone = (c) => {
|
|
18134
|
+
off();
|
|
18135
|
+
resolve2({ ok: false, error: { name: "Error", code: "E_WORKER", message: `the worker stopped (exit ${c}), out of memory (memoryMb) or crashed` }, dead: true });
|
|
18136
|
+
};
|
|
18137
|
+
worker.on("message", ok);
|
|
18138
|
+
worker.once("error", bad);
|
|
18139
|
+
worker.once("exit", gone);
|
|
18140
|
+
worker.postMessage({ task, input: list[i2], o: taskOpts });
|
|
18141
|
+
});
|
|
18142
|
+
if (r.dead) {
|
|
18143
|
+
worker.terminate();
|
|
18144
|
+
worker = spawn();
|
|
18145
|
+
delete r.dead;
|
|
18146
|
+
}
|
|
18147
|
+
done(i2, r);
|
|
18148
|
+
}
|
|
18149
|
+
} finally {
|
|
18150
|
+
await worker.terminate();
|
|
18151
|
+
}
|
|
18152
|
+
};
|
|
18153
|
+
await Promise.all(Array.from({ length: n }, lane));
|
|
18154
|
+
return results;
|
|
18155
|
+
}
|
|
18156
|
+
function __bulkWorker() {
|
|
18157
|
+
const { parentPort } = (
|
|
18158
|
+
/** @type {any} */
|
|
18159
|
+
globalThis.process.getBuiltinModule("node:worker_threads")
|
|
18160
|
+
);
|
|
18161
|
+
parentPort.on("message", async (m) => {
|
|
18162
|
+
const r = await runOne(m.task, m.input, m.o);
|
|
18163
|
+
const v = r.ok ? r.value : null;
|
|
18164
|
+
const transfer = v instanceof Uint8Array ? [v.buffer] : Array.isArray(v) ? v.filter((x2) => x2 instanceof Uint8Array).map((x2) => x2.buffer) : [];
|
|
18165
|
+
try {
|
|
18166
|
+
parentPort.postMessage(r, [...new Set(transfer)].filter((b) => b instanceof ArrayBuffer));
|
|
18167
|
+
} catch {
|
|
18168
|
+
parentPort.postMessage(r);
|
|
18169
|
+
}
|
|
18170
|
+
});
|
|
18171
|
+
}
|
|
18172
|
+
var TASKS, BULK_TASKS, load, errorOf;
|
|
18173
|
+
var init_bulk = __esm({
|
|
18174
|
+
"src/bulk.js"() {
|
|
18175
|
+
init_pdf();
|
|
18176
|
+
TASKS = {
|
|
18177
|
+
/** bytes → the text of every page ('\f' between pages) */
|
|
18178
|
+
extractText: async (input, o) => (await loadPdf(bytesOf2(input), load(o))).extractText(),
|
|
18179
|
+
/** [bytes, bytes, …] → one file */
|
|
18180
|
+
merge: async (input, o) => {
|
|
18181
|
+
if (!Array.isArray(input) || !input.length) throw new TypeError("bulk merge: each input is an array of files");
|
|
18182
|
+
const docs = [];
|
|
18183
|
+
for (const b of input) docs.push(await loadPdf(bytesOf2(b), load(o)));
|
|
18184
|
+
return (await docs[0].fork().merge(docs.slice(1)).save(o.save)).bytes;
|
|
18185
|
+
},
|
|
18186
|
+
/** bytes → one file per page */
|
|
18187
|
+
split: async (input, o) => {
|
|
18188
|
+
const d = await loadPdf(bytesOf2(input), load(o));
|
|
18189
|
+
const out = [];
|
|
18190
|
+
for (let i2 = 0; i2 < d.pageCount; i2++) out.push((await d.fork().reorder([i2]).save(o.save)).bytes);
|
|
18191
|
+
return out;
|
|
18192
|
+
},
|
|
18193
|
+
/** bytes → the file encrypted with o.encrypt (save()'s encrypt option) */
|
|
18194
|
+
encrypt: async (input, o) => {
|
|
18195
|
+
if (o.encrypt == null || typeof o.encrypt !== "object") throw new TypeError("bulk encrypt: options.encrypt is save()'s encrypt option");
|
|
18196
|
+
return (await (await loadPdf(bytesOf2(input), load(o))).save({ ...o.save, encrypt: o.encrypt })).bytes;
|
|
18197
|
+
}
|
|
18198
|
+
};
|
|
18199
|
+
BULK_TASKS = Object.freeze(Object.keys(TASKS));
|
|
18200
|
+
load = (o) => ({ ...o.password != null && { password: o.password }, ...o.budget && { budget: o.budget }, ...o.timeoutMs && { timeoutMs: o.timeoutMs } });
|
|
18201
|
+
errorOf = (e) => ({ name: String(e?.name ?? "Error"), code: e?.code == null ? void 0 : String(e.code), message: String(e?.message ?? e) });
|
|
18202
|
+
}
|
|
18203
|
+
});
|
|
18204
|
+
|
|
18205
|
+
// src/index.js
|
|
18009
18206
|
async function mergePdfs(docs, o) {
|
|
18010
18207
|
if (!Array.isArray(docs) || !docs.length) throw new TypeError("mergePdfs: an array of documents from loadPdf");
|
|
18011
18208
|
return docs[0].fork().merge(docs.slice(1)).save(o);
|
|
@@ -18195,7 +18392,7 @@ async function toBytes2(build, options2) {
|
|
|
18195
18392
|
return all;
|
|
18196
18393
|
}
|
|
18197
18394
|
var init_index = __esm({
|
|
18198
|
-
"
|
|
18395
|
+
"src/index.js"() {
|
|
18199
18396
|
init_sink();
|
|
18200
18397
|
init_document();
|
|
18201
18398
|
init_brand();
|
|
@@ -18225,13 +18422,17 @@ var init_index = __esm({
|
|
|
18225
18422
|
init_cms();
|
|
18226
18423
|
init_pdf();
|
|
18227
18424
|
init_budget();
|
|
18425
|
+
init_bulk();
|
|
18228
18426
|
}
|
|
18229
18427
|
});
|
|
18230
18428
|
init_index();
|
|
18231
18429
|
export {
|
|
18430
|
+
BULK_TASKS,
|
|
18232
18431
|
Page,
|
|
18233
18432
|
PdfReadError,
|
|
18234
18433
|
STANDARD_NAMES,
|
|
18434
|
+
__bulkWorker,
|
|
18435
|
+
bulk,
|
|
18235
18436
|
cmsSigner,
|
|
18236
18437
|
cmyk,
|
|
18237
18438
|
createPdf,
|