@chialab/pdfjs-lib 1.0.0-alpha.11 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{chunk-AK2AE3GS.js → chunk-TKDBOXH4.js} +31 -39
- package/dist/browser/index.js +614 -493
- package/dist/browser/openjpeg-K2XBCFFN.js +9 -0
- package/dist/browser/qcms_bg-Q7BRLLZG.js +9 -0
- package/dist/browser/worker.js +1260 -1121
- package/dist/lib/utils.d.ts +6 -0
- package/dist/node/{chunk-WL32POZ2.js → chunk-MAMMG4XK.js} +31 -39
- package/dist/node/index.js +755 -495
- package/dist/node/openjpeg-B2WN24QZ.js +9 -0
- package/dist/node/qcms_bg-T4RSHPOQ.js +9 -0
- package/dist/node/worker.js +1260 -1121
- package/dist/pdf.js/src/display/annotation_storage.d.ts +1 -8
- package/dist/pdf.js/src/display/api.d.ts +10 -69
- package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
- package/dist/pdf.js/src/display/canvas.d.ts +2 -2
- package/dist/pdf.js/src/display/display_utils.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +4 -4
- package/dist/pdf.js/src/display/editor/editor.d.ts +17 -3
- package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -5
- package/dist/pdf.js/src/display/editor/tools.d.ts +2 -1
- package/dist/pdf.js/src/display/metadata.d.ts +1 -2
- package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
- package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
- package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
- package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +3 -2
- package/dist/pdf.js/src/shared/util.d.ts +12 -5
- package/package.json +1 -1
- package/dist/browser/openjpeg-NLAGCGEG.js +0 -9
- package/dist/browser/qcms_bg-EPYCMBVV.js +0 -9
- package/dist/node/openjpeg-O3KQE6R6.js +0 -9
- package/dist/node/qcms_bg-5Z325MLG.js +0 -9
package/dist/node/worker.js
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
FONT_IDENTITY_MATRIX,
|
|
17
17
|
FeatureTest,
|
|
18
18
|
FormatError,
|
|
19
|
-
IDENTITY_MATRIX,
|
|
20
19
|
ImageKind,
|
|
21
20
|
InvalidPDFException,
|
|
22
21
|
LINE_DESCENT_FACTOR,
|
|
@@ -60,7 +59,7 @@ import {
|
|
|
60
59
|
utf8StringToString,
|
|
61
60
|
warn,
|
|
62
61
|
wrapReason
|
|
63
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-MAMMG4XK.js";
|
|
64
63
|
import {
|
|
65
64
|
__privateAdd,
|
|
66
65
|
__privateGet,
|
|
@@ -484,6 +483,22 @@ var BaseStream = class {
|
|
|
484
483
|
var PDF_VERSION_REGEXP = /^[1-9]\.\d$/;
|
|
485
484
|
var MAX_INT_32 = 2 ** 31 - 1;
|
|
486
485
|
var MIN_INT_32 = -(2 ** 31);
|
|
486
|
+
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
|
487
|
+
var RESOURCES_KEYS_OPERATOR_LIST = [
|
|
488
|
+
"ColorSpace",
|
|
489
|
+
"ExtGState",
|
|
490
|
+
"Font",
|
|
491
|
+
"Pattern",
|
|
492
|
+
"Properties",
|
|
493
|
+
"Shading",
|
|
494
|
+
"XObject"
|
|
495
|
+
];
|
|
496
|
+
var RESOURCES_KEYS_TEXT_CONTENT = [
|
|
497
|
+
"ExtGState",
|
|
498
|
+
"Font",
|
|
499
|
+
"Properties",
|
|
500
|
+
"XObject"
|
|
501
|
+
];
|
|
487
502
|
function getLookupTableFactory(initializer) {
|
|
488
503
|
let lookup;
|
|
489
504
|
return function() {
|
|
@@ -742,7 +757,11 @@ function _collectJS(entry, xref, list, parents) {
|
|
|
742
757
|
} else if (typeof js === "string") {
|
|
743
758
|
code = js;
|
|
744
759
|
}
|
|
745
|
-
code && (code = stringToPDFString(
|
|
760
|
+
code && (code = stringToPDFString(
|
|
761
|
+
code,
|
|
762
|
+
/* keepEscapeSequence = */
|
|
763
|
+
true
|
|
764
|
+
).replaceAll("\0", ""));
|
|
746
765
|
if (code) {
|
|
747
766
|
list.push(code);
|
|
748
767
|
}
|
|
@@ -913,6 +932,12 @@ function recoverJsURL(str) {
|
|
|
913
932
|
return null;
|
|
914
933
|
}
|
|
915
934
|
function numberToString(value) {
|
|
935
|
+
if (false) {
|
|
936
|
+
assert(
|
|
937
|
+
typeof value === "number",
|
|
938
|
+
`numberToString - the value (${value}) should be a number.`
|
|
939
|
+
);
|
|
940
|
+
}
|
|
916
941
|
if (Number.isInteger(value)) {
|
|
917
942
|
return value.toString();
|
|
918
943
|
}
|
|
@@ -1066,7 +1091,8 @@ function copyRgbaImage(src, dest, alpha01) {
|
|
|
1066
1091
|
}
|
|
1067
1092
|
}
|
|
1068
1093
|
}
|
|
1069
|
-
var
|
|
1094
|
+
var _rgbBuf;
|
|
1095
|
+
var _ColorSpace = class _ColorSpace {
|
|
1070
1096
|
constructor(name, numComps) {
|
|
1071
1097
|
if (false) {
|
|
1072
1098
|
unreachable("Cannot initialize ColorSpace.");
|
|
@@ -1079,10 +1105,13 @@ var ColorSpace = class _ColorSpace {
|
|
|
1079
1105
|
* located in the src array starting from the srcOffset. Returns the array
|
|
1080
1106
|
* of the rgb components, each value ranging from [0,255].
|
|
1081
1107
|
*/
|
|
1082
|
-
getRgb(src, srcOffset) {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1108
|
+
getRgb(src, srcOffset, output = new Uint8ClampedArray(3)) {
|
|
1109
|
+
this.getRgbItem(src, srcOffset, output, 0);
|
|
1110
|
+
return output;
|
|
1111
|
+
}
|
|
1112
|
+
getRgbHex(src, srcOffset) {
|
|
1113
|
+
const buffer = this.getRgb(src, srcOffset, __privateGet(_ColorSpace, _rgbBuf));
|
|
1114
|
+
return Util.makeHexColor(buffer[0], buffer[1], buffer[2]);
|
|
1086
1115
|
}
|
|
1087
1116
|
/**
|
|
1088
1117
|
* Converts the color value to the RGB color, similar to the getRgb method.
|
|
@@ -1246,6 +1275,9 @@ var ColorSpace = class _ColorSpace {
|
|
|
1246
1275
|
return true;
|
|
1247
1276
|
}
|
|
1248
1277
|
};
|
|
1278
|
+
_rgbBuf = new WeakMap();
|
|
1279
|
+
__privateAdd(_ColorSpace, _rgbBuf, new Uint8ClampedArray(3));
|
|
1280
|
+
var ColorSpace = _ColorSpace;
|
|
1249
1281
|
var AlternateCS = class extends ColorSpace {
|
|
1250
1282
|
constructor(numComps, base, tintFn) {
|
|
1251
1283
|
super("Alternate", numComps);
|
|
@@ -1321,6 +1353,7 @@ var IndexedCS = class extends ColorSpace {
|
|
|
1321
1353
|
constructor(base, highVal, lookup) {
|
|
1322
1354
|
super("Indexed", 1);
|
|
1323
1355
|
this.base = base;
|
|
1356
|
+
this.highVal = highVal;
|
|
1324
1357
|
const length = base.numComps * (highVal + 1);
|
|
1325
1358
|
this.lookup = new Uint8Array(length);
|
|
1326
1359
|
if (lookup instanceof BaseStream) {
|
|
@@ -1341,9 +1374,9 @@ var IndexedCS = class extends ColorSpace {
|
|
|
1341
1374
|
'IndexedCS.getRgbItem: Unsupported "dest" type.'
|
|
1342
1375
|
);
|
|
1343
1376
|
}
|
|
1344
|
-
const
|
|
1345
|
-
const start = src[srcOffset] * numComps;
|
|
1346
|
-
|
|
1377
|
+
const { base, highVal, lookup } = this;
|
|
1378
|
+
const start = MathClamp(Math.round(src[srcOffset]), 0, highVal) * base.numComps;
|
|
1379
|
+
base.getRgbBuffer(lookup, start, 1, dest, destOffset, 8, 0);
|
|
1347
1380
|
}
|
|
1348
1381
|
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
|
1349
1382
|
if (false) {
|
|
@@ -1352,12 +1385,11 @@ var IndexedCS = class extends ColorSpace {
|
|
|
1352
1385
|
'IndexedCS.getRgbBuffer: Unsupported "dest" type.'
|
|
1353
1386
|
);
|
|
1354
1387
|
}
|
|
1355
|
-
const base = this
|
|
1356
|
-
const numComps = base
|
|
1388
|
+
const { base, highVal, lookup } = this;
|
|
1389
|
+
const { numComps } = base;
|
|
1357
1390
|
const outputDelta = base.getOutputLength(numComps, alpha01);
|
|
1358
|
-
const lookup = this.lookup;
|
|
1359
1391
|
for (let i = 0; i < count; ++i) {
|
|
1360
|
-
const lookupPos = src[srcOffset++] * numComps;
|
|
1392
|
+
const lookupPos = MathClamp(Math.round(src[srcOffset++]), 0, highVal) * numComps;
|
|
1361
1393
|
base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
|
|
1362
1394
|
destOffset += outputDelta;
|
|
1363
1395
|
}
|
|
@@ -1956,35 +1988,59 @@ toRgb_fn4 = function(src, srcOffset, maxVal, dest, destOffset) {
|
|
|
1956
1988
|
};
|
|
1957
1989
|
|
|
1958
1990
|
// src/pdf.js/external/qcms/qcms_utils.js
|
|
1991
|
+
var _memoryArray;
|
|
1959
1992
|
var QCMS = class {
|
|
1993
|
+
static get _memoryArray() {
|
|
1994
|
+
const array = __privateGet(this, _memoryArray);
|
|
1995
|
+
if (array?.byteLength) {
|
|
1996
|
+
return array;
|
|
1997
|
+
}
|
|
1998
|
+
return __privateSet(this, _memoryArray, new Uint8Array(this._memory.buffer));
|
|
1999
|
+
}
|
|
1960
2000
|
};
|
|
1961
|
-
|
|
2001
|
+
_memoryArray = new WeakMap();
|
|
2002
|
+
__privateAdd(QCMS, _memoryArray, null);
|
|
2003
|
+
__publicField(QCMS, "_memory", null);
|
|
1962
2004
|
__publicField(QCMS, "_mustAddAlpha", false);
|
|
1963
2005
|
__publicField(QCMS, "_destBuffer", null);
|
|
2006
|
+
__publicField(QCMS, "_destOffset", 0);
|
|
2007
|
+
__publicField(QCMS, "_destLength", 0);
|
|
2008
|
+
__publicField(QCMS, "_cssColor", "");
|
|
2009
|
+
__publicField(QCMS, "_makeHexColor", null);
|
|
1964
2010
|
function copy_result(ptr, len) {
|
|
1965
|
-
const {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
_destBuffer.set(result);
|
|
2011
|
+
const { _mustAddAlpha, _destBuffer, _destOffset, _destLength, _memoryArray: _memoryArray2 } = QCMS;
|
|
2012
|
+
if (len === _destLength) {
|
|
2013
|
+
_destBuffer.set(_memoryArray2.subarray(ptr, ptr + len), _destOffset);
|
|
1969
2014
|
return;
|
|
1970
2015
|
}
|
|
1971
2016
|
if (_mustAddAlpha) {
|
|
1972
|
-
for (let i =
|
|
1973
|
-
_destBuffer[j] =
|
|
1974
|
-
_destBuffer[j + 1] =
|
|
1975
|
-
_destBuffer[j + 2] =
|
|
2017
|
+
for (let i = ptr, ii = ptr + len, j = _destOffset; i < ii; i += 3, j += 4) {
|
|
2018
|
+
_destBuffer[j] = _memoryArray2[i];
|
|
2019
|
+
_destBuffer[j + 1] = _memoryArray2[i + 1];
|
|
2020
|
+
_destBuffer[j + 2] = _memoryArray2[i + 2];
|
|
1976
2021
|
_destBuffer[j + 3] = 255;
|
|
1977
2022
|
}
|
|
1978
2023
|
} else {
|
|
1979
|
-
for (let i =
|
|
1980
|
-
_destBuffer[j] =
|
|
1981
|
-
_destBuffer[j + 1] =
|
|
1982
|
-
_destBuffer[j + 2] =
|
|
2024
|
+
for (let i = ptr, ii = ptr + len, j = _destOffset; i < ii; i += 3, j += 4) {
|
|
2025
|
+
_destBuffer[j] = _memoryArray2[i];
|
|
2026
|
+
_destBuffer[j + 1] = _memoryArray2[i + 1];
|
|
2027
|
+
_destBuffer[j + 2] = _memoryArray2[i + 2];
|
|
1983
2028
|
}
|
|
1984
2029
|
}
|
|
1985
2030
|
}
|
|
1986
2031
|
function copy_rgb(ptr) {
|
|
1987
|
-
|
|
2032
|
+
const { _destBuffer, _destOffset, _memoryArray: _memoryArray2 } = QCMS;
|
|
2033
|
+
_destBuffer[_destOffset] = _memoryArray2[ptr];
|
|
2034
|
+
_destBuffer[_destOffset + 1] = _memoryArray2[ptr + 1];
|
|
2035
|
+
_destBuffer[_destOffset + 2] = _memoryArray2[ptr + 2];
|
|
2036
|
+
}
|
|
2037
|
+
function make_cssRGB(ptr) {
|
|
2038
|
+
const { _memoryArray: _memoryArray2 } = QCMS;
|
|
2039
|
+
QCMS._cssColor = QCMS._makeHexColor(
|
|
2040
|
+
_memoryArray2[ptr],
|
|
2041
|
+
_memoryArray2[ptr + 1],
|
|
2042
|
+
_memoryArray2[ptr + 2]
|
|
2043
|
+
);
|
|
1988
2044
|
}
|
|
1989
2045
|
|
|
1990
2046
|
// src/pdf.js/external/qcms/qcms.js
|
|
@@ -2018,14 +2074,14 @@ function qcms_convert_array(transformer, src) {
|
|
|
2018
2074
|
const len0 = WASM_VECTOR_LEN;
|
|
2019
2075
|
wasm.qcms_convert_array(transformer, ptr0, len0);
|
|
2020
2076
|
}
|
|
2021
|
-
function qcms_convert_one(transformer, src) {
|
|
2022
|
-
wasm.qcms_convert_one(transformer, src);
|
|
2077
|
+
function qcms_convert_one(transformer, src, css) {
|
|
2078
|
+
wasm.qcms_convert_one(transformer, src, css);
|
|
2023
2079
|
}
|
|
2024
|
-
function qcms_convert_three(transformer, src1, src2, src3) {
|
|
2025
|
-
wasm.qcms_convert_three(transformer, src1, src2, src3);
|
|
2080
|
+
function qcms_convert_three(transformer, src1, src2, src3, css) {
|
|
2081
|
+
wasm.qcms_convert_three(transformer, src1, src2, src3, css);
|
|
2026
2082
|
}
|
|
2027
|
-
function qcms_convert_four(transformer, src1, src2, src3, src4) {
|
|
2028
|
-
wasm.qcms_convert_four(transformer, src1, src2, src3, src4);
|
|
2083
|
+
function qcms_convert_four(transformer, src1, src2, src3, src4, css) {
|
|
2084
|
+
wasm.qcms_convert_four(transformer, src1, src2, src3, src4, css);
|
|
2029
2085
|
}
|
|
2030
2086
|
function qcms_transformer_from_memory(mem, in_type, intent) {
|
|
2031
2087
|
const ptr0 = passArray8ToWasm0(mem, wasm.__wbindgen_malloc);
|
|
@@ -2093,6 +2149,9 @@ function __wbg_get_imports() {
|
|
|
2093
2149
|
imports.wbg.__wbg_copyrgb_d60ce17bb05d9b67 = function(arg0) {
|
|
2094
2150
|
copy_rgb(arg0 >>> 0);
|
|
2095
2151
|
};
|
|
2152
|
+
imports.wbg.__wbg_makecssRGB_893bf0cd9fdb302d = function(arg0) {
|
|
2153
|
+
make_cssRGB(arg0 >>> 0);
|
|
2154
|
+
};
|
|
2096
2155
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
2097
2156
|
const table = wasm.__wbindgen_export_0;
|
|
2098
2157
|
const offset = table.grow(4);
|
|
@@ -2143,9 +2202,6 @@ async function __wbg_init(module_or_path) {
|
|
|
2143
2202
|
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
2144
2203
|
}
|
|
2145
2204
|
}
|
|
2146
|
-
if (typeof module_or_path === "undefined") {
|
|
2147
|
-
module_or_path = new URL("qcms_bg.wasm", import.meta.url);
|
|
2148
|
-
}
|
|
2149
2205
|
const imports = __wbg_get_imports();
|
|
2150
2206
|
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
2151
2207
|
module_or_path = fetch(module_or_path);
|
|
@@ -2176,25 +2232,27 @@ var _IccColorSpace = class _IccColorSpace extends ColorSpace {
|
|
|
2176
2232
|
switch (numComps) {
|
|
2177
2233
|
case 1:
|
|
2178
2234
|
inType = DataType.Gray8;
|
|
2179
|
-
__privateSet(this, _convertPixel, (src, srcOffset) => qcms_convert_one(__privateGet(this, _transformer), src[srcOffset] * 255));
|
|
2235
|
+
__privateSet(this, _convertPixel, (src, srcOffset, css) => qcms_convert_one(__privateGet(this, _transformer), src[srcOffset] * 255, css));
|
|
2180
2236
|
break;
|
|
2181
2237
|
case 3:
|
|
2182
2238
|
inType = DataType.RGB8;
|
|
2183
|
-
__privateSet(this, _convertPixel, (src, srcOffset) => qcms_convert_three(
|
|
2239
|
+
__privateSet(this, _convertPixel, (src, srcOffset, css) => qcms_convert_three(
|
|
2184
2240
|
__privateGet(this, _transformer),
|
|
2185
2241
|
src[srcOffset] * 255,
|
|
2186
2242
|
src[srcOffset + 1] * 255,
|
|
2187
|
-
src[srcOffset + 2] * 255
|
|
2243
|
+
src[srcOffset + 2] * 255,
|
|
2244
|
+
css
|
|
2188
2245
|
));
|
|
2189
2246
|
break;
|
|
2190
2247
|
case 4:
|
|
2191
2248
|
inType = DataType.CMYK;
|
|
2192
|
-
__privateSet(this, _convertPixel, (src, srcOffset) => qcms_convert_four(
|
|
2249
|
+
__privateSet(this, _convertPixel, (src, srcOffset, css) => qcms_convert_four(
|
|
2193
2250
|
__privateGet(this, _transformer),
|
|
2194
2251
|
src[srcOffset] * 255,
|
|
2195
2252
|
src[srcOffset + 1] * 255,
|
|
2196
2253
|
src[srcOffset + 2] * 255,
|
|
2197
|
-
src[srcOffset + 3] * 255
|
|
2254
|
+
src[srcOffset + 3] * 255,
|
|
2255
|
+
css
|
|
2198
2256
|
));
|
|
2199
2257
|
break;
|
|
2200
2258
|
default:
|
|
@@ -2210,9 +2268,27 @@ var _IccColorSpace = class _IccColorSpace extends ColorSpace {
|
|
|
2210
2268
|
}
|
|
2211
2269
|
__privateGet(_IccColorSpace, _finalizer).register(this, __privateGet(this, _transformer));
|
|
2212
2270
|
}
|
|
2271
|
+
getRgbHex(src, srcOffset) {
|
|
2272
|
+
__privateGet(this, _convertPixel).call(
|
|
2273
|
+
this,
|
|
2274
|
+
src,
|
|
2275
|
+
srcOffset,
|
|
2276
|
+
/* css */
|
|
2277
|
+
true
|
|
2278
|
+
);
|
|
2279
|
+
return QCMS._cssColor;
|
|
2280
|
+
}
|
|
2213
2281
|
getRgbItem(src, srcOffset, dest, destOffset) {
|
|
2214
|
-
QCMS._destBuffer = dest
|
|
2215
|
-
|
|
2282
|
+
QCMS._destBuffer = dest;
|
|
2283
|
+
QCMS._destOffset = destOffset;
|
|
2284
|
+
QCMS._destLength = 3;
|
|
2285
|
+
__privateGet(this, _convertPixel).call(
|
|
2286
|
+
this,
|
|
2287
|
+
src,
|
|
2288
|
+
srcOffset,
|
|
2289
|
+
/* css */
|
|
2290
|
+
false
|
|
2291
|
+
);
|
|
2216
2292
|
QCMS._destBuffer = null;
|
|
2217
2293
|
}
|
|
2218
2294
|
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
|
@@ -2224,10 +2300,9 @@ var _IccColorSpace = class _IccColorSpace extends ColorSpace {
|
|
|
2224
2300
|
}
|
|
2225
2301
|
}
|
|
2226
2302
|
QCMS._mustAddAlpha = alpha01 && dest.buffer === src.buffer;
|
|
2227
|
-
QCMS._destBuffer = dest
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
);
|
|
2303
|
+
QCMS._destBuffer = dest;
|
|
2304
|
+
QCMS._destOffset = destOffset;
|
|
2305
|
+
QCMS._destLength = count * (3 + alpha01);
|
|
2231
2306
|
qcms_convert_array(__privateGet(this, _transformer), src);
|
|
2232
2307
|
QCMS._mustAddAlpha = false;
|
|
2233
2308
|
QCMS._destBuffer = null;
|
|
@@ -2248,10 +2323,12 @@ var _IccColorSpace = class _IccColorSpace extends ColorSpace {
|
|
|
2248
2323
|
if (__privateGet(this, _useWasm)) {
|
|
2249
2324
|
if (__privateGet(this, _wasmUrl)) {
|
|
2250
2325
|
try {
|
|
2251
|
-
this._module =
|
|
2326
|
+
this._module = initSync({
|
|
2252
2327
|
module: fetchSync(`${__privateGet(this, _wasmUrl)}qcms_bg.wasm`)
|
|
2253
2328
|
});
|
|
2254
2329
|
isUsable = !!this._module;
|
|
2330
|
+
QCMS._memory = this._module.memory;
|
|
2331
|
+
QCMS._makeHexColor = Util.makeHexColor;
|
|
2255
2332
|
} catch (e) {
|
|
2256
2333
|
warn(`ICCBased color space: "${e}".`);
|
|
2257
2334
|
}
|
|
@@ -5715,7 +5792,13 @@ var FlateStream = class extends DecodeStream {
|
|
|
5715
5792
|
}
|
|
5716
5793
|
async getImageData(length, _decoderOptions) {
|
|
5717
5794
|
const data = await this.asyncGetBytes();
|
|
5718
|
-
|
|
5795
|
+
if (!data) {
|
|
5796
|
+
return this.getBytes(length);
|
|
5797
|
+
}
|
|
5798
|
+
if (data.length <= length) {
|
|
5799
|
+
return data;
|
|
5800
|
+
}
|
|
5801
|
+
return data.subarray(0, length);
|
|
5719
5802
|
}
|
|
5720
5803
|
async asyncGetBytes() {
|
|
5721
5804
|
this.str.reset();
|
|
@@ -9671,8 +9754,7 @@ __privateAdd(_JpegStream, _isImageDecoderSupported, FeatureTest.isImageDecoderSu
|
|
|
9671
9754
|
var JpegStream = _JpegStream;
|
|
9672
9755
|
|
|
9673
9756
|
// src/pdf.js/external/openjpeg/openjpeg.js
|
|
9674
|
-
var OpenJPEG = (() => {
|
|
9675
|
-
var _scriptName = import.meta.url;
|
|
9757
|
+
var OpenJPEG = /* @__PURE__ */ (() => {
|
|
9676
9758
|
return async function(moduleArg = {}) {
|
|
9677
9759
|
var moduleRtn;
|
|
9678
9760
|
var Module = moduleArg;
|
|
@@ -9683,12 +9765,12 @@ var OpenJPEG = (() => {
|
|
|
9683
9765
|
});
|
|
9684
9766
|
var ENVIRONMENT_IS_WEB = true;
|
|
9685
9767
|
var ENVIRONMENT_IS_WORKER = false;
|
|
9686
|
-
var moduleOverrides = Object.assign({}, Module);
|
|
9687
9768
|
var arguments_ = [];
|
|
9688
9769
|
var thisProgram = "./this.program";
|
|
9689
9770
|
var quit_ = (status, toThrow) => {
|
|
9690
9771
|
throw toThrow;
|
|
9691
9772
|
};
|
|
9773
|
+
var _scriptName = import.meta.url;
|
|
9692
9774
|
var scriptDirectory = "";
|
|
9693
9775
|
function locateFile(path) {
|
|
9694
9776
|
if (Module["locateFile"]) {
|
|
@@ -9698,18 +9780,9 @@ var OpenJPEG = (() => {
|
|
|
9698
9780
|
}
|
|
9699
9781
|
var readAsync, readBinary;
|
|
9700
9782
|
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
9701
|
-
|
|
9702
|
-
scriptDirectory =
|
|
9703
|
-
}
|
|
9704
|
-
scriptDirectory = document.currentScript.src;
|
|
9705
|
-
}
|
|
9706
|
-
if (_scriptName) {
|
|
9707
|
-
scriptDirectory = _scriptName;
|
|
9708
|
-
}
|
|
9709
|
-
if (scriptDirectory.startsWith("blob:")) {
|
|
9710
|
-
scriptDirectory = "";
|
|
9711
|
-
} else {
|
|
9712
|
-
scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
|
|
9783
|
+
try {
|
|
9784
|
+
scriptDirectory = new URL(".", _scriptName).href;
|
|
9785
|
+
} catch {
|
|
9713
9786
|
}
|
|
9714
9787
|
{
|
|
9715
9788
|
readAsync = async (url) => {
|
|
@@ -9722,13 +9795,9 @@ var OpenJPEG = (() => {
|
|
|
9722
9795
|
}
|
|
9723
9796
|
} else {
|
|
9724
9797
|
}
|
|
9725
|
-
var out =
|
|
9726
|
-
var err =
|
|
9727
|
-
|
|
9728
|
-
moduleOverrides = null;
|
|
9729
|
-
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
9730
|
-
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
9731
|
-
var wasmBinary = Module["wasmBinary"];
|
|
9798
|
+
var out = console.log.bind(console);
|
|
9799
|
+
var err = console.error.bind(console);
|
|
9800
|
+
var wasmBinary;
|
|
9732
9801
|
var wasmMemory;
|
|
9733
9802
|
var ABORT = false;
|
|
9734
9803
|
var EXITSTATUS;
|
|
@@ -9736,16 +9805,16 @@ var OpenJPEG = (() => {
|
|
|
9736
9805
|
var runtimeInitialized = false;
|
|
9737
9806
|
function updateMemoryViews() {
|
|
9738
9807
|
var b = wasmMemory.buffer;
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9808
|
+
HEAP8 = new Int8Array(b);
|
|
9809
|
+
HEAP16 = new Int16Array(b);
|
|
9810
|
+
HEAPU8 = new Uint8Array(b);
|
|
9811
|
+
HEAPU16 = new Uint16Array(b);
|
|
9812
|
+
HEAP32 = new Int32Array(b);
|
|
9813
|
+
HEAPU32 = new Uint32Array(b);
|
|
9814
|
+
HEAPF32 = new Float32Array(b);
|
|
9815
|
+
HEAPF64 = new Float64Array(b);
|
|
9816
|
+
HEAP64 = new BigInt64Array(b);
|
|
9817
|
+
HEAPU64 = new BigUint64Array(b);
|
|
9749
9818
|
}
|
|
9750
9819
|
function preRun() {
|
|
9751
9820
|
if (Module["preRun"]) {
|
|
@@ -9864,8 +9933,7 @@ var OpenJPEG = (() => {
|
|
|
9864
9933
|
if (Module["instantiateWasm"]) {
|
|
9865
9934
|
return new Promise((resolve, reject) => {
|
|
9866
9935
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
9867
|
-
receiveInstance(mod, inst);
|
|
9868
|
-
resolve(mod.exports);
|
|
9936
|
+
resolve(receiveInstance(mod, inst));
|
|
9869
9937
|
});
|
|
9870
9938
|
});
|
|
9871
9939
|
}
|
|
@@ -9892,10 +9960,10 @@ var OpenJPEG = (() => {
|
|
|
9892
9960
|
}
|
|
9893
9961
|
};
|
|
9894
9962
|
var onPostRuns = [];
|
|
9895
|
-
var addOnPostRun = (cb) => onPostRuns.
|
|
9963
|
+
var addOnPostRun = (cb) => onPostRuns.push(cb);
|
|
9896
9964
|
var onPreRuns = [];
|
|
9897
|
-
var addOnPreRun = (cb) => onPreRuns.
|
|
9898
|
-
var noExitRuntime =
|
|
9965
|
+
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
9966
|
+
var noExitRuntime = true;
|
|
9899
9967
|
var __abort_js = () => abort("");
|
|
9900
9968
|
var runtimeKeepaliveCounter = 0;
|
|
9901
9969
|
var __emscripten_runtime_keepalive_clear = () => {
|
|
@@ -10042,27 +10110,75 @@ var OpenJPEG = (() => {
|
|
|
10042
10110
|
}
|
|
10043
10111
|
return getEnvStrings.strings;
|
|
10044
10112
|
};
|
|
10045
|
-
var
|
|
10113
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
10114
|
+
if (!(maxBytesToWrite > 0)) return 0;
|
|
10115
|
+
var startIdx = outIdx;
|
|
10116
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
10046
10117
|
for (var i = 0; i < str.length; ++i) {
|
|
10047
|
-
|
|
10118
|
+
var u = str.charCodeAt(i);
|
|
10119
|
+
if (u >= 55296 && u <= 57343) {
|
|
10120
|
+
var u1 = str.charCodeAt(++i);
|
|
10121
|
+
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
|
|
10122
|
+
}
|
|
10123
|
+
if (u <= 127) {
|
|
10124
|
+
if (outIdx >= endIdx) break;
|
|
10125
|
+
heap[outIdx++] = u;
|
|
10126
|
+
} else if (u <= 2047) {
|
|
10127
|
+
if (outIdx + 1 >= endIdx) break;
|
|
10128
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
10129
|
+
heap[outIdx++] = 128 | u & 63;
|
|
10130
|
+
} else if (u <= 65535) {
|
|
10131
|
+
if (outIdx + 2 >= endIdx) break;
|
|
10132
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
10133
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
10134
|
+
heap[outIdx++] = 128 | u & 63;
|
|
10135
|
+
} else {
|
|
10136
|
+
if (outIdx + 3 >= endIdx) break;
|
|
10137
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
10138
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
10139
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
10140
|
+
heap[outIdx++] = 128 | u & 63;
|
|
10141
|
+
}
|
|
10048
10142
|
}
|
|
10049
|
-
|
|
10143
|
+
heap[outIdx] = 0;
|
|
10144
|
+
return outIdx - startIdx;
|
|
10050
10145
|
};
|
|
10146
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
10051
10147
|
var _environ_get = (__environ, environ_buf) => {
|
|
10052
10148
|
var bufSize = 0;
|
|
10053
|
-
|
|
10149
|
+
var envp = 0;
|
|
10150
|
+
for (var string of getEnvStrings()) {
|
|
10054
10151
|
var ptr = environ_buf + bufSize;
|
|
10055
|
-
HEAPU32[__environ +
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
}
|
|
10152
|
+
HEAPU32[__environ + envp >> 2] = ptr;
|
|
10153
|
+
bufSize += stringToUTF8(string, ptr, Infinity) + 1;
|
|
10154
|
+
envp += 4;
|
|
10155
|
+
}
|
|
10059
10156
|
return 0;
|
|
10060
10157
|
};
|
|
10158
|
+
var lengthBytesUTF8 = (str) => {
|
|
10159
|
+
var len = 0;
|
|
10160
|
+
for (var i = 0; i < str.length; ++i) {
|
|
10161
|
+
var c = str.charCodeAt(i);
|
|
10162
|
+
if (c <= 127) {
|
|
10163
|
+
len++;
|
|
10164
|
+
} else if (c <= 2047) {
|
|
10165
|
+
len += 2;
|
|
10166
|
+
} else if (c >= 55296 && c <= 57343) {
|
|
10167
|
+
len += 4;
|
|
10168
|
+
++i;
|
|
10169
|
+
} else {
|
|
10170
|
+
len += 3;
|
|
10171
|
+
}
|
|
10172
|
+
}
|
|
10173
|
+
return len;
|
|
10174
|
+
};
|
|
10061
10175
|
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
10062
10176
|
var strings = getEnvStrings();
|
|
10063
10177
|
HEAPU32[penviron_count >> 2] = strings.length;
|
|
10064
10178
|
var bufSize = 0;
|
|
10065
|
-
|
|
10179
|
+
for (var string of strings) {
|
|
10180
|
+
bufSize += lengthBytesUTF8(string) + 1;
|
|
10181
|
+
}
|
|
10066
10182
|
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
10067
10183
|
return 0;
|
|
10068
10184
|
};
|
|
@@ -10181,13 +10297,25 @@ var OpenJPEG = (() => {
|
|
|
10181
10297
|
Module.errorMessages += "\n" + message;
|
|
10182
10298
|
}
|
|
10183
10299
|
}
|
|
10300
|
+
var writeArrayToMemory = (array, buffer) => {
|
|
10301
|
+
HEAP8.set(array, buffer);
|
|
10302
|
+
};
|
|
10303
|
+
{
|
|
10304
|
+
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
10305
|
+
if (Module["print"]) out = Module["print"];
|
|
10306
|
+
if (Module["printErr"]) err = Module["printErr"];
|
|
10307
|
+
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
|
|
10308
|
+
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
10309
|
+
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
10310
|
+
}
|
|
10311
|
+
Module["writeArrayToMemory"] = writeArrayToMemory;
|
|
10184
10312
|
var wasmImports = { l: __abort_js, k: __emscripten_runtime_keepalive_clear, m: __setitimer_js, g: _copy_pixels_1, f: _copy_pixels_3, e: _copy_pixels_4, n: _emscripten_resize_heap, p: _environ_get, q: _environ_sizes_get, b: _fd_close, o: _fd_seek, c: _fd_write, r: _gray_to_rgba, i: _graya_to_rgba, d: _jsPrintWarning, j: _proc_exit, h: _rgb_to_rgba, a: _storeErrorMessage };
|
|
10185
10313
|
var wasmExports = await createWasm();
|
|
10186
10314
|
var ___wasm_call_ctors = wasmExports["t"];
|
|
10187
10315
|
var _malloc = Module["_malloc"] = wasmExports["u"];
|
|
10188
10316
|
var _free = Module["_free"] = wasmExports["v"];
|
|
10189
|
-
var _jp2_decode = Module["_jp2_decode"] = wasmExports["
|
|
10190
|
-
var __emscripten_timeout = wasmExports["
|
|
10317
|
+
var _jp2_decode = Module["_jp2_decode"] = wasmExports["w"];
|
|
10318
|
+
var __emscripten_timeout = wasmExports["x"];
|
|
10191
10319
|
function run() {
|
|
10192
10320
|
if (runDependencies > 0) {
|
|
10193
10321
|
dependenciesFulfilled = run;
|
|
@@ -10216,12 +10344,15 @@ var OpenJPEG = (() => {
|
|
|
10216
10344
|
doRun();
|
|
10217
10345
|
}
|
|
10218
10346
|
}
|
|
10219
|
-
|
|
10220
|
-
if (
|
|
10221
|
-
|
|
10222
|
-
Module["preInit"].
|
|
10347
|
+
function preInit() {
|
|
10348
|
+
if (Module["preInit"]) {
|
|
10349
|
+
if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
|
|
10350
|
+
while (Module["preInit"].length > 0) {
|
|
10351
|
+
Module["preInit"].shift()();
|
|
10352
|
+
}
|
|
10223
10353
|
}
|
|
10224
10354
|
}
|
|
10355
|
+
preInit();
|
|
10225
10356
|
run();
|
|
10226
10357
|
moduleRtn = readyPromise;
|
|
10227
10358
|
return moduleRtn;
|
|
@@ -10245,7 +10376,12 @@ var JpxImage = class {
|
|
|
10245
10376
|
__privateSet(this, _handler, handler);
|
|
10246
10377
|
}
|
|
10247
10378
|
}
|
|
10248
|
-
static async decode(bytes, {
|
|
10379
|
+
static async decode(bytes, {
|
|
10380
|
+
numComponents = 4,
|
|
10381
|
+
isIndexedColormap = false,
|
|
10382
|
+
smaskInData = false,
|
|
10383
|
+
reducePower = 0
|
|
10384
|
+
} = {}) {
|
|
10249
10385
|
if (!__privateGet(this, _modulePromise)) {
|
|
10250
10386
|
const { promise, resolve } = Promise.withResolvers();
|
|
10251
10387
|
const promises = [promise];
|
|
@@ -10269,13 +10405,14 @@ var JpxImage = class {
|
|
|
10269
10405
|
try {
|
|
10270
10406
|
const size = bytes.length;
|
|
10271
10407
|
ptr = module._malloc(size);
|
|
10272
|
-
module.
|
|
10408
|
+
module.writeArrayToMemory(bytes, ptr);
|
|
10273
10409
|
const ret = module._jp2_decode(
|
|
10274
10410
|
ptr,
|
|
10275
10411
|
size,
|
|
10276
10412
|
numComponents > 0 ? numComponents : 0,
|
|
10277
10413
|
!!isIndexedColormap,
|
|
10278
|
-
!!smaskInData
|
|
10414
|
+
!!smaskInData,
|
|
10415
|
+
reducePower
|
|
10279
10416
|
);
|
|
10280
10417
|
if (ret) {
|
|
10281
10418
|
const { errorMessages } = module;
|
|
@@ -22429,6 +22566,7 @@ var CFFCompiler = class _CFFCompiler {
|
|
|
22429
22566
|
let out;
|
|
22430
22567
|
const numGlyphsLessNotDef = numGlyphs - 1;
|
|
22431
22568
|
if (isCIDFont) {
|
|
22569
|
+
const nLeft = numGlyphsLessNotDef - 1;
|
|
22432
22570
|
out = new Uint8Array([
|
|
22433
22571
|
2,
|
|
22434
22572
|
// format
|
|
@@ -22436,8 +22574,8 @@ var CFFCompiler = class _CFFCompiler {
|
|
|
22436
22574
|
// first CID upper byte
|
|
22437
22575
|
0,
|
|
22438
22576
|
// first CID lower byte
|
|
22439
|
-
|
|
22440
|
-
|
|
22577
|
+
nLeft >> 8 & 255,
|
|
22578
|
+
nLeft & 255
|
|
22441
22579
|
]);
|
|
22442
22580
|
} else {
|
|
22443
22581
|
const length = 1 + numGlyphsLessNotDef * 2;
|
|
@@ -24278,12 +24416,9 @@ var Commands = class {
|
|
|
24278
24416
|
}
|
|
24279
24417
|
add(cmd, args) {
|
|
24280
24418
|
if (args) {
|
|
24281
|
-
const
|
|
24419
|
+
const { currentTransform } = this;
|
|
24282
24420
|
for (let i = 0, ii = args.length; i < ii; i += 2) {
|
|
24283
|
-
|
|
24284
|
-
const y = args[i + 1];
|
|
24285
|
-
args[i] = a * x + c * y + e;
|
|
24286
|
-
args[i + 1] = b * x + d * y + f;
|
|
24421
|
+
Util.applyTransform(args, currentTransform, i);
|
|
24287
24422
|
}
|
|
24288
24423
|
this.cmds.push(`${cmd}${args.join(" ")}`);
|
|
24289
24424
|
} else {
|
|
@@ -29805,8 +29940,8 @@ var Font = class {
|
|
|
29805
29940
|
case "CIDFontType2":
|
|
29806
29941
|
this.mimetype = "font/opentype";
|
|
29807
29942
|
data = this.checkAndRepair(name, file, properties);
|
|
29943
|
+
adjustWidths(properties);
|
|
29808
29944
|
if (this.isOpenType) {
|
|
29809
|
-
adjustWidths(properties);
|
|
29810
29945
|
type = "OpenType";
|
|
29811
29946
|
}
|
|
29812
29947
|
break;
|
|
@@ -31151,7 +31286,6 @@ var Font = class {
|
|
|
31151
31286
|
if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
|
|
31152
31287
|
cffFile = new Stream(tables["CFF "].data);
|
|
31153
31288
|
cff = new CFFFont(cffFile, properties);
|
|
31154
|
-
adjustWidths(properties);
|
|
31155
31289
|
return this.convert(name, cff, properties);
|
|
31156
31290
|
}
|
|
31157
31291
|
delete tables.glyf;
|
|
@@ -31998,56 +32132,60 @@ var RadialAxialShading = class extends BaseShading {
|
|
|
31998
32132
|
return;
|
|
31999
32133
|
}
|
|
32000
32134
|
const color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
|
|
32001
|
-
let rgbColor;
|
|
32002
32135
|
let iBase = 0;
|
|
32003
32136
|
ratio[0] = t0;
|
|
32004
32137
|
fn(ratio, 0, color, 0);
|
|
32005
|
-
|
|
32006
|
-
|
|
32007
|
-
|
|
32138
|
+
const rgbBuffer = new Uint8ClampedArray(3);
|
|
32139
|
+
cs.getRgb(color, 0, rgbBuffer);
|
|
32140
|
+
let [rBase, gBase, bBase] = rgbBuffer;
|
|
32141
|
+
colorStops.push([0, Util.makeHexColor(rBase, gBase, bBase)]);
|
|
32008
32142
|
let iPrev = 1;
|
|
32009
32143
|
ratio[0] = t0 + step;
|
|
32010
32144
|
fn(ratio, 0, color, 0);
|
|
32011
|
-
|
|
32012
|
-
let
|
|
32013
|
-
let
|
|
32014
|
-
let
|
|
32015
|
-
let
|
|
32016
|
-
let
|
|
32017
|
-
let
|
|
32145
|
+
cs.getRgb(color, 0, rgbBuffer);
|
|
32146
|
+
let [rPrev, gPrev, bPrev] = rgbBuffer;
|
|
32147
|
+
let maxSlopeR = rPrev - rBase + 1;
|
|
32148
|
+
let maxSlopeG = gPrev - gBase + 1;
|
|
32149
|
+
let maxSlopeB = bPrev - bBase + 1;
|
|
32150
|
+
let minSlopeR = rPrev - rBase - 1;
|
|
32151
|
+
let minSlopeG = gPrev - gBase - 1;
|
|
32152
|
+
let minSlopeB = bPrev - bBase - 1;
|
|
32018
32153
|
for (let i = 2; i < NUMBER_OF_SAMPLES; i++) {
|
|
32019
32154
|
ratio[0] = t0 + i * step;
|
|
32020
32155
|
fn(ratio, 0, color, 0);
|
|
32021
|
-
|
|
32156
|
+
cs.getRgb(color, 0, rgbBuffer);
|
|
32157
|
+
const [r, g, b] = rgbBuffer;
|
|
32022
32158
|
const run = i - iBase;
|
|
32023
|
-
maxSlopeR = Math.min(maxSlopeR, (
|
|
32024
|
-
maxSlopeG = Math.min(maxSlopeG, (
|
|
32025
|
-
maxSlopeB = Math.min(maxSlopeB, (
|
|
32026
|
-
minSlopeR = Math.max(minSlopeR, (
|
|
32027
|
-
minSlopeG = Math.max(minSlopeG, (
|
|
32028
|
-
minSlopeB = Math.max(minSlopeB, (
|
|
32159
|
+
maxSlopeR = Math.min(maxSlopeR, (r - rBase + 1) / run);
|
|
32160
|
+
maxSlopeG = Math.min(maxSlopeG, (g - gBase + 1) / run);
|
|
32161
|
+
maxSlopeB = Math.min(maxSlopeB, (b - bBase + 1) / run);
|
|
32162
|
+
minSlopeR = Math.max(minSlopeR, (r - rBase - 1) / run);
|
|
32163
|
+
minSlopeG = Math.max(minSlopeG, (g - gBase - 1) / run);
|
|
32164
|
+
minSlopeB = Math.max(minSlopeB, (b - bBase - 1) / run);
|
|
32029
32165
|
const slopesExist = minSlopeR <= maxSlopeR && minSlopeG <= maxSlopeG && minSlopeB <= maxSlopeB;
|
|
32030
32166
|
if (!slopesExist) {
|
|
32031
|
-
const
|
|
32032
|
-
colorStops.push([iPrev / NUMBER_OF_SAMPLES,
|
|
32033
|
-
maxSlopeR =
|
|
32034
|
-
maxSlopeG =
|
|
32035
|
-
maxSlopeB =
|
|
32036
|
-
minSlopeR =
|
|
32037
|
-
minSlopeG =
|
|
32038
|
-
minSlopeB =
|
|
32167
|
+
const cssColor = Util.makeHexColor(rPrev, gPrev, bPrev);
|
|
32168
|
+
colorStops.push([iPrev / NUMBER_OF_SAMPLES, cssColor]);
|
|
32169
|
+
maxSlopeR = r - rPrev + 1;
|
|
32170
|
+
maxSlopeG = g - gPrev + 1;
|
|
32171
|
+
maxSlopeB = b - bPrev + 1;
|
|
32172
|
+
minSlopeR = r - rPrev - 1;
|
|
32173
|
+
minSlopeG = g - gPrev - 1;
|
|
32174
|
+
minSlopeB = b - bPrev - 1;
|
|
32039
32175
|
iBase = iPrev;
|
|
32040
|
-
|
|
32176
|
+
rBase = rPrev;
|
|
32177
|
+
gBase = gPrev;
|
|
32178
|
+
bBase = bPrev;
|
|
32041
32179
|
}
|
|
32042
32180
|
iPrev = i;
|
|
32043
|
-
|
|
32181
|
+
rPrev = r;
|
|
32182
|
+
gPrev = g;
|
|
32183
|
+
bPrev = b;
|
|
32044
32184
|
}
|
|
32045
|
-
|
|
32046
|
-
colorStops.push([1, cssColor]);
|
|
32185
|
+
colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);
|
|
32047
32186
|
let background = "transparent";
|
|
32048
32187
|
if (dict.has("Background")) {
|
|
32049
|
-
|
|
32050
|
-
background = Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
|
|
32188
|
+
background = cs.getRgbHex(dict.get("Background"), 0);
|
|
32051
32189
|
}
|
|
32052
32190
|
if (!extendStart) {
|
|
32053
32191
|
colorStops.unshift([0, background]);
|
|
@@ -52438,18 +52576,20 @@ addState(
|
|
|
52438
52576
|
const args = argsArray[iFirstConstructPath];
|
|
52439
52577
|
const transform = argsArray[iFirstTransform];
|
|
52440
52578
|
const [, [buffer], minMax] = args;
|
|
52441
|
-
|
|
52442
|
-
|
|
52443
|
-
|
|
52444
|
-
|
|
52445
|
-
|
|
52446
|
-
|
|
52447
|
-
|
|
52448
|
-
|
|
52449
|
-
|
|
52450
|
-
|
|
52451
|
-
|
|
52452
|
-
|
|
52579
|
+
if (minMax) {
|
|
52580
|
+
Util.scaleMinMax(transform, minMax);
|
|
52581
|
+
for (let k = 0, kk = buffer.length; k < kk; ) {
|
|
52582
|
+
switch (buffer[k++]) {
|
|
52583
|
+
case DrawOPS.moveTo:
|
|
52584
|
+
case DrawOPS.lineTo:
|
|
52585
|
+
Util.applyTransform(buffer, transform, k);
|
|
52586
|
+
k += 2;
|
|
52587
|
+
break;
|
|
52588
|
+
case DrawOPS.curveTo:
|
|
52589
|
+
Util.applyTransformToBezier(buffer, transform, k);
|
|
52590
|
+
k += 6;
|
|
52591
|
+
break;
|
|
52592
|
+
}
|
|
52453
52593
|
}
|
|
52454
52594
|
}
|
|
52455
52595
|
fnArray.splice(iFirstSave, 4, OPS.constructPath);
|
|
@@ -52743,6 +52883,23 @@ var _ImageResizer = class _ImageResizer {
|
|
|
52743
52883
|
const maxArea = this.MAX_AREA = __privateGet(this, _goodSquareLength) ** 2;
|
|
52744
52884
|
return area > maxArea;
|
|
52745
52885
|
}
|
|
52886
|
+
static getReducePowerForJPX(width, height, componentsCount) {
|
|
52887
|
+
const area = width * height;
|
|
52888
|
+
const maxJPXArea = 2 ** 30 / (componentsCount * 4);
|
|
52889
|
+
if (!this.needsToBeResized(width, height)) {
|
|
52890
|
+
if (area > maxJPXArea) {
|
|
52891
|
+
return Math.ceil(Math.log2(area / maxJPXArea));
|
|
52892
|
+
}
|
|
52893
|
+
return 0;
|
|
52894
|
+
}
|
|
52895
|
+
const { MAX_DIM, MAX_AREA } = this;
|
|
52896
|
+
const minFactor = Math.max(
|
|
52897
|
+
width / MAX_DIM,
|
|
52898
|
+
height / MAX_DIM,
|
|
52899
|
+
Math.sqrt(area / Math.min(maxJPXArea, MAX_AREA))
|
|
52900
|
+
);
|
|
52901
|
+
return Math.ceil(Math.log2(minFactor));
|
|
52902
|
+
}
|
|
52746
52903
|
static get MAX_DIM() {
|
|
52747
52904
|
return shadow(
|
|
52748
52905
|
this,
|
|
@@ -53138,11 +53295,22 @@ var _PDFImage = class _PDFImage {
|
|
|
53138
53295
|
bitsPerComponent: image.bitsPerComponent
|
|
53139
53296
|
} = JpxImage.parseImageProperties(image.stream));
|
|
53140
53297
|
image.stream.reset();
|
|
53298
|
+
const reducePower = ImageResizer.getReducePowerForJPX(
|
|
53299
|
+
image.width,
|
|
53300
|
+
image.height,
|
|
53301
|
+
image.numComps
|
|
53302
|
+
);
|
|
53141
53303
|
this.jpxDecoderOptions = {
|
|
53142
53304
|
numComponents: 0,
|
|
53143
53305
|
isIndexedColormap: false,
|
|
53144
|
-
smaskInData: dict.has("SMaskInData")
|
|
53306
|
+
smaskInData: dict.has("SMaskInData"),
|
|
53307
|
+
reducePower
|
|
53145
53308
|
};
|
|
53309
|
+
if (reducePower) {
|
|
53310
|
+
const factor = 2 ** reducePower;
|
|
53311
|
+
image.width = Math.ceil(image.width / factor);
|
|
53312
|
+
image.height = Math.ceil(image.height / factor);
|
|
53313
|
+
}
|
|
53146
53314
|
break;
|
|
53147
53315
|
case "JBIG2Decode":
|
|
53148
53316
|
image.bitsPerComponent = 1;
|
|
@@ -53331,53 +53499,25 @@ var _PDFImage = class _PDFImage {
|
|
|
53331
53499
|
localColorSpaceCache
|
|
53332
53500
|
});
|
|
53333
53501
|
}
|
|
53334
|
-
static
|
|
53335
|
-
|
|
53336
|
-
width,
|
|
53337
|
-
height,
|
|
53338
|
-
|
|
53339
|
-
|
|
53340
|
-
|
|
53341
|
-
}) {
|
|
53502
|
+
static async createMask({ image, isOffscreenCanvasSupported = false }) {
|
|
53503
|
+
const { dict } = image;
|
|
53504
|
+
const width = dict.get("W", "Width");
|
|
53505
|
+
const height = dict.get("H", "Height");
|
|
53506
|
+
const interpolate = dict.get("I", "Interpolate");
|
|
53507
|
+
const decode = dict.getArray("D", "Decode");
|
|
53508
|
+
const inverseDecode = decode?.[0] > 0;
|
|
53342
53509
|
const computedLength = (width + 7 >> 3) * height;
|
|
53343
|
-
const
|
|
53344
|
-
const haveFullData = computedLength === actualLength;
|
|
53345
|
-
let data, i;
|
|
53346
|
-
if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
|
|
53347
|
-
data = imgArray;
|
|
53348
|
-
} else if (!inverseDecode) {
|
|
53349
|
-
data = new Uint8Array(imgArray);
|
|
53350
|
-
} else {
|
|
53351
|
-
data = new Uint8Array(computedLength);
|
|
53352
|
-
data.set(imgArray);
|
|
53353
|
-
data.fill(255, actualLength);
|
|
53354
|
-
}
|
|
53355
|
-
if (inverseDecode) {
|
|
53356
|
-
for (i = 0; i < actualLength; i++) {
|
|
53357
|
-
data[i] ^= 255;
|
|
53358
|
-
}
|
|
53359
|
-
}
|
|
53360
|
-
return { data, width, height, interpolate };
|
|
53361
|
-
}
|
|
53362
|
-
static async createMask({
|
|
53363
|
-
imgArray,
|
|
53364
|
-
width,
|
|
53365
|
-
height,
|
|
53366
|
-
imageIsFromDecodeStream,
|
|
53367
|
-
inverseDecode,
|
|
53368
|
-
interpolate,
|
|
53369
|
-
isOffscreenCanvasSupported = false
|
|
53370
|
-
}) {
|
|
53510
|
+
const imgArray = image.getBytes(computedLength);
|
|
53371
53511
|
const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128));
|
|
53372
53512
|
if (isSingleOpaquePixel) {
|
|
53373
53513
|
return { isSingleOpaquePixel };
|
|
53374
53514
|
}
|
|
53375
53515
|
if (isOffscreenCanvasSupported) {
|
|
53376
53516
|
if (ImageResizer.needsToBeResized(width, height)) {
|
|
53377
|
-
const
|
|
53517
|
+
const data2 = new Uint8ClampedArray(width * height * 4);
|
|
53378
53518
|
convertBlackAndWhiteToRGBA({
|
|
53379
53519
|
src: imgArray,
|
|
53380
|
-
dest:
|
|
53520
|
+
dest: data2,
|
|
53381
53521
|
width,
|
|
53382
53522
|
height,
|
|
53383
53523
|
nonBlackColor: 0,
|
|
@@ -53385,7 +53525,7 @@ var _PDFImage = class _PDFImage {
|
|
|
53385
53525
|
});
|
|
53386
53526
|
return ImageResizer.createImage({
|
|
53387
53527
|
kind: ImageKind.RGBA_32BPP,
|
|
53388
|
-
data,
|
|
53528
|
+
data: data2,
|
|
53389
53529
|
width,
|
|
53390
53530
|
height,
|
|
53391
53531
|
interpolate
|
|
@@ -53412,14 +53552,24 @@ var _PDFImage = class _PDFImage {
|
|
|
53412
53552
|
bitmap
|
|
53413
53553
|
};
|
|
53414
53554
|
}
|
|
53415
|
-
|
|
53416
|
-
|
|
53417
|
-
|
|
53418
|
-
|
|
53419
|
-
|
|
53420
|
-
|
|
53421
|
-
|
|
53422
|
-
}
|
|
53555
|
+
const actualLength = imgArray.byteLength;
|
|
53556
|
+
const haveFullData = computedLength === actualLength;
|
|
53557
|
+
let data;
|
|
53558
|
+
if (image instanceof DecodeStream && (!inverseDecode || haveFullData)) {
|
|
53559
|
+
data = imgArray;
|
|
53560
|
+
} else if (!inverseDecode) {
|
|
53561
|
+
data = new Uint8Array(imgArray);
|
|
53562
|
+
} else {
|
|
53563
|
+
data = new Uint8Array(computedLength);
|
|
53564
|
+
data.set(imgArray);
|
|
53565
|
+
data.fill(255, actualLength);
|
|
53566
|
+
}
|
|
53567
|
+
if (inverseDecode) {
|
|
53568
|
+
for (let i = 0; i < actualLength; i++) {
|
|
53569
|
+
data[i] ^= 255;
|
|
53570
|
+
}
|
|
53571
|
+
}
|
|
53572
|
+
return { data, width, height, interpolate };
|
|
53423
53573
|
}
|
|
53424
53574
|
get drawWidth() {
|
|
53425
53575
|
return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
|
|
@@ -54239,8 +54389,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54239
54389
|
this.standardFontDataCache.set(name, data);
|
|
54240
54390
|
return new Stream(data);
|
|
54241
54391
|
}
|
|
54242
|
-
async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache) {
|
|
54243
|
-
const dict = xobj
|
|
54392
|
+
async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache, seenRefs) {
|
|
54393
|
+
const { dict } = xobj;
|
|
54244
54394
|
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
|
|
54245
54395
|
const bbox = lookupNormalRect(dict.getArray("BBox"), null);
|
|
54246
54396
|
let optionalContent, groupOptions;
|
|
@@ -54278,7 +54428,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54278
54428
|
}
|
|
54279
54429
|
if (smask?.backdrop) {
|
|
54280
54430
|
colorSpace || (colorSpace = ColorSpaceUtils.rgb);
|
|
54281
|
-
smask.backdrop = colorSpace.
|
|
54431
|
+
smask.backdrop = colorSpace.getRgbHex(smask.backdrop, 0);
|
|
54282
54432
|
}
|
|
54283
54433
|
operatorList.addOp(OPS.beginGroup, [groupOptions]);
|
|
54284
54434
|
}
|
|
@@ -54286,12 +54436,14 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54286
54436
|
const f32bbox = !group && bbox && new Float32Array(bbox) || null;
|
|
54287
54437
|
const args = [f32matrix, f32bbox];
|
|
54288
54438
|
operatorList.addOp(OPS.paintFormXObjectBegin, args);
|
|
54439
|
+
const localResources = dict.get("Resources");
|
|
54289
54440
|
await this.getOperatorList({
|
|
54290
54441
|
stream: xobj,
|
|
54291
54442
|
task,
|
|
54292
|
-
resources:
|
|
54443
|
+
resources: localResources instanceof Dict ? localResources : resources,
|
|
54293
54444
|
operatorList,
|
|
54294
|
-
initialState
|
|
54445
|
+
initialState,
|
|
54446
|
+
prevRefs: seenRefs
|
|
54295
54447
|
});
|
|
54296
54448
|
operatorList.addOp(OPS.paintFormXObjectEnd, []);
|
|
54297
54449
|
if (group) {
|
|
@@ -54328,7 +54480,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54328
54480
|
localImageCache,
|
|
54329
54481
|
localColorSpaceCache
|
|
54330
54482
|
}) {
|
|
54331
|
-
const
|
|
54483
|
+
const { maxImageSize, ignoreErrors, isOffscreenCanvasSupported } = this.options;
|
|
54484
|
+
const { dict } = image;
|
|
54332
54485
|
const imageRef = dict.objId;
|
|
54333
54486
|
const w = dict.get("W", "Width");
|
|
54334
54487
|
const h = dict.get("H", "Height");
|
|
@@ -54336,14 +54489,13 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54336
54489
|
warn("Image dimensions are missing, or not numbers.");
|
|
54337
54490
|
return;
|
|
54338
54491
|
}
|
|
54339
|
-
const maxImageSize = this.options.maxImageSize;
|
|
54340
54492
|
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
|
54341
54493
|
const msg = "Image exceeded maximum allowed size and was removed.";
|
|
54342
|
-
if (
|
|
54343
|
-
|
|
54344
|
-
return;
|
|
54494
|
+
if (!ignoreErrors) {
|
|
54495
|
+
throw new Error(msg);
|
|
54345
54496
|
}
|
|
54346
|
-
|
|
54497
|
+
warn(msg);
|
|
54498
|
+
return;
|
|
54347
54499
|
}
|
|
54348
54500
|
let optionalContent;
|
|
54349
54501
|
if (dict.has("OC")) {
|
|
@@ -54355,40 +54507,9 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54355
54507
|
const imageMask = dict.get("IM", "ImageMask") || false;
|
|
54356
54508
|
let imgData, fn, args;
|
|
54357
54509
|
if (imageMask) {
|
|
54358
|
-
const interpolate = dict.get("I", "Interpolate");
|
|
54359
|
-
const bitStrideLength = w + 7 >> 3;
|
|
54360
|
-
const imgArray = image.getBytes(bitStrideLength * h);
|
|
54361
|
-
const decode = dict.getArray("D", "Decode");
|
|
54362
|
-
if (this.parsingType3Font) {
|
|
54363
|
-
imgData = PDFImage.createRawMask({
|
|
54364
|
-
imgArray,
|
|
54365
|
-
width: w,
|
|
54366
|
-
height: h,
|
|
54367
|
-
imageIsFromDecodeStream: image instanceof DecodeStream,
|
|
54368
|
-
inverseDecode: decode?.[0] > 0,
|
|
54369
|
-
interpolate
|
|
54370
|
-
});
|
|
54371
|
-
args = compileType3Glyph(imgData);
|
|
54372
|
-
if (args) {
|
|
54373
|
-
operatorList.addImageOps(OPS.constructPath, args, optionalContent);
|
|
54374
|
-
return;
|
|
54375
|
-
}
|
|
54376
|
-
warn("Cannot compile Type3 glyph.");
|
|
54377
|
-
operatorList.addImageOps(
|
|
54378
|
-
OPS.paintImageMaskXObject,
|
|
54379
|
-
[imgData],
|
|
54380
|
-
optionalContent
|
|
54381
|
-
);
|
|
54382
|
-
return;
|
|
54383
|
-
}
|
|
54384
54510
|
imgData = await PDFImage.createMask({
|
|
54385
|
-
|
|
54386
|
-
|
|
54387
|
-
height: h,
|
|
54388
|
-
imageIsFromDecodeStream: image instanceof DecodeStream,
|
|
54389
|
-
inverseDecode: decode?.[0] > 0,
|
|
54390
|
-
interpolate,
|
|
54391
|
-
isOffscreenCanvasSupported: this.options.isOffscreenCanvasSupported
|
|
54511
|
+
image,
|
|
54512
|
+
isOffscreenCanvasSupported: isOffscreenCanvasSupported && !this.parsingType3Font
|
|
54392
54513
|
});
|
|
54393
54514
|
if (imgData.isSingleOpaquePixel) {
|
|
54394
54515
|
fn = OPS.paintSolidColorImageMask;
|
|
@@ -54408,6 +54529,26 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54408
54529
|
}
|
|
54409
54530
|
return;
|
|
54410
54531
|
}
|
|
54532
|
+
if (this.parsingType3Font) {
|
|
54533
|
+
if (false) {
|
|
54534
|
+
assert(
|
|
54535
|
+
imgData.data instanceof Uint8Array,
|
|
54536
|
+
"Type3 glyph image mask must be a TypedArray."
|
|
54537
|
+
);
|
|
54538
|
+
}
|
|
54539
|
+
args = compileType3Glyph(imgData);
|
|
54540
|
+
if (args) {
|
|
54541
|
+
operatorList.addImageOps(OPS.constructPath, args, optionalContent);
|
|
54542
|
+
return;
|
|
54543
|
+
}
|
|
54544
|
+
warn("Cannot compile Type3 glyph.");
|
|
54545
|
+
operatorList.addImageOps(
|
|
54546
|
+
OPS.paintImageMaskXObject,
|
|
54547
|
+
[imgData],
|
|
54548
|
+
optionalContent
|
|
54549
|
+
);
|
|
54550
|
+
return;
|
|
54551
|
+
}
|
|
54411
54552
|
const objId2 = `mask_${this.idFactory.createObjId()}`;
|
|
54412
54553
|
operatorList.addDependency(objId2);
|
|
54413
54554
|
imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
|
|
@@ -54463,7 +54604,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54463
54604
|
);
|
|
54464
54605
|
} catch (reason) {
|
|
54465
54606
|
const msg = `Unable to decode inline image: "${reason}".`;
|
|
54466
|
-
if (!
|
|
54607
|
+
if (!ignoreErrors) {
|
|
54467
54608
|
throw new Error(msg);
|
|
54468
54609
|
}
|
|
54469
54610
|
warn(msg);
|
|
@@ -54532,8 +54673,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54532
54673
|
imgData = await imageObj.createImageData(
|
|
54533
54674
|
/* forceRGBA = */
|
|
54534
54675
|
false,
|
|
54535
|
-
|
|
54536
|
-
this.options.isOffscreenCanvasSupported
|
|
54676
|
+
isOffscreenCanvasSupported
|
|
54537
54677
|
);
|
|
54538
54678
|
imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
|
|
54539
54679
|
imgData.ref = imageRef;
|
|
@@ -54570,7 +54710,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54570
54710
|
}
|
|
54571
54711
|
}
|
|
54572
54712
|
}
|
|
54573
|
-
handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache) {
|
|
54713
|
+
handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache, seenRefs) {
|
|
54574
54714
|
const smaskContent = smask.get("G");
|
|
54575
54715
|
const smaskOptions = {
|
|
54576
54716
|
subtype: smask.get("S").name,
|
|
@@ -54595,7 +54735,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54595
54735
|
operatorList,
|
|
54596
54736
|
task,
|
|
54597
54737
|
stateManager.state.clone({ newPath: true }),
|
|
54598
|
-
localColorSpaceCache
|
|
54738
|
+
localColorSpaceCache,
|
|
54739
|
+
seenRefs
|
|
54599
54740
|
);
|
|
54600
54741
|
}
|
|
54601
54742
|
handleTransferFunction(tr) {
|
|
@@ -54732,7 +54873,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54732
54873
|
task,
|
|
54733
54874
|
stateManager,
|
|
54734
54875
|
localGStateCache,
|
|
54735
|
-
localColorSpaceCache
|
|
54876
|
+
localColorSpaceCache,
|
|
54877
|
+
seenRefs
|
|
54736
54878
|
}) {
|
|
54737
54879
|
const gStateRef = gState.objId;
|
|
54738
54880
|
let isSimpleGState = true;
|
|
@@ -54792,7 +54934,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
54792
54934
|
operatorList,
|
|
54793
54935
|
task,
|
|
54794
54936
|
stateManager,
|
|
54795
|
-
localColorSpaceCache
|
|
54937
|
+
localColorSpaceCache,
|
|
54938
|
+
seenRefs
|
|
54796
54939
|
)
|
|
54797
54940
|
);
|
|
54798
54941
|
gStateObj.push([key, true]);
|
|
@@ -55121,7 +55264,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55121
55264
|
const localTilingPattern = rawPattern instanceof Ref && localTilingPatternCache.getByRef(rawPattern);
|
|
55122
55265
|
if (localTilingPattern) {
|
|
55123
55266
|
try {
|
|
55124
|
-
const color = cs.base ? cs.base.
|
|
55267
|
+
const color = cs.base ? cs.base.getRgbHex(args, 0) : null;
|
|
55125
55268
|
const tilingPatternIR = getTilingPatternIR(
|
|
55126
55269
|
localTilingPattern.operatorListIR,
|
|
55127
55270
|
localTilingPattern.dict,
|
|
@@ -55137,7 +55280,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55137
55280
|
const dict = pattern instanceof BaseStream ? pattern.dict : pattern;
|
|
55138
55281
|
const typeNum = dict.get("PatternType");
|
|
55139
55282
|
if (typeNum === PatternType.TILING) {
|
|
55140
|
-
const color = cs.base ? cs.base.
|
|
55283
|
+
const color = cs.base ? cs.base.getRgbHex(args, 0) : null;
|
|
55141
55284
|
return this.handleTilingType(
|
|
55142
55285
|
fn,
|
|
55143
55286
|
color,
|
|
@@ -55260,8 +55403,19 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55260
55403
|
resources,
|
|
55261
55404
|
operatorList,
|
|
55262
55405
|
initialState = null,
|
|
55263
|
-
fallbackFontDict = null
|
|
55406
|
+
fallbackFontDict = null,
|
|
55407
|
+
prevRefs = null
|
|
55264
55408
|
}) {
|
|
55409
|
+
const objId = stream.dict?.objId;
|
|
55410
|
+
const seenRefs = new RefSet(prevRefs);
|
|
55411
|
+
if (objId) {
|
|
55412
|
+
if (prevRefs?.has(objId)) {
|
|
55413
|
+
throw new Error(
|
|
55414
|
+
`getOperatorList - ignoring circular reference: ${objId}`
|
|
55415
|
+
);
|
|
55416
|
+
}
|
|
55417
|
+
seenRefs.put(objId);
|
|
55418
|
+
}
|
|
55265
55419
|
resources || (resources = Dict.empty);
|
|
55266
55420
|
initialState || (initialState = new EvalState());
|
|
55267
55421
|
if (!operatorList) {
|
|
@@ -55348,7 +55502,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55348
55502
|
operatorList,
|
|
55349
55503
|
task,
|
|
55350
55504
|
stateManager.state.clone({ newPath: true }),
|
|
55351
|
-
localColorSpaceCache
|
|
55505
|
+
localColorSpaceCache,
|
|
55506
|
+
seenRefs
|
|
55352
55507
|
).then(function() {
|
|
55353
55508
|
stateManager.restore();
|
|
55354
55509
|
resolveXObject();
|
|
@@ -55505,47 +55660,47 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55505
55660
|
}
|
|
55506
55661
|
case OPS.setFillColor:
|
|
55507
55662
|
cs = stateManager.state.fillColorSpace;
|
|
55508
|
-
args = cs.
|
|
55663
|
+
args = [cs.getRgbHex(args, 0)];
|
|
55509
55664
|
fn = OPS.setFillRGBColor;
|
|
55510
55665
|
break;
|
|
55511
55666
|
case OPS.setStrokeColor:
|
|
55512
55667
|
cs = stateManager.state.strokeColorSpace;
|
|
55513
|
-
args = cs.
|
|
55668
|
+
args = [cs.getRgbHex(args, 0)];
|
|
55514
55669
|
fn = OPS.setStrokeRGBColor;
|
|
55515
55670
|
break;
|
|
55516
55671
|
case OPS.setFillGray:
|
|
55517
55672
|
stateManager.state.fillColorSpace = ColorSpaceUtils.gray;
|
|
55518
|
-
args = ColorSpaceUtils.gray.
|
|
55673
|
+
args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
|
|
55519
55674
|
fn = OPS.setFillRGBColor;
|
|
55520
55675
|
break;
|
|
55521
55676
|
case OPS.setStrokeGray:
|
|
55522
55677
|
stateManager.state.strokeColorSpace = ColorSpaceUtils.gray;
|
|
55523
|
-
args = ColorSpaceUtils.gray.
|
|
55678
|
+
args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
|
|
55524
55679
|
fn = OPS.setStrokeRGBColor;
|
|
55525
55680
|
break;
|
|
55526
55681
|
case OPS.setFillCMYKColor:
|
|
55527
55682
|
stateManager.state.fillColorSpace = ColorSpaceUtils.cmyk;
|
|
55528
|
-
args = ColorSpaceUtils.cmyk.
|
|
55683
|
+
args = [ColorSpaceUtils.cmyk.getRgbHex(args, 0)];
|
|
55529
55684
|
fn = OPS.setFillRGBColor;
|
|
55530
55685
|
break;
|
|
55531
55686
|
case OPS.setStrokeCMYKColor:
|
|
55532
55687
|
stateManager.state.strokeColorSpace = ColorSpaceUtils.cmyk;
|
|
55533
|
-
args = ColorSpaceUtils.cmyk.
|
|
55688
|
+
args = [ColorSpaceUtils.cmyk.getRgbHex(args, 0)];
|
|
55534
55689
|
fn = OPS.setStrokeRGBColor;
|
|
55535
55690
|
break;
|
|
55536
55691
|
case OPS.setFillRGBColor:
|
|
55537
55692
|
stateManager.state.fillColorSpace = ColorSpaceUtils.rgb;
|
|
55538
|
-
args = ColorSpaceUtils.rgb.
|
|
55693
|
+
args = [ColorSpaceUtils.rgb.getRgbHex(args, 0)];
|
|
55539
55694
|
break;
|
|
55540
55695
|
case OPS.setStrokeRGBColor:
|
|
55541
55696
|
stateManager.state.strokeColorSpace = ColorSpaceUtils.rgb;
|
|
55542
|
-
args = ColorSpaceUtils.rgb.
|
|
55697
|
+
args = [ColorSpaceUtils.rgb.getRgbHex(args, 0)];
|
|
55543
55698
|
break;
|
|
55544
55699
|
case OPS.setFillColorN:
|
|
55545
55700
|
cs = stateManager.state.patternFillColorSpace;
|
|
55546
55701
|
if (!cs) {
|
|
55547
55702
|
if (isNumberArray(args, null)) {
|
|
55548
|
-
args = ColorSpaceUtils.gray.
|
|
55703
|
+
args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
|
|
55549
55704
|
fn = OPS.setFillRGBColor;
|
|
55550
55705
|
break;
|
|
55551
55706
|
}
|
|
@@ -55570,14 +55725,14 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55570
55725
|
);
|
|
55571
55726
|
return;
|
|
55572
55727
|
}
|
|
55573
|
-
args = cs.
|
|
55728
|
+
args = [cs.getRgbHex(args, 0)];
|
|
55574
55729
|
fn = OPS.setFillRGBColor;
|
|
55575
55730
|
break;
|
|
55576
55731
|
case OPS.setStrokeColorN:
|
|
55577
55732
|
cs = stateManager.state.patternStrokeColorSpace;
|
|
55578
55733
|
if (!cs) {
|
|
55579
55734
|
if (isNumberArray(args, null)) {
|
|
55580
|
-
args = ColorSpaceUtils.gray.
|
|
55735
|
+
args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
|
|
55581
55736
|
fn = OPS.setStrokeRGBColor;
|
|
55582
55737
|
break;
|
|
55583
55738
|
}
|
|
@@ -55602,7 +55757,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55602
55757
|
);
|
|
55603
55758
|
return;
|
|
55604
55759
|
}
|
|
55605
|
-
args = cs.
|
|
55760
|
+
args = [cs.getRgbHex(args, 0)];
|
|
55606
55761
|
fn = OPS.setStrokeRGBColor;
|
|
55607
55762
|
break;
|
|
55608
55763
|
case OPS.shadingFill:
|
|
@@ -55672,7 +55827,8 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55672
55827
|
task,
|
|
55673
55828
|
stateManager,
|
|
55674
55829
|
localGStateCache,
|
|
55675
|
-
localColorSpaceCache
|
|
55830
|
+
localColorSpaceCache,
|
|
55831
|
+
seenRefs
|
|
55676
55832
|
}).then(resolveGState, rejectGState);
|
|
55677
55833
|
}).catch(function(reason) {
|
|
55678
55834
|
if (reason instanceof AbortException) {
|
|
@@ -55826,8 +55982,19 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
55826
55982
|
lang = null,
|
|
55827
55983
|
markedContentData = null,
|
|
55828
55984
|
disableNormalization = false,
|
|
55829
|
-
keepWhiteSpace = false
|
|
55985
|
+
keepWhiteSpace = false,
|
|
55986
|
+
prevRefs = null
|
|
55830
55987
|
}) {
|
|
55988
|
+
const objId = stream.dict?.objId;
|
|
55989
|
+
const seenRefs = new RefSet(prevRefs);
|
|
55990
|
+
if (objId) {
|
|
55991
|
+
if (prevRefs?.has(objId)) {
|
|
55992
|
+
throw new Error(
|
|
55993
|
+
`getTextContent - ignoring circular reference: ${objId}`
|
|
55994
|
+
);
|
|
55995
|
+
}
|
|
55996
|
+
seenRefs.put(objId);
|
|
55997
|
+
}
|
|
55831
55998
|
resources || (resources = Dict.empty);
|
|
55832
55999
|
stateManager || (stateManager = new StateManager(new TextState()));
|
|
55833
56000
|
if (includeMarkedContent) {
|
|
@@ -56508,21 +56675,23 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
56508
56675
|
if (!(xobj instanceof BaseStream)) {
|
|
56509
56676
|
throw new FormatError("XObject should be a stream");
|
|
56510
56677
|
}
|
|
56511
|
-
const
|
|
56678
|
+
const { dict } = xobj;
|
|
56679
|
+
const type = dict.get("Subtype");
|
|
56512
56680
|
if (!(type instanceof Name)) {
|
|
56513
56681
|
throw new FormatError("XObject should have a Name subtype");
|
|
56514
56682
|
}
|
|
56515
56683
|
if (type.name !== "Form") {
|
|
56516
|
-
emptyXObjectCache.set(name,
|
|
56684
|
+
emptyXObjectCache.set(name, dict.objId, true);
|
|
56517
56685
|
resolveXObject();
|
|
56518
56686
|
return;
|
|
56519
56687
|
}
|
|
56520
56688
|
const currentState = stateManager.state.clone();
|
|
56521
56689
|
const xObjStateManager = new StateManager(currentState);
|
|
56522
|
-
const matrix = lookupMatrix(
|
|
56690
|
+
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
|
|
56523
56691
|
if (matrix) {
|
|
56524
56692
|
xObjStateManager.transform(matrix);
|
|
56525
56693
|
}
|
|
56694
|
+
const localResources = dict.get("Resources");
|
|
56526
56695
|
enqueueChunk();
|
|
56527
56696
|
const sinkWrapper = {
|
|
56528
56697
|
enqueueInvoked: false,
|
|
@@ -56540,7 +56709,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
56540
56709
|
self2.getTextContent({
|
|
56541
56710
|
stream: xobj,
|
|
56542
56711
|
task,
|
|
56543
|
-
resources:
|
|
56712
|
+
resources: localResources instanceof Dict ? localResources : resources,
|
|
56544
56713
|
stateManager: xObjStateManager,
|
|
56545
56714
|
includeMarkedContent,
|
|
56546
56715
|
sink: sinkWrapper,
|
|
@@ -56549,10 +56718,11 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
56549
56718
|
lang,
|
|
56550
56719
|
markedContentData,
|
|
56551
56720
|
disableNormalization,
|
|
56552
|
-
keepWhiteSpace
|
|
56721
|
+
keepWhiteSpace,
|
|
56722
|
+
prevRefs: seenRefs
|
|
56553
56723
|
}).then(function() {
|
|
56554
56724
|
if (!sinkWrapper.enqueueInvoked) {
|
|
56555
|
-
emptyXObjectCache.set(name,
|
|
56725
|
+
emptyXObjectCache.set(name, dict.objId, true);
|
|
56556
56726
|
}
|
|
56557
56727
|
resolveXObject();
|
|
56558
56728
|
}, rejectXObject);
|
|
@@ -57303,10 +57473,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
57303
57473
|
const isType3Font = type === "Type3";
|
|
57304
57474
|
if (!descriptor) {
|
|
57305
57475
|
if (isType3Font) {
|
|
57306
|
-
|
|
57307
|
-
descriptor = new Dict(null);
|
|
57308
|
-
descriptor.set("FontName", Name.get(type));
|
|
57309
|
-
descriptor.set("FontBBox", bbox2);
|
|
57476
|
+
descriptor = Dict.empty;
|
|
57310
57477
|
} else {
|
|
57311
57478
|
let baseFontName = dict.get("BaseFont");
|
|
57312
57479
|
if (!(baseFontName instanceof Name)) {
|
|
@@ -57384,15 +57551,19 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
57384
57551
|
}
|
|
57385
57552
|
const fontNameStr = fontName?.name;
|
|
57386
57553
|
const baseFontStr = baseFont?.name;
|
|
57387
|
-
if (
|
|
57554
|
+
if (isType3Font) {
|
|
57555
|
+
if (!fontNameStr) {
|
|
57556
|
+
fontName = Name.get(type);
|
|
57557
|
+
}
|
|
57558
|
+
} else if (fontNameStr !== baseFontStr) {
|
|
57388
57559
|
info(
|
|
57389
57560
|
`The FontDescriptor's FontName is "${fontNameStr}" but should be the same as the Font's BaseFont "${baseFontStr}".`
|
|
57390
57561
|
);
|
|
57391
57562
|
if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr))) {
|
|
57392
57563
|
fontName = null;
|
|
57393
57564
|
}
|
|
57565
|
+
fontName || (fontName = baseFont);
|
|
57394
57566
|
}
|
|
57395
|
-
fontName || (fontName = baseFont);
|
|
57396
57567
|
if (!(fontName instanceof Name)) {
|
|
57397
57568
|
throw new FormatError("invalid font name");
|
|
57398
57569
|
}
|
|
@@ -57460,7 +57631,7 @@ var PartialEvaluator = class _PartialEvaluator {
|
|
|
57460
57631
|
);
|
|
57461
57632
|
const bbox = lookupNormalRect(
|
|
57462
57633
|
descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
|
|
57463
|
-
void 0
|
|
57634
|
+
isType3Font ? [0, 0, 0, 0] : void 0
|
|
57464
57635
|
);
|
|
57465
57636
|
let ascent = descriptor.get("Ascent");
|
|
57466
57637
|
if (typeof ascent !== "number") {
|
|
@@ -57619,7 +57790,7 @@ var TranslatedFont = class {
|
|
|
57619
57790
|
const charProcs = this.dict.get("CharProcs");
|
|
57620
57791
|
const fontResources = this.dict.get("Resources") || resources;
|
|
57621
57792
|
const charProcOperatorList = /* @__PURE__ */ Object.create(null);
|
|
57622
|
-
const
|
|
57793
|
+
const [x0, y0, x1, y1] = font.bbox, width = x1 - x0, height = y1 - y0;
|
|
57623
57794
|
const fontBBoxSize = Math.hypot(width, height);
|
|
57624
57795
|
for (const key of charProcs.getKeys()) {
|
|
57625
57796
|
loadCharProcsPromise = loadCharProcsPromise.then(() => {
|
|
@@ -58669,7 +58840,11 @@ var FileSpec = class {
|
|
|
58669
58840
|
let filename = "";
|
|
58670
58841
|
const item = pickPlatformItem(this.root);
|
|
58671
58842
|
if (item && typeof item === "string") {
|
|
58672
|
-
filename = stringToPDFString(
|
|
58843
|
+
filename = stringToPDFString(
|
|
58844
|
+
item,
|
|
58845
|
+
/* keepEscapeSequence = */
|
|
58846
|
+
true
|
|
58847
|
+
).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/");
|
|
58673
58848
|
}
|
|
58674
58849
|
return shadow(this, "filename", filename || "unnamed");
|
|
58675
58850
|
}
|
|
@@ -59328,7 +59503,7 @@ var _StructTreeRoot = class _StructTreeRoot {
|
|
|
59328
59503
|
pdfManager,
|
|
59329
59504
|
changes
|
|
59330
59505
|
}) {
|
|
59331
|
-
const root = pdfManager.
|
|
59506
|
+
const root = await pdfManager.ensureCatalog("cloneDict");
|
|
59332
59507
|
const cache = new RefSetCache();
|
|
59333
59508
|
cache.put(catalogRef, root);
|
|
59334
59509
|
const structTreeRootRef = xref.getNewTemporaryRef();
|
|
@@ -59880,7 +60055,7 @@ var StructTreePage = class {
|
|
|
59880
60055
|
const element = new StructElementNode(this, dict);
|
|
59881
60056
|
map.set(dict, element);
|
|
59882
60057
|
const parent = dict.get("P");
|
|
59883
|
-
if (!parent || isName(parent.get("Type"), "StructTreeRoot")) {
|
|
60058
|
+
if (!(parent instanceof Dict) || isName(parent.get("Type"), "StructTreeRoot")) {
|
|
59884
60059
|
if (!this.addTopLevelNode(dict, element)) {
|
|
59885
60060
|
map.delete(dict);
|
|
59886
60061
|
}
|
|
@@ -60024,41 +60199,46 @@ function fetchRemoteDest(action) {
|
|
|
60024
60199
|
dest = dest.name;
|
|
60025
60200
|
}
|
|
60026
60201
|
if (typeof dest === "string") {
|
|
60027
|
-
return stringToPDFString(
|
|
60202
|
+
return stringToPDFString(
|
|
60203
|
+
dest,
|
|
60204
|
+
/* keepEscapeSequence = */
|
|
60205
|
+
true
|
|
60206
|
+
);
|
|
60028
60207
|
} else if (isValidExplicitDest(dest)) {
|
|
60029
60208
|
return JSON.stringify(dest);
|
|
60030
60209
|
}
|
|
60031
60210
|
}
|
|
60032
60211
|
return null;
|
|
60033
60212
|
}
|
|
60034
|
-
var _Catalog_instances, readStructTreeRoot_fn, readOptionalContentGroup_fn, readOptionalContentConfig_fn, readDests_fn;
|
|
60213
|
+
var _actualNumPages, _catDict, _Catalog_instances, readMarkInfo_fn, readStructTreeRoot_fn, readDocumentOutline_fn, readPermissions_fn, readOptionalContentGroup_fn, readOptionalContentConfig_fn, readDests_fn, readPageLabels_fn, collectJavaScript_fn;
|
|
60035
60214
|
var _Catalog = class _Catalog {
|
|
60036
60215
|
constructor(pdfManager, xref) {
|
|
60037
60216
|
__privateAdd(this, _Catalog_instances);
|
|
60217
|
+
__privateAdd(this, _actualNumPages, null);
|
|
60218
|
+
__privateAdd(this, _catDict, null);
|
|
60219
|
+
__publicField(this, "builtInCMapCache", /* @__PURE__ */ new Map());
|
|
60220
|
+
__publicField(this, "fontCache", new RefSetCache());
|
|
60221
|
+
__publicField(this, "globalColorSpaceCache", new GlobalColorSpaceCache());
|
|
60222
|
+
__publicField(this, "globalImageCache", new GlobalImageCache());
|
|
60223
|
+
__publicField(this, "nonBlendModesSet", new RefSet());
|
|
60224
|
+
__publicField(this, "pageDictCache", new RefSetCache());
|
|
60225
|
+
__publicField(this, "pageIndexCache", new RefSetCache());
|
|
60226
|
+
__publicField(this, "pageKidsCountCache", new RefSetCache());
|
|
60227
|
+
__publicField(this, "standardFontDataCache", /* @__PURE__ */ new Map());
|
|
60228
|
+
__publicField(this, "systemFontCache", /* @__PURE__ */ new Map());
|
|
60038
60229
|
this.pdfManager = pdfManager;
|
|
60039
60230
|
this.xref = xref;
|
|
60040
|
-
this
|
|
60041
|
-
if (!(this
|
|
60231
|
+
__privateSet(this, _catDict, xref.getCatalogObj());
|
|
60232
|
+
if (!(__privateGet(this, _catDict) instanceof Dict)) {
|
|
60042
60233
|
throw new FormatError("Catalog object is not a dictionary.");
|
|
60043
60234
|
}
|
|
60044
60235
|
this.toplevelPagesDict;
|
|
60045
|
-
this._actualNumPages = null;
|
|
60046
|
-
this.fontCache = new RefSetCache();
|
|
60047
|
-
this.builtInCMapCache = /* @__PURE__ */ new Map();
|
|
60048
|
-
this.standardFontDataCache = /* @__PURE__ */ new Map();
|
|
60049
|
-
this.globalColorSpaceCache = new GlobalColorSpaceCache();
|
|
60050
|
-
this.globalImageCache = new GlobalImageCache();
|
|
60051
|
-
this.pageKidsCountCache = new RefSetCache();
|
|
60052
|
-
this.pageIndexCache = new RefSetCache();
|
|
60053
|
-
this.pageDictCache = new RefSetCache();
|
|
60054
|
-
this.nonBlendModesSet = new RefSet();
|
|
60055
|
-
this.systemFontCache = /* @__PURE__ */ new Map();
|
|
60056
60236
|
}
|
|
60057
60237
|
cloneDict() {
|
|
60058
|
-
return this
|
|
60238
|
+
return __privateGet(this, _catDict).clone();
|
|
60059
60239
|
}
|
|
60060
60240
|
get version() {
|
|
60061
|
-
const version = this
|
|
60241
|
+
const version = __privateGet(this, _catDict).get("Version");
|
|
60062
60242
|
if (version instanceof Name) {
|
|
60063
60243
|
if (PDF_VERSION_REGEXP.test(version.name)) {
|
|
60064
60244
|
return shadow(this, "version", version.name);
|
|
@@ -60068,7 +60248,7 @@ var _Catalog = class _Catalog {
|
|
|
60068
60248
|
return shadow(this, "version", null);
|
|
60069
60249
|
}
|
|
60070
60250
|
get lang() {
|
|
60071
|
-
const lang = this
|
|
60251
|
+
const lang = __privateGet(this, _catDict).get("Lang");
|
|
60072
60252
|
return shadow(
|
|
60073
60253
|
this,
|
|
60074
60254
|
"lang",
|
|
@@ -60080,7 +60260,7 @@ var _Catalog = class _Catalog {
|
|
|
60080
60260
|
* `false` for XFA Foreground documents.
|
|
60081
60261
|
*/
|
|
60082
60262
|
get needsRendering() {
|
|
60083
|
-
const needsRendering = this
|
|
60263
|
+
const needsRendering = __privateGet(this, _catDict).get("NeedsRendering");
|
|
60084
60264
|
return shadow(
|
|
60085
60265
|
this,
|
|
60086
60266
|
"needsRendering",
|
|
@@ -60090,7 +60270,7 @@ var _Catalog = class _Catalog {
|
|
|
60090
60270
|
get collection() {
|
|
60091
60271
|
let collection = null;
|
|
60092
60272
|
try {
|
|
60093
|
-
const obj = this
|
|
60273
|
+
const obj = __privateGet(this, _catDict).get("Collection");
|
|
60094
60274
|
if (obj instanceof Dict && obj.size > 0) {
|
|
60095
60275
|
collection = obj;
|
|
60096
60276
|
}
|
|
@@ -60105,7 +60285,7 @@ var _Catalog = class _Catalog {
|
|
|
60105
60285
|
get acroForm() {
|
|
60106
60286
|
let acroForm = null;
|
|
60107
60287
|
try {
|
|
60108
|
-
const obj = this
|
|
60288
|
+
const obj = __privateGet(this, _catDict).get("AcroForm");
|
|
60109
60289
|
if (obj instanceof Dict && obj.size > 0) {
|
|
60110
60290
|
acroForm = obj;
|
|
60111
60291
|
}
|
|
@@ -60118,11 +60298,11 @@ var _Catalog = class _Catalog {
|
|
|
60118
60298
|
return shadow(this, "acroForm", acroForm);
|
|
60119
60299
|
}
|
|
60120
60300
|
get acroFormRef() {
|
|
60121
|
-
const value = this
|
|
60301
|
+
const value = __privateGet(this, _catDict).getRaw("AcroForm");
|
|
60122
60302
|
return shadow(this, "acroFormRef", value instanceof Ref ? value : null);
|
|
60123
60303
|
}
|
|
60124
60304
|
get metadata() {
|
|
60125
|
-
const streamRef = this
|
|
60305
|
+
const streamRef = __privateGet(this, _catDict).getRaw("Metadata");
|
|
60126
60306
|
if (!(streamRef instanceof Ref)) {
|
|
60127
60307
|
return shadow(this, "metadata", null);
|
|
60128
60308
|
}
|
|
@@ -60154,7 +60334,7 @@ var _Catalog = class _Catalog {
|
|
|
60154
60334
|
get markInfo() {
|
|
60155
60335
|
let markInfo = null;
|
|
60156
60336
|
try {
|
|
60157
|
-
markInfo = this.
|
|
60337
|
+
markInfo = __privateMethod(this, _Catalog_instances, readMarkInfo_fn).call(this);
|
|
60158
60338
|
} catch (ex) {
|
|
60159
60339
|
if (ex instanceof MissingDataException) {
|
|
60160
60340
|
throw ex;
|
|
@@ -60163,27 +60343,6 @@ var _Catalog = class _Catalog {
|
|
|
60163
60343
|
}
|
|
60164
60344
|
return shadow(this, "markInfo", markInfo);
|
|
60165
60345
|
}
|
|
60166
|
-
/**
|
|
60167
|
-
* @private
|
|
60168
|
-
*/
|
|
60169
|
-
_readMarkInfo() {
|
|
60170
|
-
const obj = this._catDict.get("MarkInfo");
|
|
60171
|
-
if (!(obj instanceof Dict)) {
|
|
60172
|
-
return null;
|
|
60173
|
-
}
|
|
60174
|
-
const markInfo = {
|
|
60175
|
-
Marked: false,
|
|
60176
|
-
UserProperties: false,
|
|
60177
|
-
Suspects: false
|
|
60178
|
-
};
|
|
60179
|
-
for (const key in markInfo) {
|
|
60180
|
-
const value = obj.get(key);
|
|
60181
|
-
if (typeof value === "boolean") {
|
|
60182
|
-
markInfo[key] = value;
|
|
60183
|
-
}
|
|
60184
|
-
}
|
|
60185
|
-
return markInfo;
|
|
60186
|
-
}
|
|
60187
60346
|
get structTreeRoot() {
|
|
60188
60347
|
let structTree = null;
|
|
60189
60348
|
try {
|
|
@@ -60197,7 +60356,7 @@ var _Catalog = class _Catalog {
|
|
|
60197
60356
|
return shadow(this, "structTreeRoot", structTree);
|
|
60198
60357
|
}
|
|
60199
60358
|
get toplevelPagesDict() {
|
|
60200
|
-
const pagesObj = this
|
|
60359
|
+
const pagesObj = __privateGet(this, _catDict).get("Pages");
|
|
60201
60360
|
if (!(pagesObj instanceof Dict)) {
|
|
60202
60361
|
throw new FormatError("Invalid top-level pages dictionary.");
|
|
60203
60362
|
}
|
|
@@ -60206,7 +60365,7 @@ var _Catalog = class _Catalog {
|
|
|
60206
60365
|
get documentOutline() {
|
|
60207
60366
|
let obj = null;
|
|
60208
60367
|
try {
|
|
60209
|
-
obj = this.
|
|
60368
|
+
obj = __privateMethod(this, _Catalog_instances, readDocumentOutline_fn).call(this);
|
|
60210
60369
|
} catch (ex) {
|
|
60211
60370
|
if (ex instanceof MissingDataException) {
|
|
60212
60371
|
throw ex;
|
|
@@ -60215,80 +60374,10 @@ var _Catalog = class _Catalog {
|
|
|
60215
60374
|
}
|
|
60216
60375
|
return shadow(this, "documentOutline", obj);
|
|
60217
60376
|
}
|
|
60218
|
-
/**
|
|
60219
|
-
* @private
|
|
60220
|
-
*/
|
|
60221
|
-
_readDocumentOutline() {
|
|
60222
|
-
let obj = this._catDict.get("Outlines");
|
|
60223
|
-
if (!(obj instanceof Dict)) {
|
|
60224
|
-
return null;
|
|
60225
|
-
}
|
|
60226
|
-
obj = obj.getRaw("First");
|
|
60227
|
-
if (!(obj instanceof Ref)) {
|
|
60228
|
-
return null;
|
|
60229
|
-
}
|
|
60230
|
-
const root = { items: [] };
|
|
60231
|
-
const queue = [{ obj, parent: root }];
|
|
60232
|
-
const processed = new RefSet();
|
|
60233
|
-
processed.put(obj);
|
|
60234
|
-
const xref = this.xref, blackColor = new Uint8ClampedArray(3);
|
|
60235
|
-
while (queue.length > 0) {
|
|
60236
|
-
const i = queue.shift();
|
|
60237
|
-
const outlineDict = xref.fetchIfRef(i.obj);
|
|
60238
|
-
if (outlineDict === null) {
|
|
60239
|
-
continue;
|
|
60240
|
-
}
|
|
60241
|
-
if (!outlineDict.has("Title")) {
|
|
60242
|
-
warn("Invalid outline item encountered.");
|
|
60243
|
-
}
|
|
60244
|
-
const data = { url: null, dest: null, action: null };
|
|
60245
|
-
_Catalog.parseDestDictionary({
|
|
60246
|
-
destDict: outlineDict,
|
|
60247
|
-
resultObj: data,
|
|
60248
|
-
docBaseUrl: this.baseUrl,
|
|
60249
|
-
docAttachments: this.attachments
|
|
60250
|
-
});
|
|
60251
|
-
const title = outlineDict.get("Title");
|
|
60252
|
-
const flags = outlineDict.get("F") || 0;
|
|
60253
|
-
const color = outlineDict.getArray("C");
|
|
60254
|
-
const count = outlineDict.get("Count");
|
|
60255
|
-
let rgbColor = blackColor;
|
|
60256
|
-
if (isNumberArray(color, 3) && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
|
|
60257
|
-
rgbColor = ColorSpaceUtils.rgb.getRgb(color, 0);
|
|
60258
|
-
}
|
|
60259
|
-
const outlineItem = {
|
|
60260
|
-
action: data.action,
|
|
60261
|
-
attachment: data.attachment,
|
|
60262
|
-
dest: data.dest,
|
|
60263
|
-
url: data.url,
|
|
60264
|
-
unsafeUrl: data.unsafeUrl,
|
|
60265
|
-
newWindow: data.newWindow,
|
|
60266
|
-
setOCGState: data.setOCGState,
|
|
60267
|
-
title: typeof title === "string" ? stringToPDFString(title) : "",
|
|
60268
|
-
color: rgbColor,
|
|
60269
|
-
count: Number.isInteger(count) ? count : void 0,
|
|
60270
|
-
bold: !!(flags & 2),
|
|
60271
|
-
italic: !!(flags & 1),
|
|
60272
|
-
items: []
|
|
60273
|
-
};
|
|
60274
|
-
i.parent.items.push(outlineItem);
|
|
60275
|
-
obj = outlineDict.getRaw("First");
|
|
60276
|
-
if (obj instanceof Ref && !processed.has(obj)) {
|
|
60277
|
-
queue.push({ obj, parent: outlineItem });
|
|
60278
|
-
processed.put(obj);
|
|
60279
|
-
}
|
|
60280
|
-
obj = outlineDict.getRaw("Next");
|
|
60281
|
-
if (obj instanceof Ref && !processed.has(obj)) {
|
|
60282
|
-
queue.push({ obj, parent: i.parent });
|
|
60283
|
-
processed.put(obj);
|
|
60284
|
-
}
|
|
60285
|
-
}
|
|
60286
|
-
return root.items.length > 0 ? root.items : null;
|
|
60287
|
-
}
|
|
60288
60377
|
get permissions() {
|
|
60289
60378
|
let permissions = null;
|
|
60290
60379
|
try {
|
|
60291
|
-
permissions = this.
|
|
60380
|
+
permissions = __privateMethod(this, _Catalog_instances, readPermissions_fn).call(this);
|
|
60292
60381
|
} catch (ex) {
|
|
60293
60382
|
if (ex instanceof MissingDataException) {
|
|
60294
60383
|
throw ex;
|
|
@@ -60297,32 +60386,10 @@ var _Catalog = class _Catalog {
|
|
|
60297
60386
|
}
|
|
60298
60387
|
return shadow(this, "permissions", permissions);
|
|
60299
60388
|
}
|
|
60300
|
-
/**
|
|
60301
|
-
* @private
|
|
60302
|
-
*/
|
|
60303
|
-
_readPermissions() {
|
|
60304
|
-
const encrypt = this.xref.trailer.get("Encrypt");
|
|
60305
|
-
if (!(encrypt instanceof Dict)) {
|
|
60306
|
-
return null;
|
|
60307
|
-
}
|
|
60308
|
-
let flags = encrypt.get("P");
|
|
60309
|
-
if (typeof flags !== "number") {
|
|
60310
|
-
return null;
|
|
60311
|
-
}
|
|
60312
|
-
flags += 2 ** 32;
|
|
60313
|
-
const permissions = [];
|
|
60314
|
-
for (const key in PermissionFlag) {
|
|
60315
|
-
const value = PermissionFlag[key];
|
|
60316
|
-
if (flags & value) {
|
|
60317
|
-
permissions.push(value);
|
|
60318
|
-
}
|
|
60319
|
-
}
|
|
60320
|
-
return permissions;
|
|
60321
|
-
}
|
|
60322
60389
|
get optionalContentConfig() {
|
|
60323
60390
|
let config = null;
|
|
60324
60391
|
try {
|
|
60325
|
-
const properties = this
|
|
60392
|
+
const properties = __privateGet(this, _catDict).get("OCProperties");
|
|
60326
60393
|
if (!properties) {
|
|
60327
60394
|
return shadow(this, "optionalContentConfig", null);
|
|
60328
60395
|
}
|
|
@@ -60351,10 +60418,10 @@ var _Catalog = class _Catalog {
|
|
|
60351
60418
|
return shadow(this, "optionalContentConfig", config);
|
|
60352
60419
|
}
|
|
60353
60420
|
setActualNumPages(num = null) {
|
|
60354
|
-
this
|
|
60421
|
+
__privateSet(this, _actualNumPages, num);
|
|
60355
60422
|
}
|
|
60356
60423
|
get hasActualNumPages() {
|
|
60357
|
-
return this
|
|
60424
|
+
return __privateGet(this, _actualNumPages) !== null;
|
|
60358
60425
|
}
|
|
60359
60426
|
get _pagesCount() {
|
|
60360
60427
|
const obj = this.toplevelPagesDict.get("Count");
|
|
@@ -60366,23 +60433,32 @@ var _Catalog = class _Catalog {
|
|
|
60366
60433
|
return shadow(this, "_pagesCount", obj);
|
|
60367
60434
|
}
|
|
60368
60435
|
get numPages() {
|
|
60369
|
-
return this
|
|
60436
|
+
return __privateGet(this, _actualNumPages) ?? this._pagesCount;
|
|
60370
60437
|
}
|
|
60371
60438
|
get destinations() {
|
|
60439
|
+
var _a;
|
|
60372
60440
|
const rawDests = __privateMethod(this, _Catalog_instances, readDests_fn).call(this), dests = /* @__PURE__ */ Object.create(null);
|
|
60373
60441
|
for (const obj of rawDests) {
|
|
60374
60442
|
if (obj instanceof NameTree) {
|
|
60375
60443
|
for (const [key, value] of obj.getAll()) {
|
|
60376
60444
|
const dest = fetchDest(value);
|
|
60377
60445
|
if (dest) {
|
|
60378
|
-
dests[stringToPDFString(
|
|
60446
|
+
dests[stringToPDFString(
|
|
60447
|
+
key,
|
|
60448
|
+
/* keepEscapeSequence = */
|
|
60449
|
+
true
|
|
60450
|
+
)] = dest;
|
|
60379
60451
|
}
|
|
60380
60452
|
}
|
|
60381
60453
|
} else if (obj instanceof Dict) {
|
|
60382
60454
|
for (const [key, value] of obj) {
|
|
60383
60455
|
const dest = fetchDest(value);
|
|
60384
60456
|
if (dest) {
|
|
60385
|
-
dests[
|
|
60457
|
+
dests[_a = stringToPDFString(
|
|
60458
|
+
key,
|
|
60459
|
+
/* keepEscapeSequence = */
|
|
60460
|
+
true
|
|
60461
|
+
)] || (dests[_a] = dest);
|
|
60386
60462
|
}
|
|
60387
60463
|
}
|
|
60388
60464
|
}
|
|
@@ -60390,6 +60466,9 @@ var _Catalog = class _Catalog {
|
|
|
60390
60466
|
return shadow(this, "destinations", dests);
|
|
60391
60467
|
}
|
|
60392
60468
|
getDestination(id) {
|
|
60469
|
+
if (this.hasOwnProperty("destinations")) {
|
|
60470
|
+
return this.destinations[id] ?? null;
|
|
60471
|
+
}
|
|
60393
60472
|
const rawDests = __privateMethod(this, _Catalog_instances, readDests_fn).call(this);
|
|
60394
60473
|
for (const obj of rawDests) {
|
|
60395
60474
|
if (obj instanceof NameTree || obj instanceof Dict) {
|
|
@@ -60399,10 +60478,9 @@ var _Catalog = class _Catalog {
|
|
|
60399
60478
|
}
|
|
60400
60479
|
}
|
|
60401
60480
|
}
|
|
60402
|
-
if (rawDests
|
|
60481
|
+
if (rawDests.length) {
|
|
60403
60482
|
const dest = this.destinations[id];
|
|
60404
60483
|
if (dest) {
|
|
60405
|
-
warn(`Found "${id}" at an incorrect position in the NameTree.`);
|
|
60406
60484
|
return dest;
|
|
60407
60485
|
}
|
|
60408
60486
|
}
|
|
@@ -60411,7 +60489,7 @@ var _Catalog = class _Catalog {
|
|
|
60411
60489
|
get pageLabels() {
|
|
60412
60490
|
let obj = null;
|
|
60413
60491
|
try {
|
|
60414
|
-
obj = this.
|
|
60492
|
+
obj = __privateMethod(this, _Catalog_instances, readPageLabels_fn).call(this);
|
|
60415
60493
|
} catch (ex) {
|
|
60416
60494
|
if (ex instanceof MissingDataException) {
|
|
60417
60495
|
throw ex;
|
|
@@ -60420,90 +60498,8 @@ var _Catalog = class _Catalog {
|
|
|
60420
60498
|
}
|
|
60421
60499
|
return shadow(this, "pageLabels", obj);
|
|
60422
60500
|
}
|
|
60423
|
-
/**
|
|
60424
|
-
* @private
|
|
60425
|
-
*/
|
|
60426
|
-
_readPageLabels() {
|
|
60427
|
-
const obj = this._catDict.getRaw("PageLabels");
|
|
60428
|
-
if (!obj) {
|
|
60429
|
-
return null;
|
|
60430
|
-
}
|
|
60431
|
-
const pageLabels = new Array(this.numPages);
|
|
60432
|
-
let style = null, prefix = "";
|
|
60433
|
-
const numberTree = new NumberTree(obj, this.xref);
|
|
60434
|
-
const nums = numberTree.getAll();
|
|
60435
|
-
let currentLabel = "", currentIndex = 1;
|
|
60436
|
-
for (let i = 0, ii = this.numPages; i < ii; i++) {
|
|
60437
|
-
const labelDict = nums.get(i);
|
|
60438
|
-
if (labelDict !== void 0) {
|
|
60439
|
-
if (!(labelDict instanceof Dict)) {
|
|
60440
|
-
throw new FormatError("PageLabel is not a dictionary.");
|
|
60441
|
-
}
|
|
60442
|
-
if (labelDict.has("Type") && !isName(labelDict.get("Type"), "PageLabel")) {
|
|
60443
|
-
throw new FormatError("Invalid type in PageLabel dictionary.");
|
|
60444
|
-
}
|
|
60445
|
-
if (labelDict.has("S")) {
|
|
60446
|
-
const s = labelDict.get("S");
|
|
60447
|
-
if (!(s instanceof Name)) {
|
|
60448
|
-
throw new FormatError("Invalid style in PageLabel dictionary.");
|
|
60449
|
-
}
|
|
60450
|
-
style = s.name;
|
|
60451
|
-
} else {
|
|
60452
|
-
style = null;
|
|
60453
|
-
}
|
|
60454
|
-
if (labelDict.has("P")) {
|
|
60455
|
-
const p = labelDict.get("P");
|
|
60456
|
-
if (typeof p !== "string") {
|
|
60457
|
-
throw new FormatError("Invalid prefix in PageLabel dictionary.");
|
|
60458
|
-
}
|
|
60459
|
-
prefix = stringToPDFString(p);
|
|
60460
|
-
} else {
|
|
60461
|
-
prefix = "";
|
|
60462
|
-
}
|
|
60463
|
-
if (labelDict.has("St")) {
|
|
60464
|
-
const st = labelDict.get("St");
|
|
60465
|
-
if (!(Number.isInteger(st) && st >= 1)) {
|
|
60466
|
-
throw new FormatError("Invalid start in PageLabel dictionary.");
|
|
60467
|
-
}
|
|
60468
|
-
currentIndex = st;
|
|
60469
|
-
} else {
|
|
60470
|
-
currentIndex = 1;
|
|
60471
|
-
}
|
|
60472
|
-
}
|
|
60473
|
-
switch (style) {
|
|
60474
|
-
case "D":
|
|
60475
|
-
currentLabel = currentIndex;
|
|
60476
|
-
break;
|
|
60477
|
-
case "R":
|
|
60478
|
-
case "r":
|
|
60479
|
-
currentLabel = toRomanNumerals(currentIndex, style === "r");
|
|
60480
|
-
break;
|
|
60481
|
-
case "A":
|
|
60482
|
-
case "a":
|
|
60483
|
-
const LIMIT = 26;
|
|
60484
|
-
const A_UPPER_CASE = 65, A_LOWER_CASE = 97;
|
|
60485
|
-
const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
|
|
60486
|
-
const letterIndex = currentIndex - 1;
|
|
60487
|
-
const character = String.fromCharCode(
|
|
60488
|
-
baseCharCode + letterIndex % LIMIT
|
|
60489
|
-
);
|
|
60490
|
-
currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
|
|
60491
|
-
break;
|
|
60492
|
-
default:
|
|
60493
|
-
if (style) {
|
|
60494
|
-
throw new FormatError(
|
|
60495
|
-
`Invalid style "${style}" in PageLabel dictionary.`
|
|
60496
|
-
);
|
|
60497
|
-
}
|
|
60498
|
-
currentLabel = "";
|
|
60499
|
-
}
|
|
60500
|
-
pageLabels[i] = prefix + currentLabel;
|
|
60501
|
-
currentIndex++;
|
|
60502
|
-
}
|
|
60503
|
-
return pageLabels;
|
|
60504
|
-
}
|
|
60505
60501
|
get pageLayout() {
|
|
60506
|
-
const obj = this
|
|
60502
|
+
const obj = __privateGet(this, _catDict).get("PageLayout");
|
|
60507
60503
|
let pageLayout = "";
|
|
60508
60504
|
if (obj instanceof Name) {
|
|
60509
60505
|
switch (obj.name) {
|
|
@@ -60519,7 +60515,7 @@ var _Catalog = class _Catalog {
|
|
|
60519
60515
|
return shadow(this, "pageLayout", pageLayout);
|
|
60520
60516
|
}
|
|
60521
60517
|
get pageMode() {
|
|
60522
|
-
const obj = this
|
|
60518
|
+
const obj = __privateGet(this, _catDict).get("PageMode");
|
|
60523
60519
|
let pageMode = "UseNone";
|
|
60524
60520
|
if (obj instanceof Name) {
|
|
60525
60521
|
switch (obj.name) {
|
|
@@ -60535,7 +60531,7 @@ var _Catalog = class _Catalog {
|
|
|
60535
60531
|
return shadow(this, "pageMode", pageMode);
|
|
60536
60532
|
}
|
|
60537
60533
|
get viewerPreferences() {
|
|
60538
|
-
const obj = this
|
|
60534
|
+
const obj = __privateGet(this, _catDict).get("ViewerPreferences");
|
|
60539
60535
|
if (!(obj instanceof Dict)) {
|
|
60540
60536
|
return shadow(this, "viewerPreferences", null);
|
|
60541
60537
|
}
|
|
@@ -60646,15 +60642,13 @@ var _Catalog = class _Catalog {
|
|
|
60646
60642
|
warn(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
|
|
60647
60643
|
continue;
|
|
60648
60644
|
}
|
|
60649
|
-
|
|
60650
|
-
prefs = /* @__PURE__ */ Object.create(null);
|
|
60651
|
-
}
|
|
60645
|
+
prefs ?? (prefs = /* @__PURE__ */ Object.create(null));
|
|
60652
60646
|
prefs[key] = prefValue;
|
|
60653
60647
|
}
|
|
60654
60648
|
return shadow(this, "viewerPreferences", prefs);
|
|
60655
60649
|
}
|
|
60656
60650
|
get openAction() {
|
|
60657
|
-
const obj = this
|
|
60651
|
+
const obj = __privateGet(this, _catDict).get("OpenAction");
|
|
60658
60652
|
const openAction = /* @__PURE__ */ Object.create(null);
|
|
60659
60653
|
if (obj instanceof Dict) {
|
|
60660
60654
|
const destDict = new Dict(this.xref);
|
|
@@ -60666,7 +60660,7 @@ var _Catalog = class _Catalog {
|
|
|
60666
60660
|
} else if (resultObj.action) {
|
|
60667
60661
|
openAction.action = resultObj.action;
|
|
60668
60662
|
}
|
|
60669
|
-
} else if (
|
|
60663
|
+
} else if (isValidExplicitDest(obj)) {
|
|
60670
60664
|
openAction.dest = obj;
|
|
60671
60665
|
}
|
|
60672
60666
|
return shadow(
|
|
@@ -60676,72 +60670,48 @@ var _Catalog = class _Catalog {
|
|
|
60676
60670
|
);
|
|
60677
60671
|
}
|
|
60678
60672
|
get attachments() {
|
|
60679
|
-
const obj = this
|
|
60673
|
+
const obj = __privateGet(this, _catDict).get("Names");
|
|
60680
60674
|
let attachments = null;
|
|
60681
60675
|
if (obj instanceof Dict && obj.has("EmbeddedFiles")) {
|
|
60682
60676
|
const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
|
|
60683
60677
|
for (const [key, value] of nameTree.getAll()) {
|
|
60684
60678
|
const fs = new FileSpec(value, this.xref);
|
|
60685
|
-
|
|
60686
|
-
|
|
60687
|
-
|
|
60688
|
-
|
|
60679
|
+
attachments ?? (attachments = /* @__PURE__ */ Object.create(null));
|
|
60680
|
+
attachments[stringToPDFString(
|
|
60681
|
+
key,
|
|
60682
|
+
/* keepEscapeSequence = */
|
|
60683
|
+
true
|
|
60684
|
+
)] = fs.serializable;
|
|
60689
60685
|
}
|
|
60690
60686
|
}
|
|
60691
60687
|
return shadow(this, "attachments", attachments);
|
|
60692
60688
|
}
|
|
60693
60689
|
get xfaImages() {
|
|
60694
|
-
const obj = this
|
|
60690
|
+
const obj = __privateGet(this, _catDict).get("Names");
|
|
60695
60691
|
let xfaImages = null;
|
|
60696
60692
|
if (obj instanceof Dict && obj.has("XFAImages")) {
|
|
60697
60693
|
const nameTree = new NameTree(obj.getRaw("XFAImages"), this.xref);
|
|
60698
60694
|
for (const [key, value] of nameTree.getAll()) {
|
|
60699
|
-
if (
|
|
60700
|
-
xfaImages = new
|
|
60695
|
+
if (value instanceof BaseStream) {
|
|
60696
|
+
xfaImages ?? (xfaImages = /* @__PURE__ */ new Map());
|
|
60697
|
+
xfaImages.set(
|
|
60698
|
+
stringToPDFString(
|
|
60699
|
+
key,
|
|
60700
|
+
/* keepEscapeSequence = */
|
|
60701
|
+
true
|
|
60702
|
+
),
|
|
60703
|
+
value.getBytes()
|
|
60704
|
+
);
|
|
60701
60705
|
}
|
|
60702
|
-
xfaImages.set(stringToPDFString(key), value);
|
|
60703
60706
|
}
|
|
60704
60707
|
}
|
|
60705
60708
|
return shadow(this, "xfaImages", xfaImages);
|
|
60706
60709
|
}
|
|
60707
|
-
_collectJavaScript() {
|
|
60708
|
-
const obj = this._catDict.get("Names");
|
|
60709
|
-
let javaScript = null;
|
|
60710
|
-
function appendIfJavaScriptDict(name, jsDict) {
|
|
60711
|
-
if (!(jsDict instanceof Dict)) {
|
|
60712
|
-
return;
|
|
60713
|
-
}
|
|
60714
|
-
if (!isName(jsDict.get("S"), "JavaScript")) {
|
|
60715
|
-
return;
|
|
60716
|
-
}
|
|
60717
|
-
let js = jsDict.get("JS");
|
|
60718
|
-
if (js instanceof BaseStream) {
|
|
60719
|
-
js = js.getString();
|
|
60720
|
-
} else if (typeof js !== "string") {
|
|
60721
|
-
return;
|
|
60722
|
-
}
|
|
60723
|
-
js = stringToPDFString(js).replaceAll("\0", "");
|
|
60724
|
-
if (js) {
|
|
60725
|
-
(javaScript || (javaScript = /* @__PURE__ */ new Map())).set(name, js);
|
|
60726
|
-
}
|
|
60727
|
-
}
|
|
60728
|
-
if (obj instanceof Dict && obj.has("JavaScript")) {
|
|
60729
|
-
const nameTree = new NameTree(obj.getRaw("JavaScript"), this.xref);
|
|
60730
|
-
for (const [key, value] of nameTree.getAll()) {
|
|
60731
|
-
appendIfJavaScriptDict(stringToPDFString(key), value);
|
|
60732
|
-
}
|
|
60733
|
-
}
|
|
60734
|
-
const openAction = this._catDict.get("OpenAction");
|
|
60735
|
-
if (openAction) {
|
|
60736
|
-
appendIfJavaScriptDict("OpenAction", openAction);
|
|
60737
|
-
}
|
|
60738
|
-
return javaScript;
|
|
60739
|
-
}
|
|
60740
60710
|
get jsActions() {
|
|
60741
|
-
const javaScript = this.
|
|
60711
|
+
const javaScript = __privateMethod(this, _Catalog_instances, collectJavaScript_fn).call(this);
|
|
60742
60712
|
let actions = collectActions(
|
|
60743
60713
|
this.xref,
|
|
60744
|
-
this
|
|
60714
|
+
__privateGet(this, _catDict),
|
|
60745
60715
|
DocumentActionEventType
|
|
60746
60716
|
);
|
|
60747
60717
|
if (javaScript) {
|
|
@@ -60778,7 +60748,7 @@ var _Catalog = class _Catalog {
|
|
|
60778
60748
|
async getPageDict(pageIndex) {
|
|
60779
60749
|
const nodesToVisit = [this.toplevelPagesDict];
|
|
60780
60750
|
const visitedNodes = new RefSet();
|
|
60781
|
-
const pagesRef = this
|
|
60751
|
+
const pagesRef = __privateGet(this, _catDict).getRaw("Pages");
|
|
60782
60752
|
if (pagesRef instanceof Ref) {
|
|
60783
60753
|
visitedNodes.put(pagesRef);
|
|
60784
60754
|
}
|
|
@@ -60874,7 +60844,7 @@ var _Catalog = class _Catalog {
|
|
|
60874
60844
|
const { ignoreErrors } = this.pdfManager.evaluatorOptions;
|
|
60875
60845
|
const queue = [{ currentNode: this.toplevelPagesDict, posInKids: 0 }];
|
|
60876
60846
|
const visitedNodes = new RefSet();
|
|
60877
|
-
const pagesRef = this
|
|
60847
|
+
const pagesRef = __privateGet(this, _catDict).getRaw("Pages");
|
|
60878
60848
|
if (pagesRef instanceof Ref) {
|
|
60879
60849
|
visitedNodes.put(pagesRef);
|
|
60880
60850
|
}
|
|
@@ -61039,7 +61009,7 @@ var _Catalog = class _Catalog {
|
|
|
61039
61009
|
return next(pageRef);
|
|
61040
61010
|
}
|
|
61041
61011
|
get baseUrl() {
|
|
61042
|
-
const uri = this
|
|
61012
|
+
const uri = __privateGet(this, _catDict).get("URI");
|
|
61043
61013
|
if (uri instanceof Dict) {
|
|
61044
61014
|
const base = uri.get("Base");
|
|
61045
61015
|
if (typeof base === "string") {
|
|
@@ -61160,7 +61130,11 @@ var _Catalog = class _Catalog {
|
|
|
61160
61130
|
const relationship = target.get("R");
|
|
61161
61131
|
const name = target.get("N");
|
|
61162
61132
|
if (isName(relationship, "C") && typeof name === "string") {
|
|
61163
|
-
attachment = docAttachments[stringToPDFString(
|
|
61133
|
+
attachment = docAttachments[stringToPDFString(
|
|
61134
|
+
name,
|
|
61135
|
+
/* keepEscapeSequence = */
|
|
61136
|
+
true
|
|
61137
|
+
)];
|
|
61164
61138
|
}
|
|
61165
61139
|
}
|
|
61166
61140
|
if (attachment) {
|
|
@@ -61215,7 +61189,13 @@ var _Catalog = class _Catalog {
|
|
|
61215
61189
|
} else if (typeof jsAction === "string") {
|
|
61216
61190
|
js = jsAction;
|
|
61217
61191
|
}
|
|
61218
|
-
const jsURL = js && recoverJsURL(
|
|
61192
|
+
const jsURL = js && recoverJsURL(
|
|
61193
|
+
stringToPDFString(
|
|
61194
|
+
js,
|
|
61195
|
+
/* keepEscapeSequence = */
|
|
61196
|
+
true
|
|
61197
|
+
)
|
|
61198
|
+
);
|
|
61219
61199
|
if (jsURL) {
|
|
61220
61200
|
url = jsURL.url;
|
|
61221
61201
|
resultObj.newWindow = jsURL.newWindow;
|
|
@@ -61247,16 +61227,40 @@ var _Catalog = class _Catalog {
|
|
|
61247
61227
|
dest = dest.name;
|
|
61248
61228
|
}
|
|
61249
61229
|
if (typeof dest === "string") {
|
|
61250
|
-
resultObj.dest = stringToPDFString(
|
|
61230
|
+
resultObj.dest = stringToPDFString(
|
|
61231
|
+
dest,
|
|
61232
|
+
/* keepEscapeSequence = */
|
|
61233
|
+
true
|
|
61234
|
+
);
|
|
61251
61235
|
} else if (isValidExplicitDest(dest)) {
|
|
61252
61236
|
resultObj.dest = dest;
|
|
61253
61237
|
}
|
|
61254
61238
|
}
|
|
61255
61239
|
}
|
|
61256
61240
|
};
|
|
61241
|
+
_actualNumPages = new WeakMap();
|
|
61242
|
+
_catDict = new WeakMap();
|
|
61257
61243
|
_Catalog_instances = new WeakSet();
|
|
61244
|
+
readMarkInfo_fn = function() {
|
|
61245
|
+
const obj = __privateGet(this, _catDict).get("MarkInfo");
|
|
61246
|
+
if (!(obj instanceof Dict)) {
|
|
61247
|
+
return null;
|
|
61248
|
+
}
|
|
61249
|
+
const markInfo = {
|
|
61250
|
+
Marked: false,
|
|
61251
|
+
UserProperties: false,
|
|
61252
|
+
Suspects: false
|
|
61253
|
+
};
|
|
61254
|
+
for (const key in markInfo) {
|
|
61255
|
+
const value = obj.get(key);
|
|
61256
|
+
if (typeof value === "boolean") {
|
|
61257
|
+
markInfo[key] = value;
|
|
61258
|
+
}
|
|
61259
|
+
}
|
|
61260
|
+
return markInfo;
|
|
61261
|
+
};
|
|
61258
61262
|
readStructTreeRoot_fn = function() {
|
|
61259
|
-
const rawObj = this
|
|
61263
|
+
const rawObj = __privateGet(this, _catDict).getRaw("StructTreeRoot");
|
|
61260
61264
|
const obj = this.xref.fetchIfRef(rawObj);
|
|
61261
61265
|
if (!(obj instanceof Dict)) {
|
|
61262
61266
|
return null;
|
|
@@ -61265,6 +61269,92 @@ readStructTreeRoot_fn = function() {
|
|
|
61265
61269
|
root.init();
|
|
61266
61270
|
return root;
|
|
61267
61271
|
};
|
|
61272
|
+
readDocumentOutline_fn = function() {
|
|
61273
|
+
let obj = __privateGet(this, _catDict).get("Outlines");
|
|
61274
|
+
if (!(obj instanceof Dict)) {
|
|
61275
|
+
return null;
|
|
61276
|
+
}
|
|
61277
|
+
obj = obj.getRaw("First");
|
|
61278
|
+
if (!(obj instanceof Ref)) {
|
|
61279
|
+
return null;
|
|
61280
|
+
}
|
|
61281
|
+
const root = { items: [] };
|
|
61282
|
+
const queue = [{ obj, parent: root }];
|
|
61283
|
+
const processed = new RefSet();
|
|
61284
|
+
processed.put(obj);
|
|
61285
|
+
const xref = this.xref, blackColor = new Uint8ClampedArray(3);
|
|
61286
|
+
while (queue.length > 0) {
|
|
61287
|
+
const i = queue.shift();
|
|
61288
|
+
const outlineDict = xref.fetchIfRef(i.obj);
|
|
61289
|
+
if (outlineDict === null) {
|
|
61290
|
+
continue;
|
|
61291
|
+
}
|
|
61292
|
+
if (!outlineDict.has("Title")) {
|
|
61293
|
+
warn("Invalid outline item encountered.");
|
|
61294
|
+
}
|
|
61295
|
+
const data = { url: null, dest: null, action: null };
|
|
61296
|
+
_Catalog.parseDestDictionary({
|
|
61297
|
+
destDict: outlineDict,
|
|
61298
|
+
resultObj: data,
|
|
61299
|
+
docBaseUrl: this.baseUrl,
|
|
61300
|
+
docAttachments: this.attachments
|
|
61301
|
+
});
|
|
61302
|
+
const title = outlineDict.get("Title");
|
|
61303
|
+
const flags = outlineDict.get("F") || 0;
|
|
61304
|
+
const color = outlineDict.getArray("C");
|
|
61305
|
+
const count = outlineDict.get("Count");
|
|
61306
|
+
let rgbColor = blackColor;
|
|
61307
|
+
if (isNumberArray(color, 3) && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
|
|
61308
|
+
rgbColor = ColorSpaceUtils.rgb.getRgb(color, 0);
|
|
61309
|
+
}
|
|
61310
|
+
const outlineItem = {
|
|
61311
|
+
action: data.action,
|
|
61312
|
+
attachment: data.attachment,
|
|
61313
|
+
dest: data.dest,
|
|
61314
|
+
url: data.url,
|
|
61315
|
+
unsafeUrl: data.unsafeUrl,
|
|
61316
|
+
newWindow: data.newWindow,
|
|
61317
|
+
setOCGState: data.setOCGState,
|
|
61318
|
+
title: typeof title === "string" ? stringToPDFString(title) : "",
|
|
61319
|
+
color: rgbColor,
|
|
61320
|
+
count: Number.isInteger(count) ? count : void 0,
|
|
61321
|
+
bold: !!(flags & 2),
|
|
61322
|
+
italic: !!(flags & 1),
|
|
61323
|
+
items: []
|
|
61324
|
+
};
|
|
61325
|
+
i.parent.items.push(outlineItem);
|
|
61326
|
+
obj = outlineDict.getRaw("First");
|
|
61327
|
+
if (obj instanceof Ref && !processed.has(obj)) {
|
|
61328
|
+
queue.push({ obj, parent: outlineItem });
|
|
61329
|
+
processed.put(obj);
|
|
61330
|
+
}
|
|
61331
|
+
obj = outlineDict.getRaw("Next");
|
|
61332
|
+
if (obj instanceof Ref && !processed.has(obj)) {
|
|
61333
|
+
queue.push({ obj, parent: i.parent });
|
|
61334
|
+
processed.put(obj);
|
|
61335
|
+
}
|
|
61336
|
+
}
|
|
61337
|
+
return root.items.length > 0 ? root.items : null;
|
|
61338
|
+
};
|
|
61339
|
+
readPermissions_fn = function() {
|
|
61340
|
+
const encrypt = this.xref.trailer.get("Encrypt");
|
|
61341
|
+
if (!(encrypt instanceof Dict)) {
|
|
61342
|
+
return null;
|
|
61343
|
+
}
|
|
61344
|
+
let flags = encrypt.get("P");
|
|
61345
|
+
if (typeof flags !== "number") {
|
|
61346
|
+
return null;
|
|
61347
|
+
}
|
|
61348
|
+
flags += 2 ** 32;
|
|
61349
|
+
const permissions = [];
|
|
61350
|
+
for (const key in PermissionFlag) {
|
|
61351
|
+
const value = PermissionFlag[key];
|
|
61352
|
+
if (flags & value) {
|
|
61353
|
+
permissions.push(value);
|
|
61354
|
+
}
|
|
61355
|
+
}
|
|
61356
|
+
return permissions;
|
|
61357
|
+
};
|
|
61268
61358
|
readOptionalContentGroup_fn = function(groupRef) {
|
|
61269
61359
|
const group = this.xref.fetch(groupRef);
|
|
61270
61360
|
const obj = {
|
|
@@ -61410,16 +61500,142 @@ readOptionalContentConfig_fn = function(config, groupRefCache) {
|
|
|
61410
61500
|
};
|
|
61411
61501
|
};
|
|
61412
61502
|
readDests_fn = function() {
|
|
61413
|
-
const obj = this
|
|
61503
|
+
const obj = __privateGet(this, _catDict).get("Names");
|
|
61414
61504
|
const rawDests = [];
|
|
61415
61505
|
if (obj?.has("Dests")) {
|
|
61416
61506
|
rawDests.push(new NameTree(obj.getRaw("Dests"), this.xref));
|
|
61417
61507
|
}
|
|
61418
|
-
if (this
|
|
61419
|
-
rawDests.push(this
|
|
61508
|
+
if (__privateGet(this, _catDict).has("Dests")) {
|
|
61509
|
+
rawDests.push(__privateGet(this, _catDict).get("Dests"));
|
|
61420
61510
|
}
|
|
61421
61511
|
return rawDests;
|
|
61422
61512
|
};
|
|
61513
|
+
readPageLabels_fn = function() {
|
|
61514
|
+
const obj = __privateGet(this, _catDict).getRaw("PageLabels");
|
|
61515
|
+
if (!obj) {
|
|
61516
|
+
return null;
|
|
61517
|
+
}
|
|
61518
|
+
const pageLabels = new Array(this.numPages);
|
|
61519
|
+
let style = null, prefix = "";
|
|
61520
|
+
const numberTree = new NumberTree(obj, this.xref);
|
|
61521
|
+
const nums = numberTree.getAll();
|
|
61522
|
+
let currentLabel = "", currentIndex = 1;
|
|
61523
|
+
for (let i = 0, ii = this.numPages; i < ii; i++) {
|
|
61524
|
+
const labelDict = nums.get(i);
|
|
61525
|
+
if (labelDict !== void 0) {
|
|
61526
|
+
if (!(labelDict instanceof Dict)) {
|
|
61527
|
+
throw new FormatError("PageLabel is not a dictionary.");
|
|
61528
|
+
}
|
|
61529
|
+
if (labelDict.has("Type") && !isName(labelDict.get("Type"), "PageLabel")) {
|
|
61530
|
+
throw new FormatError("Invalid type in PageLabel dictionary.");
|
|
61531
|
+
}
|
|
61532
|
+
if (labelDict.has("S")) {
|
|
61533
|
+
const s = labelDict.get("S");
|
|
61534
|
+
if (!(s instanceof Name)) {
|
|
61535
|
+
throw new FormatError("Invalid style in PageLabel dictionary.");
|
|
61536
|
+
}
|
|
61537
|
+
style = s.name;
|
|
61538
|
+
} else {
|
|
61539
|
+
style = null;
|
|
61540
|
+
}
|
|
61541
|
+
if (labelDict.has("P")) {
|
|
61542
|
+
const p = labelDict.get("P");
|
|
61543
|
+
if (typeof p !== "string") {
|
|
61544
|
+
throw new FormatError("Invalid prefix in PageLabel dictionary.");
|
|
61545
|
+
}
|
|
61546
|
+
prefix = stringToPDFString(p);
|
|
61547
|
+
} else {
|
|
61548
|
+
prefix = "";
|
|
61549
|
+
}
|
|
61550
|
+
if (labelDict.has("St")) {
|
|
61551
|
+
const st = labelDict.get("St");
|
|
61552
|
+
if (!(Number.isInteger(st) && st >= 1)) {
|
|
61553
|
+
throw new FormatError("Invalid start in PageLabel dictionary.");
|
|
61554
|
+
}
|
|
61555
|
+
currentIndex = st;
|
|
61556
|
+
} else {
|
|
61557
|
+
currentIndex = 1;
|
|
61558
|
+
}
|
|
61559
|
+
}
|
|
61560
|
+
switch (style) {
|
|
61561
|
+
case "D":
|
|
61562
|
+
currentLabel = currentIndex;
|
|
61563
|
+
break;
|
|
61564
|
+
case "R":
|
|
61565
|
+
case "r":
|
|
61566
|
+
currentLabel = toRomanNumerals(currentIndex, style === "r");
|
|
61567
|
+
break;
|
|
61568
|
+
case "A":
|
|
61569
|
+
case "a":
|
|
61570
|
+
const LIMIT = 26;
|
|
61571
|
+
const A_UPPER_CASE = 65, A_LOWER_CASE = 97;
|
|
61572
|
+
const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
|
|
61573
|
+
const letterIndex = currentIndex - 1;
|
|
61574
|
+
const character = String.fromCharCode(
|
|
61575
|
+
baseCharCode + letterIndex % LIMIT
|
|
61576
|
+
);
|
|
61577
|
+
currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
|
|
61578
|
+
break;
|
|
61579
|
+
default:
|
|
61580
|
+
if (style) {
|
|
61581
|
+
throw new FormatError(
|
|
61582
|
+
`Invalid style "${style}" in PageLabel dictionary.`
|
|
61583
|
+
);
|
|
61584
|
+
}
|
|
61585
|
+
currentLabel = "";
|
|
61586
|
+
}
|
|
61587
|
+
pageLabels[i] = prefix + currentLabel;
|
|
61588
|
+
currentIndex++;
|
|
61589
|
+
}
|
|
61590
|
+
return pageLabels;
|
|
61591
|
+
};
|
|
61592
|
+
collectJavaScript_fn = function() {
|
|
61593
|
+
const obj = __privateGet(this, _catDict).get("Names");
|
|
61594
|
+
let javaScript = null;
|
|
61595
|
+
function appendIfJavaScriptDict(name, jsDict) {
|
|
61596
|
+
if (!(jsDict instanceof Dict)) {
|
|
61597
|
+
return;
|
|
61598
|
+
}
|
|
61599
|
+
if (!isName(jsDict.get("S"), "JavaScript")) {
|
|
61600
|
+
return;
|
|
61601
|
+
}
|
|
61602
|
+
let js = jsDict.get("JS");
|
|
61603
|
+
if (js instanceof BaseStream) {
|
|
61604
|
+
js = js.getString();
|
|
61605
|
+
} else if (typeof js !== "string") {
|
|
61606
|
+
return;
|
|
61607
|
+
}
|
|
61608
|
+
js = stringToPDFString(
|
|
61609
|
+
js,
|
|
61610
|
+
/* keepEscapeSequence = */
|
|
61611
|
+
true
|
|
61612
|
+
).replaceAll(
|
|
61613
|
+
"\0",
|
|
61614
|
+
""
|
|
61615
|
+
);
|
|
61616
|
+
if (js) {
|
|
61617
|
+
(javaScript || (javaScript = /* @__PURE__ */ new Map())).set(name, js);
|
|
61618
|
+
}
|
|
61619
|
+
}
|
|
61620
|
+
if (obj instanceof Dict && obj.has("JavaScript")) {
|
|
61621
|
+
const nameTree = new NameTree(obj.getRaw("JavaScript"), this.xref);
|
|
61622
|
+
for (const [key, value] of nameTree.getAll()) {
|
|
61623
|
+
appendIfJavaScriptDict(
|
|
61624
|
+
stringToPDFString(
|
|
61625
|
+
key,
|
|
61626
|
+
/* keepEscapeSequence = */
|
|
61627
|
+
true
|
|
61628
|
+
),
|
|
61629
|
+
value
|
|
61630
|
+
);
|
|
61631
|
+
}
|
|
61632
|
+
}
|
|
61633
|
+
const openAction = __privateGet(this, _catDict).get("OpenAction");
|
|
61634
|
+
if (openAction) {
|
|
61635
|
+
appendIfJavaScriptDict("OpenAction", openAction);
|
|
61636
|
+
}
|
|
61637
|
+
return javaScript;
|
|
61638
|
+
};
|
|
61423
61639
|
var Catalog = _Catalog;
|
|
61424
61640
|
|
|
61425
61641
|
// src/pdf.js/src/core/object_loader.js
|
|
@@ -61440,19 +61656,17 @@ function addChildren(node, nodesToVisit) {
|
|
|
61440
61656
|
}
|
|
61441
61657
|
}
|
|
61442
61658
|
}
|
|
61443
|
-
var
|
|
61659
|
+
var _ObjectLoader_instances, walk_fn;
|
|
61660
|
+
var _ObjectLoader = class _ObjectLoader {
|
|
61444
61661
|
constructor(dict, keys, xref) {
|
|
61662
|
+
__privateAdd(this, _ObjectLoader_instances);
|
|
61663
|
+
__publicField(this, "refSet", new RefSet());
|
|
61445
61664
|
this.dict = dict;
|
|
61446
61665
|
this.keys = keys;
|
|
61447
61666
|
this.xref = xref;
|
|
61448
|
-
this.refSet = null;
|
|
61449
61667
|
}
|
|
61450
61668
|
async load() {
|
|
61451
|
-
if (this.xref.stream.isDataLoaded) {
|
|
61452
|
-
return void 0;
|
|
61453
|
-
}
|
|
61454
61669
|
const { keys, dict } = this;
|
|
61455
|
-
this.refSet = new RefSet();
|
|
61456
61670
|
const nodesToVisit = [];
|
|
61457
61671
|
for (const key of keys) {
|
|
61458
61672
|
const rawValue = dict.getRaw(key);
|
|
@@ -61460,62 +61674,69 @@ var ObjectLoader = class {
|
|
|
61460
61674
|
nodesToVisit.push(rawValue);
|
|
61461
61675
|
}
|
|
61462
61676
|
}
|
|
61463
|
-
|
|
61677
|
+
await __privateMethod(this, _ObjectLoader_instances, walk_fn).call(this, nodesToVisit);
|
|
61678
|
+
this.refSet = null;
|
|
61464
61679
|
}
|
|
61465
|
-
async
|
|
61466
|
-
|
|
61467
|
-
|
|
61468
|
-
|
|
61469
|
-
|
|
61470
|
-
|
|
61471
|
-
|
|
61472
|
-
|
|
61473
|
-
|
|
61474
|
-
|
|
61475
|
-
|
|
61476
|
-
|
|
61477
|
-
|
|
61478
|
-
|
|
61479
|
-
|
|
61480
|
-
|
|
61481
|
-
|
|
61482
|
-
|
|
61483
|
-
|
|
61484
|
-
|
|
61485
|
-
|
|
61680
|
+
static async load(obj, keys, xref) {
|
|
61681
|
+
if (xref.stream.isDataLoaded) {
|
|
61682
|
+
return;
|
|
61683
|
+
}
|
|
61684
|
+
const objLoader = new _ObjectLoader(obj, keys, xref);
|
|
61685
|
+
await objLoader.load();
|
|
61686
|
+
}
|
|
61687
|
+
};
|
|
61688
|
+
_ObjectLoader_instances = new WeakSet();
|
|
61689
|
+
walk_fn = async function(nodesToVisit) {
|
|
61690
|
+
const nodesToRevisit = [];
|
|
61691
|
+
const pendingRequests = [];
|
|
61692
|
+
while (nodesToVisit.length) {
|
|
61693
|
+
let currentNode = nodesToVisit.pop();
|
|
61694
|
+
if (currentNode instanceof Ref) {
|
|
61695
|
+
if (this.refSet.has(currentNode)) {
|
|
61696
|
+
continue;
|
|
61697
|
+
}
|
|
61698
|
+
try {
|
|
61699
|
+
this.refSet.put(currentNode);
|
|
61700
|
+
currentNode = this.xref.fetch(currentNode);
|
|
61701
|
+
} catch (ex) {
|
|
61702
|
+
if (!(ex instanceof MissingDataException)) {
|
|
61703
|
+
warn(`ObjectLoader.#walk - requesting all data: "${ex}".`);
|
|
61704
|
+
await this.xref.stream.manager.requestAllChunks();
|
|
61705
|
+
return;
|
|
61486
61706
|
}
|
|
61707
|
+
nodesToRevisit.push(currentNode);
|
|
61708
|
+
pendingRequests.push({ begin: ex.begin, end: ex.end });
|
|
61487
61709
|
}
|
|
61488
|
-
|
|
61489
|
-
|
|
61490
|
-
|
|
61491
|
-
|
|
61492
|
-
|
|
61493
|
-
|
|
61494
|
-
|
|
61495
|
-
|
|
61496
|
-
foundMissingData = true;
|
|
61497
|
-
pendingRequests.push({ begin: stream.start, end: stream.end });
|
|
61498
|
-
}
|
|
61499
|
-
if (foundMissingData) {
|
|
61500
|
-
nodesToRevisit.push(currentNode);
|
|
61710
|
+
}
|
|
61711
|
+
if (currentNode instanceof BaseStream) {
|
|
61712
|
+
const baseStreams = currentNode.getBaseStreams();
|
|
61713
|
+
if (baseStreams) {
|
|
61714
|
+
let foundMissingData = false;
|
|
61715
|
+
for (const stream of baseStreams) {
|
|
61716
|
+
if (stream.isDataLoaded) {
|
|
61717
|
+
continue;
|
|
61501
61718
|
}
|
|
61719
|
+
foundMissingData = true;
|
|
61720
|
+
pendingRequests.push({ begin: stream.start, end: stream.end });
|
|
61721
|
+
}
|
|
61722
|
+
if (foundMissingData) {
|
|
61723
|
+
nodesToRevisit.push(currentNode);
|
|
61502
61724
|
}
|
|
61503
61725
|
}
|
|
61504
|
-
addChildren(currentNode, nodesToVisit);
|
|
61505
61726
|
}
|
|
61506
|
-
|
|
61507
|
-
|
|
61508
|
-
|
|
61509
|
-
|
|
61510
|
-
|
|
61511
|
-
|
|
61727
|
+
addChildren(currentNode, nodesToVisit);
|
|
61728
|
+
}
|
|
61729
|
+
if (pendingRequests.length) {
|
|
61730
|
+
await this.xref.stream.manager.requestRanges(pendingRequests);
|
|
61731
|
+
for (const node of nodesToRevisit) {
|
|
61732
|
+
if (node instanceof Ref) {
|
|
61733
|
+
this.refSet.remove(node);
|
|
61512
61734
|
}
|
|
61513
|
-
return this._walk(nodesToRevisit);
|
|
61514
61735
|
}
|
|
61515
|
-
this.
|
|
61516
|
-
return void 0;
|
|
61736
|
+
await __privateMethod(this, _ObjectLoader_instances, walk_fn).call(this, nodesToRevisit);
|
|
61517
61737
|
}
|
|
61518
61738
|
};
|
|
61739
|
+
var ObjectLoader = _ObjectLoader;
|
|
61519
61740
|
|
|
61520
61741
|
// src/pdf.js/src/core/xfa/symbol_utils.js
|
|
61521
61742
|
var $acceptWhitespace = Symbol();
|
|
@@ -65181,7 +65402,7 @@ var CheckButton = class extends XFAObject {
|
|
|
65181
65402
|
this.margin = null;
|
|
65182
65403
|
}
|
|
65183
65404
|
[$toHTML](availableSpace) {
|
|
65184
|
-
const style = toStyle("margin");
|
|
65405
|
+
const style = toStyle(this, "margin");
|
|
65185
65406
|
const size = measureToString(this.size);
|
|
65186
65407
|
style.width = style.height = size;
|
|
65187
65408
|
let type;
|
|
@@ -66257,6 +66478,7 @@ var ExclGroup = class extends XFAObject {
|
|
|
66257
66478
|
return getAvailableSpace(this);
|
|
66258
66479
|
}
|
|
66259
66480
|
[$toHTML](availableSpace) {
|
|
66481
|
+
var _a;
|
|
66260
66482
|
setTabIndex(this);
|
|
66261
66483
|
if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
|
|
66262
66484
|
return HTMLResult.EMPTY;
|
|
@@ -66268,9 +66490,7 @@ var ExclGroup = class extends XFAObject {
|
|
|
66268
66490
|
class: []
|
|
66269
66491
|
};
|
|
66270
66492
|
setAccess(this, attributes.class);
|
|
66271
|
-
|
|
66272
|
-
this[$extra] = /* @__PURE__ */ Object.create(null);
|
|
66273
|
-
}
|
|
66493
|
+
this[_a = $extra] || (this[_a] = /* @__PURE__ */ Object.create(null));
|
|
66274
66494
|
Object.assign(this[$extra], {
|
|
66275
66495
|
children,
|
|
66276
66496
|
attributes,
|
|
@@ -66521,6 +66741,7 @@ var Field = class extends XFAObject {
|
|
|
66521
66741
|
_setValue(this, value);
|
|
66522
66742
|
}
|
|
66523
66743
|
[$toHTML](availableSpace) {
|
|
66744
|
+
var _a, _b;
|
|
66524
66745
|
setTabIndex(this);
|
|
66525
66746
|
if (!this.ui) {
|
|
66526
66747
|
this.ui = new Ui({});
|
|
@@ -66684,9 +66905,7 @@ var Field = class extends XFAObject {
|
|
|
66684
66905
|
ui.attributes.tabindex = this[$tabIndex];
|
|
66685
66906
|
}
|
|
66686
66907
|
}
|
|
66687
|
-
|
|
66688
|
-
ui.attributes.style = /* @__PURE__ */ Object.create(null);
|
|
66689
|
-
}
|
|
66908
|
+
(_a = ui.attributes).style || (_a.style = /* @__PURE__ */ Object.create(null));
|
|
66690
66909
|
let aElement = null;
|
|
66691
66910
|
if (this.ui.button) {
|
|
66692
66911
|
if (ui.children.length === 1) {
|
|
@@ -66765,9 +66984,7 @@ var Field = class extends XFAObject {
|
|
|
66765
66984
|
} else if (this.ui.checkButton) {
|
|
66766
66985
|
caption.attributes.class[0] = "xfaCaptionForCheckButton";
|
|
66767
66986
|
}
|
|
66768
|
-
|
|
66769
|
-
ui.attributes.class = [];
|
|
66770
|
-
}
|
|
66987
|
+
(_b = ui.attributes).class || (_b.class = []);
|
|
66771
66988
|
ui.children.splice(0, 0, caption);
|
|
66772
66989
|
switch (this.caption.placement) {
|
|
66773
66990
|
case "left":
|
|
@@ -67103,7 +67320,7 @@ var Image = class extends StringObject {
|
|
|
67103
67320
|
if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
|
|
67104
67321
|
return HTMLResult.EMPTY;
|
|
67105
67322
|
}
|
|
67106
|
-
let buffer = this[$globalData].images
|
|
67323
|
+
let buffer = this[$globalData].images?.get(this.href);
|
|
67107
67324
|
if (!buffer && (this.href || !this[$content])) {
|
|
67108
67325
|
return HTMLResult.EMPTY;
|
|
67109
67326
|
}
|
|
@@ -67735,11 +67952,10 @@ var PageArea = class extends XFAObject {
|
|
|
67735
67952
|
delete this[$extra];
|
|
67736
67953
|
}
|
|
67737
67954
|
[$getNextPage]() {
|
|
67738
|
-
|
|
67739
|
-
|
|
67740
|
-
|
|
67741
|
-
|
|
67742
|
-
}
|
|
67955
|
+
var _a;
|
|
67956
|
+
this[_a = $extra] || (this[_a] = {
|
|
67957
|
+
numberOfUse: 0
|
|
67958
|
+
});
|
|
67743
67959
|
const parent = this[$getParent]();
|
|
67744
67960
|
if (parent.relation === "orderedOccurrence") {
|
|
67745
67961
|
if (this[$isUsable]()) {
|
|
@@ -67753,11 +67969,10 @@ var PageArea = class extends XFAObject {
|
|
|
67753
67969
|
return this[$extra].space || { width: 0, height: 0 };
|
|
67754
67970
|
}
|
|
67755
67971
|
[$toHTML]() {
|
|
67756
|
-
|
|
67757
|
-
|
|
67758
|
-
|
|
67759
|
-
|
|
67760
|
-
}
|
|
67972
|
+
var _a;
|
|
67973
|
+
this[_a = $extra] || (this[_a] = {
|
|
67974
|
+
numberOfUse: 1
|
|
67975
|
+
});
|
|
67761
67976
|
const children = [];
|
|
67762
67977
|
this[$extra].children = children;
|
|
67763
67978
|
const style = /* @__PURE__ */ Object.create(null);
|
|
@@ -67839,13 +68054,12 @@ var PageSet = class _PageSet extends XFAObject {
|
|
|
67839
68054
|
return !this.occur || this.occur.max === -1 || this[$extra].numberOfUse < this.occur.max;
|
|
67840
68055
|
}
|
|
67841
68056
|
[$getNextPage]() {
|
|
67842
|
-
|
|
67843
|
-
|
|
67844
|
-
|
|
67845
|
-
|
|
67846
|
-
|
|
67847
|
-
|
|
67848
|
-
}
|
|
68057
|
+
var _a;
|
|
68058
|
+
this[_a = $extra] || (this[_a] = {
|
|
68059
|
+
numberOfUse: 1,
|
|
68060
|
+
pageIndex: -1,
|
|
68061
|
+
pageSetIndex: -1
|
|
68062
|
+
});
|
|
67849
68063
|
if (this.relation === "orderedOccurrence") {
|
|
67850
68064
|
if (this[$extra].pageIndex + 1 < this.pageArea.children.length) {
|
|
67851
68065
|
this[$extra].pageIndex += 1;
|
|
@@ -68600,6 +68814,7 @@ var Subform = class extends XFAObject {
|
|
|
68600
68814
|
return true;
|
|
68601
68815
|
}
|
|
68602
68816
|
[$toHTML](availableSpace) {
|
|
68817
|
+
var _a;
|
|
68603
68818
|
setTabIndex(this);
|
|
68604
68819
|
if (this.break) {
|
|
68605
68820
|
if (this.break.after !== "auto" || this.break.afterTarget !== "") {
|
|
@@ -68659,9 +68874,7 @@ var Subform = class extends XFAObject {
|
|
|
68659
68874
|
class: []
|
|
68660
68875
|
};
|
|
68661
68876
|
setAccess(this, attributes.class);
|
|
68662
|
-
|
|
68663
|
-
this[$extra] = /* @__PURE__ */ Object.create(null);
|
|
68664
|
-
}
|
|
68877
|
+
this[_a = $extra] || (this[_a] = /* @__PURE__ */ Object.create(null));
|
|
68665
68878
|
Object.assign(this[$extra], {
|
|
68666
68879
|
children,
|
|
68667
68880
|
line: null,
|
|
@@ -69023,9 +69236,7 @@ var Template = class extends XFAObject {
|
|
|
69023
69236
|
breakBefore[$extra] = {};
|
|
69024
69237
|
}
|
|
69025
69238
|
}
|
|
69026
|
-
|
|
69027
|
-
pageArea = pageAreas[0];
|
|
69028
|
-
}
|
|
69239
|
+
pageArea || (pageArea = pageAreas[0]);
|
|
69029
69240
|
pageArea[$extra] = {
|
|
69030
69241
|
numberOfUse: 1
|
|
69031
69242
|
};
|
|
@@ -73566,6 +73777,7 @@ var XFAParser = class _XFAParser extends XMLParserBase {
|
|
|
73566
73777
|
this._current[$onText](text);
|
|
73567
73778
|
}
|
|
73568
73779
|
_mkAttributes(attributes, tagName) {
|
|
73780
|
+
var _a;
|
|
73569
73781
|
let namespace = null;
|
|
73570
73782
|
let prefixes = null;
|
|
73571
73783
|
const attributeObj = /* @__PURE__ */ Object.create({});
|
|
@@ -73578,19 +73790,14 @@ var XFAParser = class _XFAParser extends XMLParserBase {
|
|
|
73578
73790
|
}
|
|
73579
73791
|
} else if (name.startsWith("xmlns:")) {
|
|
73580
73792
|
const prefix = name.substring("xmlns:".length);
|
|
73581
|
-
|
|
73582
|
-
prefixes = [];
|
|
73583
|
-
}
|
|
73793
|
+
prefixes ?? (prefixes = []);
|
|
73584
73794
|
prefixes.push({ prefix, value });
|
|
73585
73795
|
} else {
|
|
73586
73796
|
const i = name.indexOf(":");
|
|
73587
73797
|
if (i === -1) {
|
|
73588
73798
|
attributeObj[name] = value;
|
|
73589
73799
|
} else {
|
|
73590
|
-
|
|
73591
|
-
if (!nsAttrs) {
|
|
73592
|
-
nsAttrs = attributeObj[$nsAttributes] = /* @__PURE__ */ Object.create(null);
|
|
73593
|
-
}
|
|
73800
|
+
const nsAttrs = attributeObj[_a = $nsAttributes] ?? (attributeObj[_a] = /* @__PURE__ */ Object.create(null));
|
|
73594
73801
|
const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
|
|
73595
73802
|
const attrs = nsAttrs[ns] || (nsAttrs[ns] = /* @__PURE__ */ Object.create(null));
|
|
73596
73803
|
attrs[attrName] = value;
|
|
@@ -73669,7 +73876,7 @@ var XFAFactory = class _XFAFactory {
|
|
|
73669
73876
|
}
|
|
73670
73877
|
}
|
|
73671
73878
|
isValid() {
|
|
73672
|
-
return this.root && this.form;
|
|
73879
|
+
return !!(this.root && this.form);
|
|
73673
73880
|
}
|
|
73674
73881
|
/**
|
|
73675
73882
|
* In order to avoid to block the event loop, the conversion
|
|
@@ -74660,14 +74867,12 @@ var Annotation = class {
|
|
|
74660
74867
|
this.oc = oc;
|
|
74661
74868
|
}
|
|
74662
74869
|
}
|
|
74663
|
-
loadResources(keys, appearance) {
|
|
74664
|
-
|
|
74665
|
-
|
|
74666
|
-
|
|
74667
|
-
|
|
74668
|
-
|
|
74669
|
-
return objectLoader.load().then(() => resources);
|
|
74670
|
-
});
|
|
74870
|
+
async loadResources(keys, appearance) {
|
|
74871
|
+
const resources = await appearance.dict.getAsync("Resources");
|
|
74872
|
+
if (resources) {
|
|
74873
|
+
await ObjectLoader.load(resources, keys, resources.xref);
|
|
74874
|
+
}
|
|
74875
|
+
return resources;
|
|
74671
74876
|
}
|
|
74672
74877
|
async getOperatorList(evaluator, task, intent, annotationStorage) {
|
|
74673
74878
|
const { hasOwnCanvas, id, rect } = this.data;
|
|
@@ -74694,7 +74899,7 @@ var Annotation = class {
|
|
|
74694
74899
|
}
|
|
74695
74900
|
const appearanceDict = appearance.dict;
|
|
74696
74901
|
const resources = await this.loadResources(
|
|
74697
|
-
|
|
74902
|
+
RESOURCES_KEYS_OPERATOR_LIST,
|
|
74698
74903
|
appearance
|
|
74699
74904
|
);
|
|
74700
74905
|
const bbox = lookupRect(appearanceDict.getArray("BBox"), [0, 0, 1, 1]);
|
|
@@ -74747,7 +74952,7 @@ var Annotation = class {
|
|
|
74747
74952
|
return;
|
|
74748
74953
|
}
|
|
74749
74954
|
const resources = await this.loadResources(
|
|
74750
|
-
|
|
74955
|
+
RESOURCES_KEYS_TEXT_CONTENT,
|
|
74751
74956
|
this.appearance
|
|
74752
74957
|
);
|
|
74753
74958
|
const text = [];
|
|
@@ -75508,7 +75713,8 @@ var WidgetAnnotation = class _WidgetAnnotation extends Annotation {
|
|
|
75508
75713
|
const appearanceDict = appearanceStream.dict = new Dict(xref);
|
|
75509
75714
|
appearanceDict.set("Subtype", Name.get("Form"));
|
|
75510
75715
|
appearanceDict.set("Resources", resources);
|
|
75511
|
-
|
|
75716
|
+
const bbox = rotation % 180 === 0 ? [0, 0, this.width, this.height] : [0, 0, this.height, this.width];
|
|
75717
|
+
appearanceDict.set("BBox", bbox);
|
|
75512
75718
|
const rotationMatrix = this.getRotationMatrix(annotationStorage);
|
|
75513
75719
|
if (rotationMatrix !== IDENTITY_MATRIX) {
|
|
75514
75720
|
appearanceDict.set("Matrix", rotationMatrix);
|
|
@@ -76249,7 +76455,7 @@ var ButtonWidgetAnnotation = class extends WidgetAnnotation {
|
|
|
76249
76455
|
this.data.fieldValue = asValue;
|
|
76250
76456
|
}
|
|
76251
76457
|
const yes = this.data.fieldValue !== null && this.data.fieldValue !== "Off" ? this.data.fieldValue : "Yes";
|
|
76252
|
-
const exportValues = normalAppearance.getKeys();
|
|
76458
|
+
const exportValues = this._decodeFormValue(normalAppearance.getKeys());
|
|
76253
76459
|
if (exportValues.length === 0) {
|
|
76254
76460
|
exportValues.push("Off", yes);
|
|
76255
76461
|
} else if (exportValues.length === 1) {
|
|
@@ -76380,6 +76586,7 @@ var ButtonWidgetAnnotation = class extends WidgetAnnotation {
|
|
|
76380
76586
|
};
|
|
76381
76587
|
var ChoiceWidgetAnnotation = class extends WidgetAnnotation {
|
|
76382
76588
|
constructor(params) {
|
|
76589
|
+
var _a;
|
|
76383
76590
|
super(params);
|
|
76384
76591
|
const { dict, xref } = params;
|
|
76385
76592
|
this.indices = dict.getArray("I");
|
|
@@ -76403,8 +76610,8 @@ var ChoiceWidgetAnnotation = class extends WidgetAnnotation {
|
|
|
76403
76610
|
if (!this.hasIndices) {
|
|
76404
76611
|
if (typeof this.data.fieldValue === "string") {
|
|
76405
76612
|
this.data.fieldValue = [this.data.fieldValue];
|
|
76406
|
-
} else
|
|
76407
|
-
this.data.fieldValue = [];
|
|
76613
|
+
} else {
|
|
76614
|
+
(_a = this.data).fieldValue || (_a.fieldValue = []);
|
|
76408
76615
|
}
|
|
76409
76616
|
} else {
|
|
76410
76617
|
this.data.fieldValue = [];
|
|
@@ -81819,7 +82026,7 @@ _firstXRefStmPos = new WeakMap();
|
|
|
81819
82026
|
|
|
81820
82027
|
// src/pdf.js/src/core/document.js
|
|
81821
82028
|
var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
|
81822
|
-
var _Page_instances, replaceIdByRef_fn;
|
|
82029
|
+
var _resourcesPromise, _Page_instances, createPartialEvaluator_fn, getInheritableProperty_fn, getBoundingBox_fn, onSubStreamError_fn, replaceIdByRef_fn, getMergedResources_fn;
|
|
81823
82030
|
var Page = class {
|
|
81824
82031
|
constructor({
|
|
81825
82032
|
pdfManager,
|
|
@@ -81838,6 +82045,7 @@ var Page = class {
|
|
|
81838
82045
|
xfaFactory
|
|
81839
82046
|
}) {
|
|
81840
82047
|
__privateAdd(this, _Page_instances);
|
|
82048
|
+
__privateAdd(this, _resourcesPromise, null);
|
|
81841
82049
|
this.pdfManager = pdfManager;
|
|
81842
82050
|
this.pageIndex = pageIndex;
|
|
81843
82051
|
this.pageDict = pageDict;
|
|
@@ -81851,7 +82059,6 @@ var Page = class {
|
|
|
81851
82059
|
this.systemFontCache = systemFontCache;
|
|
81852
82060
|
this.nonBlendModesSet = nonBlendModesSet;
|
|
81853
82061
|
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
|
81854
|
-
this.resourcesPromise = null;
|
|
81855
82062
|
this.xfaFactory = xfaFactory;
|
|
81856
82063
|
const idCounters = {
|
|
81857
82064
|
obj: 0
|
|
@@ -81865,67 +82072,29 @@ var Page = class {
|
|
|
81865
82072
|
}
|
|
81866
82073
|
};
|
|
81867
82074
|
}
|
|
81868
|
-
/**
|
|
81869
|
-
* @private
|
|
81870
|
-
*/
|
|
81871
|
-
_getInheritableProperty(key, getArray = false) {
|
|
81872
|
-
const value = getInheritableProperty({
|
|
81873
|
-
dict: this.pageDict,
|
|
81874
|
-
key,
|
|
81875
|
-
getArray,
|
|
81876
|
-
stopWhenFound: false
|
|
81877
|
-
});
|
|
81878
|
-
if (!Array.isArray(value)) {
|
|
81879
|
-
return value;
|
|
81880
|
-
}
|
|
81881
|
-
if (value.length === 1 || !(value[0] instanceof Dict)) {
|
|
81882
|
-
return value[0];
|
|
81883
|
-
}
|
|
81884
|
-
return Dict.merge({ xref: this.xref, dictArray: value });
|
|
81885
|
-
}
|
|
81886
82075
|
get content() {
|
|
81887
82076
|
return this.pageDict.getArray("Contents");
|
|
81888
82077
|
}
|
|
81889
82078
|
get resources() {
|
|
81890
|
-
const resources = this.
|
|
82079
|
+
const resources = __privateMethod(this, _Page_instances, getInheritableProperty_fn).call(this, "Resources");
|
|
81891
82080
|
return shadow(
|
|
81892
82081
|
this,
|
|
81893
82082
|
"resources",
|
|
81894
82083
|
resources instanceof Dict ? resources : Dict.empty
|
|
81895
82084
|
);
|
|
81896
82085
|
}
|
|
81897
|
-
_getBoundingBox(name) {
|
|
81898
|
-
if (this.xfaData) {
|
|
81899
|
-
return this.xfaData.bbox;
|
|
81900
|
-
}
|
|
81901
|
-
const box = lookupNormalRect(
|
|
81902
|
-
this._getInheritableProperty(
|
|
81903
|
-
name,
|
|
81904
|
-
/* getArray = */
|
|
81905
|
-
true
|
|
81906
|
-
),
|
|
81907
|
-
null
|
|
81908
|
-
);
|
|
81909
|
-
if (box) {
|
|
81910
|
-
if (box[2] - box[0] > 0 && box[3] - box[1] > 0) {
|
|
81911
|
-
return box;
|
|
81912
|
-
}
|
|
81913
|
-
warn(`Empty, or invalid, /${name} entry.`);
|
|
81914
|
-
}
|
|
81915
|
-
return null;
|
|
81916
|
-
}
|
|
81917
82086
|
get mediaBox() {
|
|
81918
82087
|
return shadow(
|
|
81919
82088
|
this,
|
|
81920
82089
|
"mediaBox",
|
|
81921
|
-
this.
|
|
82090
|
+
__privateMethod(this, _Page_instances, getBoundingBox_fn).call(this, "MediaBox") || LETTER_SIZE_MEDIABOX
|
|
81922
82091
|
);
|
|
81923
82092
|
}
|
|
81924
82093
|
get cropBox() {
|
|
81925
82094
|
return shadow(
|
|
81926
82095
|
this,
|
|
81927
82096
|
"cropBox",
|
|
81928
|
-
this.
|
|
82097
|
+
__privateMethod(this, _Page_instances, getBoundingBox_fn).call(this, "CropBox") || this.mediaBox
|
|
81929
82098
|
);
|
|
81930
82099
|
}
|
|
81931
82100
|
get userUnit() {
|
|
@@ -81948,7 +82117,7 @@ var Page = class {
|
|
|
81948
82117
|
return shadow(this, "view", mediaBox);
|
|
81949
82118
|
}
|
|
81950
82119
|
get rotate() {
|
|
81951
|
-
let rotate = this.
|
|
82120
|
+
let rotate = __privateMethod(this, _Page_instances, getInheritableProperty_fn).call(this, "Rotate") || 0;
|
|
81952
82121
|
if (rotate % 90 !== 0) {
|
|
81953
82122
|
rotate = 0;
|
|
81954
82123
|
} else if (rotate >= 360) {
|
|
@@ -81958,16 +82127,6 @@ var Page = class {
|
|
|
81958
82127
|
}
|
|
81959
82128
|
return shadow(this, "rotate", rotate);
|
|
81960
82129
|
}
|
|
81961
|
-
/**
|
|
81962
|
-
* @private
|
|
81963
|
-
*/
|
|
81964
|
-
_onSubStreamError(reason, objId) {
|
|
81965
|
-
if (this.evaluatorOptions.ignoreErrors) {
|
|
81966
|
-
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
|
|
81967
|
-
return;
|
|
81968
|
-
}
|
|
81969
|
-
throw reason;
|
|
81970
|
-
}
|
|
81971
82130
|
/**
|
|
81972
82131
|
* @returns {Promise<BaseStream>}
|
|
81973
82132
|
*/
|
|
@@ -81979,7 +82138,7 @@ var Page = class {
|
|
|
81979
82138
|
if (Array.isArray(content)) {
|
|
81980
82139
|
return new StreamsSequenceStream(
|
|
81981
82140
|
content,
|
|
81982
|
-
this.
|
|
82141
|
+
__privateMethod(this, _Page_instances, onSubStreamError_fn).bind(this)
|
|
81983
82142
|
);
|
|
81984
82143
|
}
|
|
81985
82144
|
return new NullStream();
|
|
@@ -81995,19 +82154,7 @@ var Page = class {
|
|
|
81995
82154
|
if (this.xfaFactory) {
|
|
81996
82155
|
throw new Error("XFA: Cannot save new annotations.");
|
|
81997
82156
|
}
|
|
81998
|
-
const partialEvaluator =
|
|
81999
|
-
xref: this.xref,
|
|
82000
|
-
handler,
|
|
82001
|
-
pageIndex: this.pageIndex,
|
|
82002
|
-
idFactory: this._localIdFactory,
|
|
82003
|
-
fontCache: this.fontCache,
|
|
82004
|
-
builtInCMapCache: this.builtInCMapCache,
|
|
82005
|
-
standardFontDataCache: this.standardFontDataCache,
|
|
82006
|
-
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82007
|
-
globalImageCache: this.globalImageCache,
|
|
82008
|
-
systemFontCache: this.systemFontCache,
|
|
82009
|
-
options: this.evaluatorOptions
|
|
82010
|
-
});
|
|
82157
|
+
const partialEvaluator = __privateMethod(this, _Page_instances, createPartialEvaluator_fn).call(this, handler);
|
|
82011
82158
|
const deletedAnnotations = new RefSetCache();
|
|
82012
82159
|
const existingAnnotations = new RefSet();
|
|
82013
82160
|
await __privateMethod(this, _Page_instances, replaceIdByRef_fn).call(this, annotations, deletedAnnotations, existingAnnotations);
|
|
@@ -82039,19 +82186,7 @@ var Page = class {
|
|
|
82039
82186
|
}
|
|
82040
82187
|
}
|
|
82041
82188
|
async save(handler, task, annotationStorage, changes) {
|
|
82042
|
-
const partialEvaluator =
|
|
82043
|
-
xref: this.xref,
|
|
82044
|
-
handler,
|
|
82045
|
-
pageIndex: this.pageIndex,
|
|
82046
|
-
idFactory: this._localIdFactory,
|
|
82047
|
-
fontCache: this.fontCache,
|
|
82048
|
-
builtInCMapCache: this.builtInCMapCache,
|
|
82049
|
-
standardFontDataCache: this.standardFontDataCache,
|
|
82050
|
-
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82051
|
-
globalImageCache: this.globalImageCache,
|
|
82052
|
-
systemFontCache: this.systemFontCache,
|
|
82053
|
-
options: this.evaluatorOptions
|
|
82054
|
-
});
|
|
82189
|
+
const partialEvaluator = __privateMethod(this, _Page_instances, createPartialEvaluator_fn).call(this, handler);
|
|
82055
82190
|
const annotations = await this._parsedAnnotations;
|
|
82056
82191
|
const promises = [];
|
|
82057
82192
|
for (const annotation of annotations) {
|
|
@@ -82067,9 +82202,11 @@ var Page = class {
|
|
|
82067
82202
|
return Promise.all(promises);
|
|
82068
82203
|
}
|
|
82069
82204
|
async loadResources(keys) {
|
|
82070
|
-
await (this
|
|
82071
|
-
|
|
82072
|
-
|
|
82205
|
+
await (__privateGet(this, _resourcesPromise) ?? __privateSet(this, _resourcesPromise, this.pdfManager.ensure(
|
|
82206
|
+
this,
|
|
82207
|
+
"resources"
|
|
82208
|
+
)));
|
|
82209
|
+
await ObjectLoader.load(this.resources, keys, this.xref);
|
|
82073
82210
|
}
|
|
82074
82211
|
async getOperatorList({
|
|
82075
82212
|
handler,
|
|
@@ -82081,28 +82218,8 @@ var Page = class {
|
|
|
82081
82218
|
modifiedIds = null
|
|
82082
82219
|
}) {
|
|
82083
82220
|
const contentStreamPromise = this.getContentStream();
|
|
82084
|
-
const resourcesPromise = this.loadResources(
|
|
82085
|
-
|
|
82086
|
-
"ExtGState",
|
|
82087
|
-
"Font",
|
|
82088
|
-
"Pattern",
|
|
82089
|
-
"Properties",
|
|
82090
|
-
"Shading",
|
|
82091
|
-
"XObject"
|
|
82092
|
-
]);
|
|
82093
|
-
const partialEvaluator = new PartialEvaluator({
|
|
82094
|
-
xref: this.xref,
|
|
82095
|
-
handler,
|
|
82096
|
-
pageIndex: this.pageIndex,
|
|
82097
|
-
idFactory: this._localIdFactory,
|
|
82098
|
-
fontCache: this.fontCache,
|
|
82099
|
-
builtInCMapCache: this.builtInCMapCache,
|
|
82100
|
-
standardFontDataCache: this.standardFontDataCache,
|
|
82101
|
-
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82102
|
-
globalImageCache: this.globalImageCache,
|
|
82103
|
-
systemFontCache: this.systemFontCache,
|
|
82104
|
-
options: this.evaluatorOptions
|
|
82105
|
-
});
|
|
82221
|
+
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
|
|
82222
|
+
const partialEvaluator = __privateMethod(this, _Page_instances, createPartialEvaluator_fn).call(this, handler);
|
|
82106
82223
|
const newAnnotsByPage = !this.xfaFactory ? getNewAnnotationsMap(annotationStorage) : null;
|
|
82107
82224
|
const newAnnots = newAnnotsByPage?.get(this.pageIndex);
|
|
82108
82225
|
let newAnnotationsPromise = Promise.resolve(null);
|
|
@@ -82160,10 +82277,11 @@ var Page = class {
|
|
|
82160
82277
|
contentStreamPromise,
|
|
82161
82278
|
resourcesPromise
|
|
82162
82279
|
]).then(async ([contentStream]) => {
|
|
82280
|
+
const resources = await __privateMethod(this, _Page_instances, getMergedResources_fn).call(this, contentStream.dict, RESOURCES_KEYS_OPERATOR_LIST);
|
|
82163
82281
|
const opList = new OperatorList(intent, sink);
|
|
82164
82282
|
handler.send("StartRenderPage", {
|
|
82165
82283
|
transparency: partialEvaluator.hasBlendModes(
|
|
82166
|
-
|
|
82284
|
+
resources,
|
|
82167
82285
|
this.nonBlendModesSet
|
|
82168
82286
|
),
|
|
82169
82287
|
pageIndex: this.pageIndex,
|
|
@@ -82172,7 +82290,7 @@ var Page = class {
|
|
|
82172
82290
|
await partialEvaluator.getOperatorList({
|
|
82173
82291
|
stream: contentStream,
|
|
82174
82292
|
task,
|
|
82175
|
-
resources
|
|
82293
|
+
resources,
|
|
82176
82294
|
operatorList: opList
|
|
82177
82295
|
});
|
|
82178
82296
|
return opList;
|
|
@@ -82249,35 +82367,19 @@ var Page = class {
|
|
|
82249
82367
|
sink
|
|
82250
82368
|
}) {
|
|
82251
82369
|
const contentStreamPromise = this.getContentStream();
|
|
82252
|
-
const resourcesPromise = this.loadResources(
|
|
82253
|
-
"ExtGState",
|
|
82254
|
-
"Font",
|
|
82255
|
-
"Properties",
|
|
82256
|
-
"XObject"
|
|
82257
|
-
]);
|
|
82370
|
+
const resourcesPromise = this.loadResources(RESOURCES_KEYS_TEXT_CONTENT);
|
|
82258
82371
|
const langPromise = this.pdfManager.ensureCatalog("lang");
|
|
82259
82372
|
const [contentStream, , lang] = await Promise.all([
|
|
82260
82373
|
contentStreamPromise,
|
|
82261
82374
|
resourcesPromise,
|
|
82262
82375
|
langPromise
|
|
82263
82376
|
]);
|
|
82264
|
-
const
|
|
82265
|
-
|
|
82266
|
-
handler,
|
|
82267
|
-
pageIndex: this.pageIndex,
|
|
82268
|
-
idFactory: this._localIdFactory,
|
|
82269
|
-
fontCache: this.fontCache,
|
|
82270
|
-
builtInCMapCache: this.builtInCMapCache,
|
|
82271
|
-
standardFontDataCache: this.standardFontDataCache,
|
|
82272
|
-
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82273
|
-
globalImageCache: this.globalImageCache,
|
|
82274
|
-
systemFontCache: this.systemFontCache,
|
|
82275
|
-
options: this.evaluatorOptions
|
|
82276
|
-
});
|
|
82377
|
+
const resources = await __privateMethod(this, _Page_instances, getMergedResources_fn).call(this, contentStream.dict, RESOURCES_KEYS_TEXT_CONTENT);
|
|
82378
|
+
const partialEvaluator = __privateMethod(this, _Page_instances, createPartialEvaluator_fn).call(this, handler);
|
|
82277
82379
|
return partialEvaluator.getTextContent({
|
|
82278
82380
|
stream: contentStream,
|
|
82279
82381
|
task,
|
|
82280
|
-
resources
|
|
82382
|
+
resources,
|
|
82281
82383
|
includeMarkedContent,
|
|
82282
82384
|
disableNormalization,
|
|
82283
82385
|
sink,
|
|
@@ -82291,10 +82393,18 @@ var Page = class {
|
|
|
82291
82393
|
return null;
|
|
82292
82394
|
}
|
|
82293
82395
|
await this._parsedAnnotations;
|
|
82294
|
-
|
|
82295
|
-
|
|
82296
|
-
|
|
82297
|
-
|
|
82396
|
+
try {
|
|
82397
|
+
const structTree = await this.pdfManager.ensure(
|
|
82398
|
+
this,
|
|
82399
|
+
"_parseStructTree",
|
|
82400
|
+
[structTreeRoot]
|
|
82401
|
+
);
|
|
82402
|
+
const data = await this.pdfManager.ensure(structTree, "serializable");
|
|
82403
|
+
return data;
|
|
82404
|
+
} catch (ex) {
|
|
82405
|
+
warn(`getStructTree: "${ex}".`);
|
|
82406
|
+
return null;
|
|
82407
|
+
}
|
|
82298
82408
|
}
|
|
82299
82409
|
/**
|
|
82300
82410
|
* @private
|
|
@@ -82318,19 +82428,7 @@ var Page = class {
|
|
|
82318
82428
|
annotationsData.push(annotation.data);
|
|
82319
82429
|
}
|
|
82320
82430
|
if (annotation.hasTextContent && isVisible) {
|
|
82321
|
-
partialEvaluator
|
|
82322
|
-
xref: this.xref,
|
|
82323
|
-
handler,
|
|
82324
|
-
pageIndex: this.pageIndex,
|
|
82325
|
-
idFactory: this._localIdFactory,
|
|
82326
|
-
fontCache: this.fontCache,
|
|
82327
|
-
builtInCMapCache: this.builtInCMapCache,
|
|
82328
|
-
standardFontDataCache: this.standardFontDataCache,
|
|
82329
|
-
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82330
|
-
globalImageCache: this.globalImageCache,
|
|
82331
|
-
systemFontCache: this.systemFontCache,
|
|
82332
|
-
options: this.evaluatorOptions
|
|
82333
|
-
}));
|
|
82431
|
+
partialEvaluator ?? (partialEvaluator = __privateMethod(this, _Page_instances, createPartialEvaluator_fn).call(this, handler));
|
|
82334
82432
|
textContentPromises.push(
|
|
82335
82433
|
annotation.extractTextContent(partialEvaluator, task, [
|
|
82336
82434
|
-Infinity,
|
|
@@ -82349,7 +82447,7 @@ var Page = class {
|
|
|
82349
82447
|
return annotationsData;
|
|
82350
82448
|
}
|
|
82351
82449
|
get annotations() {
|
|
82352
|
-
const annots = this.
|
|
82450
|
+
const annots = __privateMethod(this, _Page_instances, getInheritableProperty_fn).call(this, "Annots");
|
|
82353
82451
|
return shadow(this, "annotations", Array.isArray(annots) ? annots : []);
|
|
82354
82452
|
}
|
|
82355
82453
|
get _parsedAnnotations() {
|
|
@@ -82418,7 +82516,66 @@ var Page = class {
|
|
|
82418
82516
|
return shadow(this, "jsActions", actions);
|
|
82419
82517
|
}
|
|
82420
82518
|
};
|
|
82519
|
+
_resourcesPromise = new WeakMap();
|
|
82421
82520
|
_Page_instances = new WeakSet();
|
|
82521
|
+
createPartialEvaluator_fn = function(handler) {
|
|
82522
|
+
return new PartialEvaluator({
|
|
82523
|
+
xref: this.xref,
|
|
82524
|
+
handler,
|
|
82525
|
+
pageIndex: this.pageIndex,
|
|
82526
|
+
idFactory: this._localIdFactory,
|
|
82527
|
+
fontCache: this.fontCache,
|
|
82528
|
+
builtInCMapCache: this.builtInCMapCache,
|
|
82529
|
+
standardFontDataCache: this.standardFontDataCache,
|
|
82530
|
+
globalColorSpaceCache: this.globalColorSpaceCache,
|
|
82531
|
+
globalImageCache: this.globalImageCache,
|
|
82532
|
+
systemFontCache: this.systemFontCache,
|
|
82533
|
+
options: this.evaluatorOptions
|
|
82534
|
+
});
|
|
82535
|
+
};
|
|
82536
|
+
getInheritableProperty_fn = function(key, getArray = false) {
|
|
82537
|
+
const value = getInheritableProperty({
|
|
82538
|
+
dict: this.pageDict,
|
|
82539
|
+
key,
|
|
82540
|
+
getArray,
|
|
82541
|
+
stopWhenFound: false
|
|
82542
|
+
});
|
|
82543
|
+
if (!Array.isArray(value)) {
|
|
82544
|
+
return value;
|
|
82545
|
+
}
|
|
82546
|
+
if (value.length === 1 || !(value[0] instanceof Dict)) {
|
|
82547
|
+
return value[0];
|
|
82548
|
+
}
|
|
82549
|
+
return Dict.merge({ xref: this.xref, dictArray: value });
|
|
82550
|
+
};
|
|
82551
|
+
getBoundingBox_fn = function(name) {
|
|
82552
|
+
if (this.xfaData) {
|
|
82553
|
+
return this.xfaData.bbox;
|
|
82554
|
+
}
|
|
82555
|
+
const box = lookupNormalRect(
|
|
82556
|
+
__privateMethod(this, _Page_instances, getInheritableProperty_fn).call(
|
|
82557
|
+
this,
|
|
82558
|
+
name,
|
|
82559
|
+
/* getArray = */
|
|
82560
|
+
true
|
|
82561
|
+
),
|
|
82562
|
+
null
|
|
82563
|
+
);
|
|
82564
|
+
if (box) {
|
|
82565
|
+
if (box[2] - box[0] > 0 && box[3] - box[1] > 0) {
|
|
82566
|
+
return box;
|
|
82567
|
+
}
|
|
82568
|
+
warn(`Empty, or invalid, /${name} entry.`);
|
|
82569
|
+
}
|
|
82570
|
+
return null;
|
|
82571
|
+
};
|
|
82572
|
+
onSubStreamError_fn = function(reason, objId) {
|
|
82573
|
+
if (this.evaluatorOptions.ignoreErrors) {
|
|
82574
|
+
warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
|
|
82575
|
+
return;
|
|
82576
|
+
}
|
|
82577
|
+
throw reason;
|
|
82578
|
+
};
|
|
82422
82579
|
replaceIdByRef_fn = async function(annotations, deletedAnnotations, existingAnnotations) {
|
|
82423
82580
|
const promises = [];
|
|
82424
82581
|
for (const annotation of annotations) {
|
|
@@ -82457,6 +82614,18 @@ replaceIdByRef_fn = async function(annotations, deletedAnnotations, existingAnno
|
|
|
82457
82614
|
}
|
|
82458
82615
|
await Promise.all(promises);
|
|
82459
82616
|
};
|
|
82617
|
+
getMergedResources_fn = async function(streamDict, keys) {
|
|
82618
|
+
const localResources = streamDict?.get("Resources");
|
|
82619
|
+
if (!(localResources instanceof Dict && localResources.size)) {
|
|
82620
|
+
return this.resources;
|
|
82621
|
+
}
|
|
82622
|
+
await ObjectLoader.load(localResources, keys, this.xref);
|
|
82623
|
+
return Dict.merge({
|
|
82624
|
+
xref: this.xref,
|
|
82625
|
+
dictArray: [localResources, this.resources],
|
|
82626
|
+
mergeSubDicts: true
|
|
82627
|
+
});
|
|
82628
|
+
};
|
|
82460
82629
|
var PDF_HEADER_SIGNATURE = new Uint8Array([37, 80, 68, 70, 45]);
|
|
82461
82630
|
var STARTXREF_SIGNATURE = new Uint8Array([
|
|
82462
82631
|
115,
|
|
@@ -82510,10 +82679,12 @@ function find(stream, signature, limit = 1024, backwards = false) {
|
|
|
82510
82679
|
}
|
|
82511
82680
|
return false;
|
|
82512
82681
|
}
|
|
82513
|
-
var _PDFDocument_instances, collectFieldObjects_fn;
|
|
82682
|
+
var _pagePromises, _version, _PDFDocument_instances, hasOnlyDocumentSignatures_fn, loadXfaImages_fn, loadXfaFonts_fn, getLinearizationPage_fn, collectFieldObjects_fn;
|
|
82514
82683
|
var PDFDocument = class {
|
|
82515
82684
|
constructor(pdfManager, stream) {
|
|
82516
82685
|
__privateAdd(this, _PDFDocument_instances);
|
|
82686
|
+
__privateAdd(this, _pagePromises, /* @__PURE__ */ new Map());
|
|
82687
|
+
__privateAdd(this, _version, null);
|
|
82517
82688
|
if (false) {
|
|
82518
82689
|
assert(
|
|
82519
82690
|
stream instanceof BaseStream,
|
|
@@ -82528,8 +82699,6 @@ var PDFDocument = class {
|
|
|
82528
82699
|
this.pdfManager = pdfManager;
|
|
82529
82700
|
this.stream = stream;
|
|
82530
82701
|
this.xref = new XRef(stream, pdfManager);
|
|
82531
|
-
this._pagePromises = /* @__PURE__ */ new Map();
|
|
82532
|
-
this._version = null;
|
|
82533
82702
|
const idCounters = {
|
|
82534
82703
|
font: 0
|
|
82535
82704
|
};
|
|
@@ -82628,7 +82797,7 @@ var PDFDocument = class {
|
|
|
82628
82797
|
version += String.fromCharCode(ch3);
|
|
82629
82798
|
}
|
|
82630
82799
|
if (PDF_VERSION_REGEXP.test(version)) {
|
|
82631
|
-
this
|
|
82800
|
+
__privateSet(this, _version, version);
|
|
82632
82801
|
} else {
|
|
82633
82802
|
warn(`Invalid PDF header version: ${version}`);
|
|
82634
82803
|
}
|
|
@@ -82649,53 +82818,26 @@ var PDFDocument = class {
|
|
|
82649
82818
|
}
|
|
82650
82819
|
return shadow(this, "numPages", num);
|
|
82651
82820
|
}
|
|
82652
|
-
/**
|
|
82653
|
-
* @private
|
|
82654
|
-
*/
|
|
82655
|
-
_hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
|
|
82656
|
-
const RECURSION_LIMIT = 10;
|
|
82657
|
-
if (!Array.isArray(fields)) {
|
|
82658
|
-
return false;
|
|
82659
|
-
}
|
|
82660
|
-
return fields.every((field) => {
|
|
82661
|
-
field = this.xref.fetchIfRef(field);
|
|
82662
|
-
if (!(field instanceof Dict)) {
|
|
82663
|
-
return false;
|
|
82664
|
-
}
|
|
82665
|
-
if (field.has("Kids")) {
|
|
82666
|
-
if (++recursionDepth > RECURSION_LIMIT) {
|
|
82667
|
-
warn("_hasOnlyDocumentSignatures: maximum recursion depth reached");
|
|
82668
|
-
return false;
|
|
82669
|
-
}
|
|
82670
|
-
return this._hasOnlyDocumentSignatures(
|
|
82671
|
-
field.get("Kids"),
|
|
82672
|
-
recursionDepth
|
|
82673
|
-
);
|
|
82674
|
-
}
|
|
82675
|
-
const isSignature = isName(field.get("FT"), "Sig");
|
|
82676
|
-
const rectangle = field.get("Rect");
|
|
82677
|
-
const isInvisible = Array.isArray(rectangle) && rectangle.every((value) => value === 0);
|
|
82678
|
-
return isSignature && isInvisible;
|
|
82679
|
-
});
|
|
82680
|
-
}
|
|
82681
82821
|
get _xfaStreams() {
|
|
82682
|
-
const acroForm = this.catalog
|
|
82822
|
+
const { acroForm } = this.catalog;
|
|
82683
82823
|
if (!acroForm) {
|
|
82684
82824
|
return null;
|
|
82685
82825
|
}
|
|
82686
82826
|
const xfa = acroForm.get("XFA");
|
|
82687
|
-
const entries =
|
|
82688
|
-
|
|
82689
|
-
|
|
82690
|
-
|
|
82691
|
-
|
|
82692
|
-
|
|
82693
|
-
|
|
82694
|
-
|
|
82695
|
-
|
|
82696
|
-
|
|
82827
|
+
const entries = new Map(
|
|
82828
|
+
[
|
|
82829
|
+
"xdp:xdp",
|
|
82830
|
+
"template",
|
|
82831
|
+
"datasets",
|
|
82832
|
+
"config",
|
|
82833
|
+
"connectionSet",
|
|
82834
|
+
"localeSet",
|
|
82835
|
+
"stylesheet",
|
|
82836
|
+
"/xdp:xdp"
|
|
82837
|
+
].map((e) => [e, null])
|
|
82838
|
+
);
|
|
82697
82839
|
if (xfa instanceof BaseStream && !xfa.isEmpty) {
|
|
82698
|
-
entries
|
|
82840
|
+
entries.set("xdp:xdp", xfa);
|
|
82699
82841
|
return entries;
|
|
82700
82842
|
}
|
|
82701
82843
|
if (!Array.isArray(xfa) || xfa.length === 0) {
|
|
@@ -82710,14 +82852,14 @@ var PDFDocument = class {
|
|
|
82710
82852
|
} else {
|
|
82711
82853
|
name = xfa[i];
|
|
82712
82854
|
}
|
|
82713
|
-
if (!entries.
|
|
82855
|
+
if (!entries.has(name)) {
|
|
82714
82856
|
continue;
|
|
82715
82857
|
}
|
|
82716
82858
|
const data = this.xref.fetchIfRef(xfa[i + 1]);
|
|
82717
82859
|
if (!(data instanceof BaseStream) || data.isEmpty) {
|
|
82718
82860
|
continue;
|
|
82719
82861
|
}
|
|
82720
|
-
entries
|
|
82862
|
+
entries.set(name, data);
|
|
82721
82863
|
}
|
|
82722
82864
|
return entries;
|
|
82723
82865
|
}
|
|
@@ -82727,7 +82869,7 @@ var PDFDocument = class {
|
|
|
82727
82869
|
return shadow(this, "xfaDatasets", null);
|
|
82728
82870
|
}
|
|
82729
82871
|
for (const key of ["datasets", "xdp:xdp"]) {
|
|
82730
|
-
const stream = streams
|
|
82872
|
+
const stream = streams.get(key);
|
|
82731
82873
|
if (!stream) {
|
|
82732
82874
|
continue;
|
|
82733
82875
|
}
|
|
@@ -82748,7 +82890,7 @@ var PDFDocument = class {
|
|
|
82748
82890
|
return null;
|
|
82749
82891
|
}
|
|
82750
82892
|
const data = /* @__PURE__ */ Object.create(null);
|
|
82751
|
-
for (const [key, stream] of
|
|
82893
|
+
for (const [key, stream] of streams) {
|
|
82752
82894
|
if (!stream) {
|
|
82753
82895
|
continue;
|
|
82754
82896
|
}
|
|
@@ -82774,156 +82916,14 @@ var PDFDocument = class {
|
|
|
82774
82916
|
get htmlForXfa() {
|
|
82775
82917
|
return this.xfaFactory ? this.xfaFactory.getPages() : null;
|
|
82776
82918
|
}
|
|
82777
|
-
|
|
82778
|
-
|
|
82779
|
-
|
|
82780
|
-
|
|
82781
|
-
|
|
82782
|
-
|
|
82783
|
-
const objectLoader = new ObjectLoader(xfaImagesDict, keys, this.xref);
|
|
82784
|
-
await objectLoader.load();
|
|
82785
|
-
const xfaImages = /* @__PURE__ */ new Map();
|
|
82786
|
-
for (const key of keys) {
|
|
82787
|
-
const stream = xfaImagesDict.get(key);
|
|
82788
|
-
if (stream instanceof BaseStream) {
|
|
82789
|
-
xfaImages.set(key, stream.getBytes());
|
|
82790
|
-
}
|
|
82791
|
-
}
|
|
82792
|
-
this.xfaFactory.setImages(xfaImages);
|
|
82793
|
-
}
|
|
82794
|
-
async loadXfaFonts(handler, task) {
|
|
82795
|
-
const acroForm = await this.pdfManager.ensureCatalog("acroForm");
|
|
82796
|
-
if (!acroForm) {
|
|
82797
|
-
return;
|
|
82798
|
-
}
|
|
82799
|
-
const resources = await acroForm.getAsync("DR");
|
|
82800
|
-
if (!(resources instanceof Dict)) {
|
|
82801
|
-
return;
|
|
82802
|
-
}
|
|
82803
|
-
const objectLoader = new ObjectLoader(resources, ["Font"], this.xref);
|
|
82804
|
-
await objectLoader.load();
|
|
82805
|
-
const fontRes = resources.get("Font");
|
|
82806
|
-
if (!(fontRes instanceof Dict)) {
|
|
82807
|
-
return;
|
|
82808
|
-
}
|
|
82809
|
-
const options = Object.assign(
|
|
82810
|
-
/* @__PURE__ */ Object.create(null),
|
|
82811
|
-
this.pdfManager.evaluatorOptions
|
|
82812
|
-
);
|
|
82813
|
-
options.useSystemFonts = false;
|
|
82814
|
-
const partialEvaluator = new PartialEvaluator({
|
|
82815
|
-
xref: this.xref,
|
|
82816
|
-
handler,
|
|
82817
|
-
pageIndex: -1,
|
|
82818
|
-
idFactory: this._globalIdFactory,
|
|
82819
|
-
fontCache: this.catalog.fontCache,
|
|
82820
|
-
builtInCMapCache: this.catalog.builtInCMapCache,
|
|
82821
|
-
standardFontDataCache: this.catalog.standardFontDataCache,
|
|
82822
|
-
options
|
|
82823
|
-
});
|
|
82824
|
-
const operatorList = new OperatorList();
|
|
82825
|
-
const pdfFonts = [];
|
|
82826
|
-
const initialState = {
|
|
82827
|
-
get font() {
|
|
82828
|
-
return pdfFonts.at(-1);
|
|
82829
|
-
},
|
|
82830
|
-
set font(font) {
|
|
82831
|
-
pdfFonts.push(font);
|
|
82832
|
-
},
|
|
82833
|
-
clone() {
|
|
82834
|
-
return this;
|
|
82835
|
-
}
|
|
82836
|
-
};
|
|
82837
|
-
const promises = [];
|
|
82838
|
-
for (const [fontName, font] of fontRes) {
|
|
82839
|
-
const descriptor = font.get("FontDescriptor");
|
|
82840
|
-
if (!(descriptor instanceof Dict)) {
|
|
82841
|
-
continue;
|
|
82842
|
-
}
|
|
82843
|
-
let fontFamily = descriptor.get("FontFamily");
|
|
82844
|
-
fontFamily = fontFamily.replaceAll(/[ ]+(\d)/g, "$1");
|
|
82845
|
-
const fontWeight = descriptor.get("FontWeight");
|
|
82846
|
-
const italicAngle = -descriptor.get("ItalicAngle");
|
|
82847
|
-
const cssFontInfo = { fontFamily, fontWeight, italicAngle };
|
|
82848
|
-
if (!validateCSSFont(cssFontInfo)) {
|
|
82849
|
-
continue;
|
|
82850
|
-
}
|
|
82851
|
-
promises.push(
|
|
82852
|
-
partialEvaluator.handleSetFont(
|
|
82853
|
-
resources,
|
|
82854
|
-
[Name.get(fontName), 1],
|
|
82855
|
-
/* fontRef = */
|
|
82856
|
-
null,
|
|
82857
|
-
operatorList,
|
|
82858
|
-
task,
|
|
82859
|
-
initialState,
|
|
82860
|
-
/* fallbackFontDict = */
|
|
82861
|
-
null,
|
|
82862
|
-
/* cssFontInfo = */
|
|
82863
|
-
cssFontInfo
|
|
82864
|
-
).catch(function(reason) {
|
|
82865
|
-
warn(`loadXfaFonts: "${reason}".`);
|
|
82866
|
-
return null;
|
|
82867
|
-
})
|
|
82868
|
-
);
|
|
82869
|
-
}
|
|
82870
|
-
await Promise.all(promises);
|
|
82871
|
-
const missingFonts = this.xfaFactory.setFonts(pdfFonts);
|
|
82872
|
-
if (!missingFonts) {
|
|
82873
|
-
return;
|
|
82874
|
-
}
|
|
82875
|
-
options.ignoreErrors = true;
|
|
82876
|
-
promises.length = 0;
|
|
82877
|
-
pdfFonts.length = 0;
|
|
82878
|
-
const reallyMissingFonts = /* @__PURE__ */ new Set();
|
|
82879
|
-
for (const missing of missingFonts) {
|
|
82880
|
-
if (!getXfaFontName(`${missing}-Regular`)) {
|
|
82881
|
-
reallyMissingFonts.add(missing);
|
|
82882
|
-
}
|
|
82883
|
-
}
|
|
82884
|
-
if (reallyMissingFonts.size) {
|
|
82885
|
-
missingFonts.push("PdfJS-Fallback");
|
|
82886
|
-
}
|
|
82887
|
-
for (const missing of missingFonts) {
|
|
82888
|
-
if (reallyMissingFonts.has(missing)) {
|
|
82889
|
-
continue;
|
|
82890
|
-
}
|
|
82891
|
-
for (const fontInfo of [
|
|
82892
|
-
{ name: "Regular", fontWeight: 400, italicAngle: 0 },
|
|
82893
|
-
{ name: "Bold", fontWeight: 700, italicAngle: 0 },
|
|
82894
|
-
{ name: "Italic", fontWeight: 400, italicAngle: 12 },
|
|
82895
|
-
{ name: "BoldItalic", fontWeight: 700, italicAngle: 12 }
|
|
82896
|
-
]) {
|
|
82897
|
-
const name = `${missing}-${fontInfo.name}`;
|
|
82898
|
-
const dict = getXfaFontDict(name);
|
|
82899
|
-
promises.push(
|
|
82900
|
-
partialEvaluator.handleSetFont(
|
|
82901
|
-
resources,
|
|
82902
|
-
[Name.get(name), 1],
|
|
82903
|
-
/* fontRef = */
|
|
82904
|
-
null,
|
|
82905
|
-
operatorList,
|
|
82906
|
-
task,
|
|
82907
|
-
initialState,
|
|
82908
|
-
/* fallbackFontDict = */
|
|
82909
|
-
dict,
|
|
82910
|
-
/* cssFontInfo = */
|
|
82911
|
-
{
|
|
82912
|
-
fontFamily: missing,
|
|
82913
|
-
fontWeight: fontInfo.fontWeight,
|
|
82914
|
-
italicAngle: fontInfo.italicAngle
|
|
82915
|
-
}
|
|
82916
|
-
).catch(function(reason) {
|
|
82917
|
-
warn(`loadXfaFonts: "${reason}".`);
|
|
82918
|
-
return null;
|
|
82919
|
-
})
|
|
82920
|
-
);
|
|
82921
|
-
}
|
|
82922
|
-
}
|
|
82923
|
-
await Promise.all(promises);
|
|
82924
|
-
this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts);
|
|
82919
|
+
loadXfaResources(handler, task) {
|
|
82920
|
+
return Promise.all([
|
|
82921
|
+
__privateMethod(this, _PDFDocument_instances, loadXfaFonts_fn).call(this, handler, task).catch(() => {
|
|
82922
|
+
}),
|
|
82923
|
+
__privateMethod(this, _PDFDocument_instances, loadXfaImages_fn).call(this)
|
|
82924
|
+
]);
|
|
82925
82925
|
}
|
|
82926
|
-
|
|
82926
|
+
serializeXfaData(annotationStorage) {
|
|
82927
82927
|
return this.xfaFactory ? this.xfaFactory.serializeData(annotationStorage) : null;
|
|
82928
82928
|
}
|
|
82929
82929
|
/**
|
|
@@ -82931,7 +82931,7 @@ var PDFDocument = class {
|
|
|
82931
82931
|
* the catalog, if present, should overwrite the version from the header.
|
|
82932
82932
|
*/
|
|
82933
82933
|
get version() {
|
|
82934
|
-
return this.catalog.version || this
|
|
82934
|
+
return this.catalog.version || __privateGet(this, _version);
|
|
82935
82935
|
}
|
|
82936
82936
|
get formInfo() {
|
|
82937
82937
|
const formInfo = {
|
|
@@ -82940,7 +82940,7 @@ var PDFDocument = class {
|
|
|
82940
82940
|
hasXfa: false,
|
|
82941
82941
|
hasSignatures: false
|
|
82942
82942
|
};
|
|
82943
|
-
const acroForm = this.catalog
|
|
82943
|
+
const { acroForm } = this.catalog;
|
|
82944
82944
|
if (!acroForm) {
|
|
82945
82945
|
return shadow(this, "formInfo", formInfo);
|
|
82946
82946
|
}
|
|
@@ -82952,7 +82952,7 @@ var PDFDocument = class {
|
|
|
82952
82952
|
formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof BaseStream && !xfa.isEmpty;
|
|
82953
82953
|
const sigFlags = acroForm.get("SigFlags");
|
|
82954
82954
|
const hasSignatures = !!(sigFlags & 1);
|
|
82955
|
-
const hasOnlyDocumentSignatures = hasSignatures && this.
|
|
82955
|
+
const hasOnlyDocumentSignatures = hasSignatures && __privateMethod(this, _PDFDocument_instances, hasOnlyDocumentSignatures_fn).call(this, fields);
|
|
82956
82956
|
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
|
|
82957
82957
|
formInfo.hasSignatures = hasSignatures;
|
|
82958
82958
|
} catch (ex) {
|
|
@@ -82964,19 +82964,20 @@ var PDFDocument = class {
|
|
|
82964
82964
|
return shadow(this, "formInfo", formInfo);
|
|
82965
82965
|
}
|
|
82966
82966
|
get documentInfo() {
|
|
82967
|
+
const { catalog, formInfo, xref } = this;
|
|
82967
82968
|
const docInfo = {
|
|
82968
82969
|
PDFFormatVersion: this.version,
|
|
82969
|
-
Language:
|
|
82970
|
-
EncryptFilterName:
|
|
82970
|
+
Language: catalog.lang,
|
|
82971
|
+
EncryptFilterName: xref.encrypt?.filterName ?? null,
|
|
82971
82972
|
IsLinearized: !!this.linearization,
|
|
82972
|
-
IsAcroFormPresent:
|
|
82973
|
-
IsXFAPresent:
|
|
82974
|
-
IsCollectionPresent: !!
|
|
82975
|
-
IsSignaturesPresent:
|
|
82973
|
+
IsAcroFormPresent: formInfo.hasAcroForm,
|
|
82974
|
+
IsXFAPresent: formInfo.hasXfa,
|
|
82975
|
+
IsCollectionPresent: !!catalog.collection,
|
|
82976
|
+
IsSignaturesPresent: formInfo.hasSignatures
|
|
82976
82977
|
};
|
|
82977
82978
|
let infoDict;
|
|
82978
82979
|
try {
|
|
82979
|
-
infoDict =
|
|
82980
|
+
infoDict = xref.trailer.get("Info");
|
|
82980
82981
|
} catch (err) {
|
|
82981
82982
|
if (err instanceof MissingDataException) {
|
|
82982
82983
|
throw err;
|
|
@@ -83027,9 +83028,7 @@ var PDFDocument = class {
|
|
|
83027
83028
|
warn(`Bad value, for custom key "${key}", in Info: ${value}.`);
|
|
83028
83029
|
continue;
|
|
83029
83030
|
}
|
|
83030
|
-
|
|
83031
|
-
docInfo.Custom = /* @__PURE__ */ Object.create(null);
|
|
83032
|
-
}
|
|
83031
|
+
docInfo.Custom ?? (docInfo.Custom = /* @__PURE__ */ Object.create(null));
|
|
83033
83032
|
docInfo.Custom[key] = customValue;
|
|
83034
83033
|
continue;
|
|
83035
83034
|
}
|
|
@@ -83062,42 +83061,8 @@ var PDFDocument = class {
|
|
|
83062
83061
|
hashModified ? toHexUtil(hashModified) : null
|
|
83063
83062
|
]);
|
|
83064
83063
|
}
|
|
83065
|
-
async _getLinearizationPage(pageIndex) {
|
|
83066
|
-
const { catalog, linearization, xref } = this;
|
|
83067
|
-
if (false) {
|
|
83068
|
-
assert(
|
|
83069
|
-
linearization?.pageFirst === pageIndex,
|
|
83070
|
-
"_getLinearizationPage - invalid pageIndex argument."
|
|
83071
|
-
);
|
|
83072
|
-
}
|
|
83073
|
-
const ref = Ref.get(linearization.objectNumberFirst, 0);
|
|
83074
|
-
try {
|
|
83075
|
-
const obj = await xref.fetchAsync(ref);
|
|
83076
|
-
if (obj instanceof Dict) {
|
|
83077
|
-
let type = obj.getRaw("Type");
|
|
83078
|
-
if (type instanceof Ref) {
|
|
83079
|
-
type = await xref.fetchAsync(type);
|
|
83080
|
-
}
|
|
83081
|
-
if (isName(type, "Page") || !obj.has("Type") && !obj.has("Kids") && obj.has("Contents")) {
|
|
83082
|
-
if (!catalog.pageKidsCountCache.has(ref)) {
|
|
83083
|
-
catalog.pageKidsCountCache.put(ref, 1);
|
|
83084
|
-
}
|
|
83085
|
-
if (!catalog.pageIndexCache.has(ref)) {
|
|
83086
|
-
catalog.pageIndexCache.put(ref, 0);
|
|
83087
|
-
}
|
|
83088
|
-
return [obj, ref];
|
|
83089
|
-
}
|
|
83090
|
-
}
|
|
83091
|
-
throw new FormatError(
|
|
83092
|
-
"The Linearization dictionary doesn't point to a valid Page dictionary."
|
|
83093
|
-
);
|
|
83094
|
-
} catch (reason) {
|
|
83095
|
-
warn(`_getLinearizationPage: "${reason.message}".`);
|
|
83096
|
-
return catalog.getPageDict(pageIndex);
|
|
83097
|
-
}
|
|
83098
|
-
}
|
|
83099
83064
|
getPage(pageIndex) {
|
|
83100
|
-
const cachedPromise = this
|
|
83065
|
+
const cachedPromise = __privateGet(this, _pagePromises).get(pageIndex);
|
|
83101
83066
|
if (cachedPromise) {
|
|
83102
83067
|
return cachedPromise;
|
|
83103
83068
|
}
|
|
@@ -83106,7 +83071,7 @@ var PDFDocument = class {
|
|
|
83106
83071
|
if (xfaFactory) {
|
|
83107
83072
|
promise = Promise.resolve([Dict.empty, null]);
|
|
83108
83073
|
} else if (linearization?.pageFirst === pageIndex) {
|
|
83109
|
-
promise = this.
|
|
83074
|
+
promise = __privateMethod(this, _PDFDocument_instances, getLinearizationPage_fn).call(this, pageIndex);
|
|
83110
83075
|
} else {
|
|
83111
83076
|
promise = catalog.getPageDict(pageIndex);
|
|
83112
83077
|
}
|
|
@@ -83128,7 +83093,7 @@ var PDFDocument = class {
|
|
|
83128
83093
|
xfaFactory
|
|
83129
83094
|
})
|
|
83130
83095
|
);
|
|
83131
|
-
this
|
|
83096
|
+
__privateGet(this, _pagePromises).set(pageIndex, promise);
|
|
83132
83097
|
return promise;
|
|
83133
83098
|
}
|
|
83134
83099
|
async checkFirstPage(recoveryMode = false) {
|
|
@@ -83139,7 +83104,7 @@ var PDFDocument = class {
|
|
|
83139
83104
|
await this.getPage(0);
|
|
83140
83105
|
} catch (reason) {
|
|
83141
83106
|
if (reason instanceof XRefEntryException) {
|
|
83142
|
-
this
|
|
83107
|
+
__privateGet(this, _pagePromises).delete(0);
|
|
83143
83108
|
await this.cleanup();
|
|
83144
83109
|
throw new XRefParseException();
|
|
83145
83110
|
}
|
|
@@ -83169,7 +83134,7 @@ var PDFDocument = class {
|
|
|
83169
83134
|
}
|
|
83170
83135
|
await this.getPage(numPages - 1);
|
|
83171
83136
|
} catch (reason) {
|
|
83172
|
-
this
|
|
83137
|
+
__privateGet(this, _pagePromises).delete(numPages - 1);
|
|
83173
83138
|
await this.cleanup();
|
|
83174
83139
|
if (reason instanceof XRefEntryException && !recoveryMode) {
|
|
83175
83140
|
throw new XRefParseException();
|
|
@@ -83211,7 +83176,7 @@ var PDFDocument = class {
|
|
|
83211
83176
|
})
|
|
83212
83177
|
);
|
|
83213
83178
|
}
|
|
83214
|
-
this
|
|
83179
|
+
__privateGet(this, _pagePromises).set(pageIndex, promise);
|
|
83215
83180
|
}
|
|
83216
83181
|
catalog.setActualNumPages(pagesTree.size);
|
|
83217
83182
|
}
|
|
@@ -83233,18 +83198,16 @@ var PDFDocument = class {
|
|
|
83233
83198
|
if (!formInfo.hasFields) {
|
|
83234
83199
|
return null;
|
|
83235
83200
|
}
|
|
83236
|
-
const
|
|
83237
|
-
this.pdfManager.ensureDoc("annotationGlobals"),
|
|
83238
|
-
this.pdfManager.ensureCatalog("acroForm")
|
|
83239
|
-
]);
|
|
83201
|
+
const annotationGlobals = await this.annotationGlobals;
|
|
83240
83202
|
if (!annotationGlobals) {
|
|
83241
83203
|
return null;
|
|
83242
83204
|
}
|
|
83205
|
+
const { acroForm } = annotationGlobals;
|
|
83243
83206
|
const visitedRefs = new RefSet();
|
|
83244
83207
|
const allFields = /* @__PURE__ */ Object.create(null);
|
|
83245
83208
|
const fieldPromises = /* @__PURE__ */ new Map();
|
|
83246
83209
|
const orphanFields = new RefSetCache();
|
|
83247
|
-
for (const fieldRef of
|
|
83210
|
+
for (const fieldRef of acroForm.get("Fields")) {
|
|
83248
83211
|
await __privateMethod(this, _PDFDocument_instances, collectFieldObjects_fn).call(this, "", null, fieldRef, fieldPromises, annotationGlobals, visitedRefs, orphanFields);
|
|
83249
83212
|
}
|
|
83250
83213
|
const allPromises = [];
|
|
@@ -83309,7 +83272,193 @@ var PDFDocument = class {
|
|
|
83309
83272
|
);
|
|
83310
83273
|
}
|
|
83311
83274
|
};
|
|
83275
|
+
_pagePromises = new WeakMap();
|
|
83276
|
+
_version = new WeakMap();
|
|
83312
83277
|
_PDFDocument_instances = new WeakSet();
|
|
83278
|
+
hasOnlyDocumentSignatures_fn = function(fields, recursionDepth = 0) {
|
|
83279
|
+
const RECURSION_LIMIT = 10;
|
|
83280
|
+
if (!Array.isArray(fields)) {
|
|
83281
|
+
return false;
|
|
83282
|
+
}
|
|
83283
|
+
return fields.every((field) => {
|
|
83284
|
+
field = this.xref.fetchIfRef(field);
|
|
83285
|
+
if (!(field instanceof Dict)) {
|
|
83286
|
+
return false;
|
|
83287
|
+
}
|
|
83288
|
+
if (field.has("Kids")) {
|
|
83289
|
+
if (++recursionDepth > RECURSION_LIMIT) {
|
|
83290
|
+
warn("#hasOnlyDocumentSignatures: maximum recursion depth reached");
|
|
83291
|
+
return false;
|
|
83292
|
+
}
|
|
83293
|
+
return __privateMethod(this, _PDFDocument_instances, hasOnlyDocumentSignatures_fn).call(this, field.get("Kids"), recursionDepth);
|
|
83294
|
+
}
|
|
83295
|
+
const isSignature = isName(field.get("FT"), "Sig");
|
|
83296
|
+
const rectangle = field.get("Rect");
|
|
83297
|
+
const isInvisible = Array.isArray(rectangle) && rectangle.every((value) => value === 0);
|
|
83298
|
+
return isSignature && isInvisible;
|
|
83299
|
+
});
|
|
83300
|
+
};
|
|
83301
|
+
loadXfaImages_fn = async function() {
|
|
83302
|
+
const xfaImages = await this.pdfManager.ensureCatalog("xfaImages");
|
|
83303
|
+
if (!xfaImages) {
|
|
83304
|
+
return;
|
|
83305
|
+
}
|
|
83306
|
+
this.xfaFactory.setImages(xfaImages);
|
|
83307
|
+
};
|
|
83308
|
+
loadXfaFonts_fn = async function(handler, task) {
|
|
83309
|
+
const acroForm = await this.pdfManager.ensureCatalog("acroForm");
|
|
83310
|
+
if (!acroForm) {
|
|
83311
|
+
return;
|
|
83312
|
+
}
|
|
83313
|
+
const resources = await acroForm.getAsync("DR");
|
|
83314
|
+
if (!(resources instanceof Dict)) {
|
|
83315
|
+
return;
|
|
83316
|
+
}
|
|
83317
|
+
await ObjectLoader.load(resources, ["Font"], this.xref);
|
|
83318
|
+
const fontRes = resources.get("Font");
|
|
83319
|
+
if (!(fontRes instanceof Dict)) {
|
|
83320
|
+
return;
|
|
83321
|
+
}
|
|
83322
|
+
const options = Object.assign(
|
|
83323
|
+
/* @__PURE__ */ Object.create(null),
|
|
83324
|
+
this.pdfManager.evaluatorOptions,
|
|
83325
|
+
{ useSystemFonts: false }
|
|
83326
|
+
);
|
|
83327
|
+
const { builtInCMapCache, fontCache, standardFontDataCache } = this.catalog;
|
|
83328
|
+
const partialEvaluator = new PartialEvaluator({
|
|
83329
|
+
xref: this.xref,
|
|
83330
|
+
handler,
|
|
83331
|
+
pageIndex: -1,
|
|
83332
|
+
idFactory: this._globalIdFactory,
|
|
83333
|
+
fontCache,
|
|
83334
|
+
builtInCMapCache,
|
|
83335
|
+
standardFontDataCache,
|
|
83336
|
+
options
|
|
83337
|
+
});
|
|
83338
|
+
const operatorList = new OperatorList();
|
|
83339
|
+
const pdfFonts = [];
|
|
83340
|
+
const initialState = {
|
|
83341
|
+
get font() {
|
|
83342
|
+
return pdfFonts.at(-1);
|
|
83343
|
+
},
|
|
83344
|
+
set font(font) {
|
|
83345
|
+
pdfFonts.push(font);
|
|
83346
|
+
},
|
|
83347
|
+
clone() {
|
|
83348
|
+
return this;
|
|
83349
|
+
}
|
|
83350
|
+
};
|
|
83351
|
+
const parseFont = (fontName, fallbackFontDict, cssFontInfo) => partialEvaluator.handleSetFont(
|
|
83352
|
+
resources,
|
|
83353
|
+
[Name.get(fontName), 1],
|
|
83354
|
+
/* fontRef = */
|
|
83355
|
+
null,
|
|
83356
|
+
operatorList,
|
|
83357
|
+
task,
|
|
83358
|
+
initialState,
|
|
83359
|
+
fallbackFontDict,
|
|
83360
|
+
cssFontInfo
|
|
83361
|
+
).catch((reason) => {
|
|
83362
|
+
warn(`loadXfaFonts: "${reason}".`);
|
|
83363
|
+
return null;
|
|
83364
|
+
});
|
|
83365
|
+
const promises = [];
|
|
83366
|
+
for (const [fontName, font] of fontRes) {
|
|
83367
|
+
const descriptor = font.get("FontDescriptor");
|
|
83368
|
+
if (!(descriptor instanceof Dict)) {
|
|
83369
|
+
continue;
|
|
83370
|
+
}
|
|
83371
|
+
let fontFamily = descriptor.get("FontFamily");
|
|
83372
|
+
fontFamily = fontFamily.replaceAll(/[ ]+(\d)/g, "$1");
|
|
83373
|
+
const fontWeight = descriptor.get("FontWeight");
|
|
83374
|
+
const italicAngle = -descriptor.get("ItalicAngle");
|
|
83375
|
+
const cssFontInfo = { fontFamily, fontWeight, italicAngle };
|
|
83376
|
+
if (!validateCSSFont(cssFontInfo)) {
|
|
83377
|
+
continue;
|
|
83378
|
+
}
|
|
83379
|
+
promises.push(
|
|
83380
|
+
parseFont(
|
|
83381
|
+
fontName,
|
|
83382
|
+
/* fallbackFontDict = */
|
|
83383
|
+
null,
|
|
83384
|
+
cssFontInfo
|
|
83385
|
+
)
|
|
83386
|
+
);
|
|
83387
|
+
}
|
|
83388
|
+
await Promise.all(promises);
|
|
83389
|
+
const missingFonts = this.xfaFactory.setFonts(pdfFonts);
|
|
83390
|
+
if (!missingFonts) {
|
|
83391
|
+
return;
|
|
83392
|
+
}
|
|
83393
|
+
options.ignoreErrors = true;
|
|
83394
|
+
promises.length = 0;
|
|
83395
|
+
pdfFonts.length = 0;
|
|
83396
|
+
const reallyMissingFonts = /* @__PURE__ */ new Set();
|
|
83397
|
+
for (const missing of missingFonts) {
|
|
83398
|
+
if (!getXfaFontName(`${missing}-Regular`)) {
|
|
83399
|
+
reallyMissingFonts.add(missing);
|
|
83400
|
+
}
|
|
83401
|
+
}
|
|
83402
|
+
if (reallyMissingFonts.size) {
|
|
83403
|
+
missingFonts.push("PdfJS-Fallback");
|
|
83404
|
+
}
|
|
83405
|
+
for (const missing of missingFonts) {
|
|
83406
|
+
if (reallyMissingFonts.has(missing)) {
|
|
83407
|
+
continue;
|
|
83408
|
+
}
|
|
83409
|
+
for (const fontInfo of [
|
|
83410
|
+
{ name: "Regular", fontWeight: 400, italicAngle: 0 },
|
|
83411
|
+
{ name: "Bold", fontWeight: 700, italicAngle: 0 },
|
|
83412
|
+
{ name: "Italic", fontWeight: 400, italicAngle: 12 },
|
|
83413
|
+
{ name: "BoldItalic", fontWeight: 700, italicAngle: 12 }
|
|
83414
|
+
]) {
|
|
83415
|
+
const name = `${missing}-${fontInfo.name}`;
|
|
83416
|
+
promises.push(
|
|
83417
|
+
parseFont(name, getXfaFontDict(name), {
|
|
83418
|
+
fontFamily: missing,
|
|
83419
|
+
fontWeight: fontInfo.fontWeight,
|
|
83420
|
+
italicAngle: fontInfo.italicAngle
|
|
83421
|
+
})
|
|
83422
|
+
);
|
|
83423
|
+
}
|
|
83424
|
+
}
|
|
83425
|
+
await Promise.all(promises);
|
|
83426
|
+
this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts);
|
|
83427
|
+
};
|
|
83428
|
+
getLinearizationPage_fn = async function(pageIndex) {
|
|
83429
|
+
const { catalog, linearization, xref } = this;
|
|
83430
|
+
if (false) {
|
|
83431
|
+
assert(
|
|
83432
|
+
linearization?.pageFirst === pageIndex,
|
|
83433
|
+
"_getLinearizationPage - invalid pageIndex argument."
|
|
83434
|
+
);
|
|
83435
|
+
}
|
|
83436
|
+
const ref = Ref.get(linearization.objectNumberFirst, 0);
|
|
83437
|
+
try {
|
|
83438
|
+
const obj = await xref.fetchAsync(ref);
|
|
83439
|
+
if (obj instanceof Dict) {
|
|
83440
|
+
let type = obj.getRaw("Type");
|
|
83441
|
+
if (type instanceof Ref) {
|
|
83442
|
+
type = await xref.fetchAsync(type);
|
|
83443
|
+
}
|
|
83444
|
+
if (isName(type, "Page") || !obj.has("Type") && !obj.has("Kids") && obj.has("Contents")) {
|
|
83445
|
+
if (!catalog.pageKidsCountCache.has(ref)) {
|
|
83446
|
+
catalog.pageKidsCountCache.put(ref, 1);
|
|
83447
|
+
}
|
|
83448
|
+
if (!catalog.pageIndexCache.has(ref)) {
|
|
83449
|
+
catalog.pageIndexCache.put(ref, 0);
|
|
83450
|
+
}
|
|
83451
|
+
return [obj, ref];
|
|
83452
|
+
}
|
|
83453
|
+
}
|
|
83454
|
+
throw new FormatError(
|
|
83455
|
+
"The Linearization dictionary doesn't point to a valid Page dictionary."
|
|
83456
|
+
);
|
|
83457
|
+
} catch (reason) {
|
|
83458
|
+
warn(`_getLinearizationPage: "${reason.message}".`);
|
|
83459
|
+
return catalog.getPageDict(pageIndex);
|
|
83460
|
+
}
|
|
83461
|
+
};
|
|
83313
83462
|
collectFieldObjects_fn = async function(name, parentRef, fieldRef, promises, annotationGlobals, visitedRefs, orphanFields) {
|
|
83314
83463
|
const { xref } = this;
|
|
83315
83464
|
if (!(fieldRef instanceof Ref) || visitedRefs.has(fieldRef)) {
|
|
@@ -83434,9 +83583,6 @@ var BasePdfManager = class {
|
|
|
83434
83583
|
get docBaseUrl() {
|
|
83435
83584
|
return this._docBaseUrl;
|
|
83436
83585
|
}
|
|
83437
|
-
get catalog() {
|
|
83438
|
-
return this.pdfDocument.catalog;
|
|
83439
|
-
}
|
|
83440
83586
|
ensureDoc(prop, args) {
|
|
83441
83587
|
return this.ensure(this.pdfDocument, prop, args);
|
|
83442
83588
|
}
|
|
@@ -83452,15 +83598,6 @@ var BasePdfManager = class {
|
|
|
83452
83598
|
fontFallback(id, handler) {
|
|
83453
83599
|
return this.pdfDocument.fontFallback(id, handler);
|
|
83454
83600
|
}
|
|
83455
|
-
loadXfaFonts(handler, task) {
|
|
83456
|
-
return this.pdfDocument.loadXfaFonts(handler, task);
|
|
83457
|
-
}
|
|
83458
|
-
loadXfaImages() {
|
|
83459
|
-
return this.pdfDocument.loadXfaImages();
|
|
83460
|
-
}
|
|
83461
|
-
serializeXfaData(annotationStorage) {
|
|
83462
|
-
return this.pdfDocument.serializeXfaData(annotationStorage);
|
|
83463
|
-
}
|
|
83464
83601
|
cleanup(manuallyTriggered = false) {
|
|
83465
83602
|
return this.pdfDocument.cleanup(manuallyTriggered);
|
|
83466
83603
|
}
|
|
@@ -84076,14 +84213,12 @@ var _WorkerMessageHandler = class _WorkerMessageHandler {
|
|
|
84076
84213
|
);
|
|
84077
84214
|
}
|
|
84078
84215
|
if (true) {
|
|
84079
|
-
const
|
|
84080
|
-
for (const
|
|
84081
|
-
|
|
84216
|
+
const buildMsg = (type, prop) => `The \`${type}.prototype\` contains unexpected enumerable property "${prop}", thus breaking e.g. \`for...in\` iteration of ${type}s.`;
|
|
84217
|
+
for (const prop in {}) {
|
|
84218
|
+
throw new Error(buildMsg("Object", prop));
|
|
84082
84219
|
}
|
|
84083
|
-
|
|
84084
|
-
throw new Error(
|
|
84085
|
-
"The `Array.prototype` contains unexpected enumerable properties: " + enumerableProperties.join(", ") + "; thus breaking e.g. `for...in` iteration of `Array`s."
|
|
84086
|
-
);
|
|
84220
|
+
for (const prop in []) {
|
|
84221
|
+
throw new Error(buildMsg("Array", prop));
|
|
84087
84222
|
}
|
|
84088
84223
|
}
|
|
84089
84224
|
const workerHandlerName = docId + "_worker";
|
|
@@ -84108,13 +84243,10 @@ var _WorkerMessageHandler = class _WorkerMessageHandler {
|
|
|
84108
84243
|
await pdfManager.ensureDoc("checkLastPage", [recoveryMode]);
|
|
84109
84244
|
const isPureXfa = await pdfManager.ensureDoc("isPureXfa");
|
|
84110
84245
|
if (isPureXfa) {
|
|
84111
|
-
const task = new WorkerTask("
|
|
84246
|
+
const task = new WorkerTask("loadXfaResources");
|
|
84112
84247
|
startWorkerTask(task);
|
|
84113
|
-
await
|
|
84114
|
-
|
|
84115
|
-
}).then(() => finishWorkerTask(task)),
|
|
84116
|
-
pdfManager.loadXfaImages()
|
|
84117
|
-
]);
|
|
84248
|
+
await pdfManager.ensureDoc("loadXfaResources", [handler, task]);
|
|
84249
|
+
finishWorkerTask(task);
|
|
84118
84250
|
}
|
|
84119
84251
|
const [numPages, fingerprints] = await Promise.all([
|
|
84120
84252
|
pdfManager.ensureDoc("numPages"),
|
|
@@ -84461,7 +84593,9 @@ var _WorkerMessageHandler = class _WorkerMessageHandler {
|
|
|
84461
84593
|
}
|
|
84462
84594
|
}
|
|
84463
84595
|
if (isPureXfa) {
|
|
84464
|
-
promises.push(
|
|
84596
|
+
promises.push(
|
|
84597
|
+
pdfManager.ensureDoc("serializeXfaData", [annotationStorage])
|
|
84598
|
+
);
|
|
84465
84599
|
} else {
|
|
84466
84600
|
for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
|
|
84467
84601
|
promises.push(
|
|
@@ -84675,6 +84809,11 @@ var _WorkerMessageHandler = class _WorkerMessageHandler {
|
|
|
84675
84809
|
}
|
|
84676
84810
|
})();
|
|
84677
84811
|
var WorkerMessageHandler = _WorkerMessageHandler;
|
|
84812
|
+
|
|
84813
|
+
// src/pdf.js/src/pdf.worker.js
|
|
84814
|
+
globalThis.pdfjsWorker = {
|
|
84815
|
+
WorkerMessageHandler
|
|
84816
|
+
};
|
|
84678
84817
|
export {
|
|
84679
84818
|
WorkerMessageHandler
|
|
84680
84819
|
};
|