@ntlab/ntjs-assets 2.0.55 → 2.0.56
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/assets/js/pdfjs/build/pdf.mjs +12449 -12312
- package/assets/js/pdfjs/build/pdf.mjs.map +1 -1
- package/assets/js/pdfjs/build/pdf.sandbox.mjs +3 -3
- package/assets/js/pdfjs/build/pdf.sandbox.mjs.map +1 -1
- package/assets/js/pdfjs/build/pdf.worker.mjs +447 -209
- package/assets/js/pdfjs/build/pdf.worker.mjs.map +1 -1
- package/assets/js/pdfjs/web/locale/br/viewer.ftl +28 -0
- package/assets/js/pdfjs/web/locale/en-US/viewer.ftl +13 -3
- package/assets/js/pdfjs/web/locale/es-ES/viewer.ftl +49 -0
- package/assets/js/pdfjs/web/locale/es-MX/viewer.ftl +74 -0
- package/assets/js/pdfjs/web/locale/eu/viewer.ftl +64 -0
- package/assets/js/pdfjs/web/locale/tg/viewer.ftl +3 -0
- package/assets/js/pdfjs/web/locale/th/viewer.ftl +14 -0
- package/assets/js/pdfjs/web/viewer.css +3 -2
- package/assets/js/pdfjs/web/viewer.mjs +125 -187
- package/assets/js/pdfjs/web/viewer.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -229,10 +229,6 @@ const VerbosityLevel = {
|
|
|
229
229
|
WARNINGS: 1,
|
|
230
230
|
INFOS: 5
|
|
231
231
|
};
|
|
232
|
-
const CMapCompressionType = {
|
|
233
|
-
NONE: 0,
|
|
234
|
-
BINARY: 1
|
|
235
|
-
};
|
|
236
232
|
const OPS = {
|
|
237
233
|
dependency: 1,
|
|
238
234
|
setLineWidth: 2,
|
|
@@ -788,6 +784,24 @@ const FontRenderOps = {
|
|
|
788
784
|
TRANSFORM: 7,
|
|
789
785
|
TRANSLATE: 8
|
|
790
786
|
};
|
|
787
|
+
function toHexUtil(arr) {
|
|
788
|
+
if (Uint8Array.prototype.toHex) {
|
|
789
|
+
return arr.toHex();
|
|
790
|
+
}
|
|
791
|
+
return Array.from(arr, num => hexNumbers[num]).join("");
|
|
792
|
+
}
|
|
793
|
+
function toBase64Util(arr) {
|
|
794
|
+
if (Uint8Array.prototype.toBase64) {
|
|
795
|
+
return arr.toBase64();
|
|
796
|
+
}
|
|
797
|
+
return btoa(bytesToString(arr));
|
|
798
|
+
}
|
|
799
|
+
function fromBase64Util(str) {
|
|
800
|
+
if (Uint8Array.fromBase64) {
|
|
801
|
+
return Uint8Array.fromBase64(str);
|
|
802
|
+
}
|
|
803
|
+
return stringToBytes(atob(str));
|
|
804
|
+
}
|
|
791
805
|
|
|
792
806
|
;// ./src/core/primitives.js
|
|
793
807
|
|
|
@@ -1082,6 +1096,9 @@ class BaseStream {
|
|
|
1082
1096
|
get canAsyncDecodeImageFromBuffer() {
|
|
1083
1097
|
return false;
|
|
1084
1098
|
}
|
|
1099
|
+
async getTransferableImage() {
|
|
1100
|
+
return null;
|
|
1101
|
+
}
|
|
1085
1102
|
peekByte() {
|
|
1086
1103
|
const peekedByte = this.getByte();
|
|
1087
1104
|
if (peekedByte !== -1) {
|
|
@@ -1539,7 +1556,7 @@ function stringToUTF16HexString(str) {
|
|
|
1539
1556
|
const buf = [];
|
|
1540
1557
|
for (let i = 0, ii = str.length; i < ii; i++) {
|
|
1541
1558
|
const char = str.charCodeAt(i);
|
|
1542
|
-
buf.push(
|
|
1559
|
+
buf.push(hexNumbers[char >> 8 & 0xff], hexNumbers[char & 0xff]);
|
|
1543
1560
|
}
|
|
1544
1561
|
return buf.join("");
|
|
1545
1562
|
}
|
|
@@ -2093,6 +2110,58 @@ function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
|
|
|
2093
2110
|
}
|
|
2094
2111
|
}
|
|
2095
2112
|
}
|
|
2113
|
+
function resizeRgbaImage(src, dest, w1, h1, w2, h2, alpha01) {
|
|
2114
|
+
const xRatio = w1 / w2;
|
|
2115
|
+
const yRatio = h1 / h2;
|
|
2116
|
+
let newIndex = 0;
|
|
2117
|
+
const xScaled = new Uint16Array(w2);
|
|
2118
|
+
if (alpha01 === 1) {
|
|
2119
|
+
for (let i = 0; i < w2; i++) {
|
|
2120
|
+
xScaled[i] = Math.floor(i * xRatio);
|
|
2121
|
+
}
|
|
2122
|
+
const src32 = new Uint32Array(src.buffer);
|
|
2123
|
+
const dest32 = new Uint32Array(dest.buffer);
|
|
2124
|
+
const rgbMask = FeatureTest.isLittleEndian ? 0x00ffffff : 0xffffff00;
|
|
2125
|
+
for (let i = 0; i < h2; i++) {
|
|
2126
|
+
const buf = src32.subarray(Math.floor(i * yRatio) * w1);
|
|
2127
|
+
for (let j = 0; j < w2; j++) {
|
|
2128
|
+
dest32[newIndex++] |= buf[xScaled[j]] & rgbMask;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
} else {
|
|
2132
|
+
const COMPONENTS = 4;
|
|
2133
|
+
const w1Scanline = w1 * COMPONENTS;
|
|
2134
|
+
for (let i = 0; i < w2; i++) {
|
|
2135
|
+
xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
|
|
2136
|
+
}
|
|
2137
|
+
for (let i = 0; i < h2; i++) {
|
|
2138
|
+
const buf = src.subarray(Math.floor(i * yRatio) * w1Scanline);
|
|
2139
|
+
for (let j = 0; j < w2; j++) {
|
|
2140
|
+
const oldIndex = xScaled[j];
|
|
2141
|
+
dest[newIndex++] = buf[oldIndex];
|
|
2142
|
+
dest[newIndex++] = buf[oldIndex + 1];
|
|
2143
|
+
dest[newIndex++] = buf[oldIndex + 2];
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function copyRgbaImage(src, dest, alpha01) {
|
|
2149
|
+
if (alpha01 === 1) {
|
|
2150
|
+
const src32 = new Uint32Array(src.buffer);
|
|
2151
|
+
const dest32 = new Uint32Array(dest.buffer);
|
|
2152
|
+
const rgbMask = FeatureTest.isLittleEndian ? 0x00ffffff : 0xffffff00;
|
|
2153
|
+
for (let i = 0, ii = src32.length; i < ii; i++) {
|
|
2154
|
+
dest32[i] |= src32[i] & rgbMask;
|
|
2155
|
+
}
|
|
2156
|
+
} else {
|
|
2157
|
+
let j = 0;
|
|
2158
|
+
for (let i = 0, ii = src.length; i < ii; i += 4) {
|
|
2159
|
+
dest[j++] = src[i];
|
|
2160
|
+
dest[j++] = src[i + 1];
|
|
2161
|
+
dest[j++] = src[i + 2];
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2096
2165
|
class ColorSpace {
|
|
2097
2166
|
constructor(name, numComps) {
|
|
2098
2167
|
this.name = name;
|
|
@@ -2335,7 +2404,7 @@ class ColorSpace {
|
|
|
2335
2404
|
case "I":
|
|
2336
2405
|
case "Indexed":
|
|
2337
2406
|
baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
|
|
2338
|
-
const hiVal = xref.fetchIfRef(cs[2])
|
|
2407
|
+
const hiVal = Math.max(0, Math.min(xref.fetchIfRef(cs[2]), 255));
|
|
2339
2408
|
const lookup = xref.fetchIfRef(cs[3]);
|
|
2340
2409
|
return new IndexedCS(baseCS, hiVal, lookup);
|
|
2341
2410
|
case "Separation":
|
|
@@ -2451,8 +2520,7 @@ class IndexedCS extends ColorSpace {
|
|
|
2451
2520
|
constructor(base, highVal, lookup) {
|
|
2452
2521
|
super("Indexed", 1);
|
|
2453
2522
|
this.base = base;
|
|
2454
|
-
|
|
2455
|
-
const length = base.numComps * highVal;
|
|
2523
|
+
const length = base.numComps * (highVal + 1);
|
|
2456
2524
|
this.lookup = new Uint8Array(length);
|
|
2457
2525
|
if (lookup instanceof BaseStream) {
|
|
2458
2526
|
const bytes = lookup.getBytes(length);
|
|
@@ -2564,6 +2632,13 @@ class DeviceRgbaCS extends ColorSpace {
|
|
|
2564
2632
|
isPassthrough(bits) {
|
|
2565
2633
|
return bits === 8;
|
|
2566
2634
|
}
|
|
2635
|
+
fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
|
|
2636
|
+
if (originalHeight !== height || originalWidth !== width) {
|
|
2637
|
+
resizeRgbaImage(comps, dest, originalWidth, originalHeight, width, height, alpha01);
|
|
2638
|
+
} else {
|
|
2639
|
+
copyRgbaImage(comps, dest, alpha01);
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2567
2642
|
}
|
|
2568
2643
|
class DeviceCmykCS extends ColorSpace {
|
|
2569
2644
|
constructor() {
|
|
@@ -3242,6 +3317,7 @@ class DecodeStream extends BaseStream {
|
|
|
3242
3317
|
}
|
|
3243
3318
|
class StreamsSequenceStream extends DecodeStream {
|
|
3244
3319
|
constructor(streams, onError = null) {
|
|
3320
|
+
streams = streams.filter(s => s instanceof BaseStream);
|
|
3245
3321
|
let maybeLength = 0;
|
|
3246
3322
|
for (const stream of streams) {
|
|
3247
3323
|
maybeLength += stream instanceof DecodeStream ? stream._rawMinBufferLength : stream.length;
|
|
@@ -3997,8 +4073,11 @@ class FlateStream extends DecodeStream {
|
|
|
3997
4073
|
writable
|
|
3998
4074
|
} = new DecompressionStream("deflate");
|
|
3999
4075
|
const writer = writable.getWriter();
|
|
4000
|
-
writer.
|
|
4001
|
-
writer.
|
|
4076
|
+
await writer.ready;
|
|
4077
|
+
writer.write(bytes).then(async () => {
|
|
4078
|
+
await writer.ready;
|
|
4079
|
+
await writer.close();
|
|
4080
|
+
}).catch(() => {});
|
|
4002
4081
|
const chunks = [];
|
|
4003
4082
|
let totalLength = 0;
|
|
4004
4083
|
for await (const chunk of readable) {
|
|
@@ -7071,6 +7150,48 @@ function findNextFileMarker(data, currentPos, startPos = currentPos) {
|
|
|
7071
7150
|
offset: newPos
|
|
7072
7151
|
};
|
|
7073
7152
|
}
|
|
7153
|
+
function prepareComponents(frame) {
|
|
7154
|
+
const mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
|
|
7155
|
+
const mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
|
|
7156
|
+
for (const component of frame.components) {
|
|
7157
|
+
const blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
|
|
7158
|
+
const blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
|
|
7159
|
+
const blocksPerLineForMcu = mcusPerLine * component.h;
|
|
7160
|
+
const blocksPerColumnForMcu = mcusPerColumn * component.v;
|
|
7161
|
+
const blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
|
|
7162
|
+
component.blockData = new Int16Array(blocksBufferSize);
|
|
7163
|
+
component.blocksPerLine = blocksPerLine;
|
|
7164
|
+
component.blocksPerColumn = blocksPerColumn;
|
|
7165
|
+
}
|
|
7166
|
+
frame.mcusPerLine = mcusPerLine;
|
|
7167
|
+
frame.mcusPerColumn = mcusPerColumn;
|
|
7168
|
+
}
|
|
7169
|
+
function readDataBlock(data, offset) {
|
|
7170
|
+
const length = readUint16(data, offset);
|
|
7171
|
+
offset += 2;
|
|
7172
|
+
let endOffset = offset + length - 2;
|
|
7173
|
+
const fileMarker = findNextFileMarker(data, endOffset, offset);
|
|
7174
|
+
if (fileMarker?.invalid) {
|
|
7175
|
+
warn("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
|
|
7176
|
+
endOffset = fileMarker.offset;
|
|
7177
|
+
}
|
|
7178
|
+
const array = data.subarray(offset, endOffset);
|
|
7179
|
+
offset += array.length;
|
|
7180
|
+
return {
|
|
7181
|
+
appData: array,
|
|
7182
|
+
newOffset: offset
|
|
7183
|
+
};
|
|
7184
|
+
}
|
|
7185
|
+
function skipData(data, offset) {
|
|
7186
|
+
const length = readUint16(data, offset);
|
|
7187
|
+
offset += 2;
|
|
7188
|
+
const endOffset = offset + length - 2;
|
|
7189
|
+
const fileMarker = findNextFileMarker(data, endOffset, offset);
|
|
7190
|
+
if (fileMarker?.invalid) {
|
|
7191
|
+
return fileMarker.offset;
|
|
7192
|
+
}
|
|
7193
|
+
return endOffset;
|
|
7194
|
+
}
|
|
7074
7195
|
class JpegImage {
|
|
7075
7196
|
constructor({
|
|
7076
7197
|
decodeTransform = null,
|
|
@@ -7079,38 +7200,44 @@ class JpegImage {
|
|
|
7079
7200
|
this._decodeTransform = decodeTransform;
|
|
7080
7201
|
this._colorTransform = colorTransform;
|
|
7081
7202
|
}
|
|
7203
|
+
static canUseImageDecoder(data, colorTransform = -1) {
|
|
7204
|
+
let offset = 0;
|
|
7205
|
+
let numComponents = null;
|
|
7206
|
+
let fileMarker = readUint16(data, offset);
|
|
7207
|
+
offset += 2;
|
|
7208
|
+
if (fileMarker !== 0xffd8) {
|
|
7209
|
+
throw new JpegError("SOI not found");
|
|
7210
|
+
}
|
|
7211
|
+
fileMarker = readUint16(data, offset);
|
|
7212
|
+
offset += 2;
|
|
7213
|
+
markerLoop: while (fileMarker !== 0xffd9) {
|
|
7214
|
+
switch (fileMarker) {
|
|
7215
|
+
case 0xffc0:
|
|
7216
|
+
case 0xffc1:
|
|
7217
|
+
case 0xffc2:
|
|
7218
|
+
numComponents = data[offset + (2 + 1 + 2 + 2)];
|
|
7219
|
+
break markerLoop;
|
|
7220
|
+
case 0xffff:
|
|
7221
|
+
if (data[offset] !== 0xff) {
|
|
7222
|
+
offset--;
|
|
7223
|
+
}
|
|
7224
|
+
break;
|
|
7225
|
+
}
|
|
7226
|
+
offset = skipData(data, offset);
|
|
7227
|
+
fileMarker = readUint16(data, offset);
|
|
7228
|
+
offset += 2;
|
|
7229
|
+
}
|
|
7230
|
+
if (numComponents === 4) {
|
|
7231
|
+
return false;
|
|
7232
|
+
}
|
|
7233
|
+
if (numComponents === 3 && colorTransform === 0) {
|
|
7234
|
+
return false;
|
|
7235
|
+
}
|
|
7236
|
+
return true;
|
|
7237
|
+
}
|
|
7082
7238
|
parse(data, {
|
|
7083
7239
|
dnlScanLines = null
|
|
7084
7240
|
} = {}) {
|
|
7085
|
-
function readDataBlock() {
|
|
7086
|
-
const length = readUint16(data, offset);
|
|
7087
|
-
offset += 2;
|
|
7088
|
-
let endOffset = offset + length - 2;
|
|
7089
|
-
const fileMarker = findNextFileMarker(data, endOffset, offset);
|
|
7090
|
-
if (fileMarker?.invalid) {
|
|
7091
|
-
warn("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
|
|
7092
|
-
endOffset = fileMarker.offset;
|
|
7093
|
-
}
|
|
7094
|
-
const array = data.subarray(offset, endOffset);
|
|
7095
|
-
offset += array.length;
|
|
7096
|
-
return array;
|
|
7097
|
-
}
|
|
7098
|
-
function prepareComponents(frame) {
|
|
7099
|
-
const mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
|
|
7100
|
-
const mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
|
|
7101
|
-
for (const component of frame.components) {
|
|
7102
|
-
const blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
|
|
7103
|
-
const blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
|
|
7104
|
-
const blocksPerLineForMcu = mcusPerLine * component.h;
|
|
7105
|
-
const blocksPerColumnForMcu = mcusPerColumn * component.v;
|
|
7106
|
-
const blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
|
|
7107
|
-
component.blockData = new Int16Array(blocksBufferSize);
|
|
7108
|
-
component.blocksPerLine = blocksPerLine;
|
|
7109
|
-
component.blocksPerColumn = blocksPerColumn;
|
|
7110
|
-
}
|
|
7111
|
-
frame.mcusPerLine = mcusPerLine;
|
|
7112
|
-
frame.mcusPerColumn = mcusPerColumn;
|
|
7113
|
-
}
|
|
7114
7241
|
let offset = 0;
|
|
7115
7242
|
let jfif = null;
|
|
7116
7243
|
let adobe = null;
|
|
@@ -7146,7 +7273,11 @@ class JpegImage {
|
|
|
7146
7273
|
case 0xffee:
|
|
7147
7274
|
case 0xffef:
|
|
7148
7275
|
case 0xfffe:
|
|
7149
|
-
const
|
|
7276
|
+
const {
|
|
7277
|
+
appData,
|
|
7278
|
+
newOffset
|
|
7279
|
+
} = readDataBlock(data, offset);
|
|
7280
|
+
offset = newOffset;
|
|
7150
7281
|
if (fileMarker === 0xffe0) {
|
|
7151
7282
|
if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
|
|
7152
7283
|
jfif = {
|
|
@@ -7570,6 +7701,9 @@ class JpegStream extends DecodeStream {
|
|
|
7570
7701
|
this.maybeLength = maybeLength;
|
|
7571
7702
|
this.params = params;
|
|
7572
7703
|
}
|
|
7704
|
+
static get canUseImageDecoder() {
|
|
7705
|
+
return shadow(this, "canUseImageDecoder", typeof ImageDecoder === "undefined" ? Promise.resolve(false) : ImageDecoder.isTypeSupported("image/jpeg"));
|
|
7706
|
+
}
|
|
7573
7707
|
get bytes() {
|
|
7574
7708
|
return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
|
|
7575
7709
|
}
|
|
@@ -7577,19 +7711,7 @@ class JpegStream extends DecodeStream {
|
|
|
7577
7711
|
readBlock() {
|
|
7578
7712
|
this.decodeImage();
|
|
7579
7713
|
}
|
|
7580
|
-
|
|
7581
|
-
if (this.eof) {
|
|
7582
|
-
return this.buffer;
|
|
7583
|
-
}
|
|
7584
|
-
bytes ||= this.bytes;
|
|
7585
|
-
for (let i = 0, ii = bytes.length - 1; i < ii; i++) {
|
|
7586
|
-
if (bytes[i] === 0xff && bytes[i + 1] === 0xd8) {
|
|
7587
|
-
if (i > 0) {
|
|
7588
|
-
bytes = bytes.subarray(i);
|
|
7589
|
-
}
|
|
7590
|
-
break;
|
|
7591
|
-
}
|
|
7592
|
-
}
|
|
7714
|
+
get jpegOptions() {
|
|
7593
7715
|
const jpegOptions = {
|
|
7594
7716
|
decodeTransform: undefined,
|
|
7595
7717
|
colorTransform: undefined
|
|
@@ -7618,7 +7740,25 @@ class JpegStream extends DecodeStream {
|
|
|
7618
7740
|
jpegOptions.colorTransform = colorTransform;
|
|
7619
7741
|
}
|
|
7620
7742
|
}
|
|
7621
|
-
|
|
7743
|
+
return shadow(this, "jpegOptions", jpegOptions);
|
|
7744
|
+
}
|
|
7745
|
+
#skipUselessBytes(data) {
|
|
7746
|
+
for (let i = 0, ii = data.length - 1; i < ii; i++) {
|
|
7747
|
+
if (data[i] === 0xff && data[i + 1] === 0xd8) {
|
|
7748
|
+
if (i > 0) {
|
|
7749
|
+
data = data.subarray(i);
|
|
7750
|
+
}
|
|
7751
|
+
break;
|
|
7752
|
+
}
|
|
7753
|
+
}
|
|
7754
|
+
return data;
|
|
7755
|
+
}
|
|
7756
|
+
decodeImage(bytes) {
|
|
7757
|
+
if (this.eof) {
|
|
7758
|
+
return this.buffer;
|
|
7759
|
+
}
|
|
7760
|
+
bytes = this.#skipUselessBytes(bytes || this.bytes);
|
|
7761
|
+
const jpegImage = new JpegImage(this.jpegOptions);
|
|
7622
7762
|
jpegImage.parse(bytes);
|
|
7623
7763
|
const data = jpegImage.getData({
|
|
7624
7764
|
width: this.drawWidth,
|
|
@@ -7635,6 +7775,37 @@ class JpegStream extends DecodeStream {
|
|
|
7635
7775
|
get canAsyncDecodeImageFromBuffer() {
|
|
7636
7776
|
return this.stream.isAsync;
|
|
7637
7777
|
}
|
|
7778
|
+
async getTransferableImage() {
|
|
7779
|
+
if (!(await JpegStream.canUseImageDecoder)) {
|
|
7780
|
+
return null;
|
|
7781
|
+
}
|
|
7782
|
+
const jpegOptions = this.jpegOptions;
|
|
7783
|
+
if (jpegOptions.decodeTransform) {
|
|
7784
|
+
return null;
|
|
7785
|
+
}
|
|
7786
|
+
let decoder;
|
|
7787
|
+
try {
|
|
7788
|
+
const bytes = this.canAsyncDecodeImageFromBuffer && (await this.stream.asyncGetBytes()) || this.bytes;
|
|
7789
|
+
if (!bytes) {
|
|
7790
|
+
return null;
|
|
7791
|
+
}
|
|
7792
|
+
const data = this.#skipUselessBytes(bytes);
|
|
7793
|
+
if (!JpegImage.canUseImageDecoder(data, jpegOptions.colorTransform)) {
|
|
7794
|
+
return null;
|
|
7795
|
+
}
|
|
7796
|
+
decoder = new ImageDecoder({
|
|
7797
|
+
data,
|
|
7798
|
+
type: "image/jpeg",
|
|
7799
|
+
preferAnimation: false
|
|
7800
|
+
});
|
|
7801
|
+
return (await decoder.decode()).image;
|
|
7802
|
+
} catch (reason) {
|
|
7803
|
+
warn(`getTransferableImage - failed: "${reason}".`);
|
|
7804
|
+
return null;
|
|
7805
|
+
} finally {
|
|
7806
|
+
decoder?.close();
|
|
7807
|
+
}
|
|
7808
|
+
}
|
|
7638
7809
|
}
|
|
7639
7810
|
|
|
7640
7811
|
;// ./external/openjpeg/openjpeg.js
|
|
@@ -10088,17 +10259,14 @@ async function createBuiltInCMap(name, fetchBuiltInCMap) {
|
|
|
10088
10259
|
}
|
|
10089
10260
|
const {
|
|
10090
10261
|
cMapData,
|
|
10091
|
-
|
|
10262
|
+
isCompressed
|
|
10092
10263
|
} = await fetchBuiltInCMap(name);
|
|
10093
10264
|
const cMap = new CMap(true);
|
|
10094
|
-
if (
|
|
10265
|
+
if (isCompressed) {
|
|
10095
10266
|
return new BinaryCMapReader().process(cMapData, cMap, useCMap => extendCMap(cMap, fetchBuiltInCMap, useCMap));
|
|
10096
10267
|
}
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
|
|
10100
|
-
}
|
|
10101
|
-
throw new Error(`Invalid CMap "compressionType" value: ${compressionType}`);
|
|
10268
|
+
const lexer = new Lexer(new Stream(cMapData));
|
|
10269
|
+
return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
|
|
10102
10270
|
}
|
|
10103
10271
|
class CMapFactory {
|
|
10104
10272
|
static async create({
|
|
@@ -28204,12 +28372,17 @@ const MIN_IMAGE_DIM = 2048;
|
|
|
28204
28372
|
const MAX_IMAGE_DIM = 65537;
|
|
28205
28373
|
const MAX_ERROR = 128;
|
|
28206
28374
|
class ImageResizer {
|
|
28375
|
+
static #goodSquareLength = MIN_IMAGE_DIM;
|
|
28376
|
+
static #isChrome = false;
|
|
28207
28377
|
constructor(imgData, isMask) {
|
|
28208
28378
|
this._imgData = imgData;
|
|
28209
28379
|
this._isMask = isMask;
|
|
28210
28380
|
}
|
|
28381
|
+
static get canUseImageDecoder() {
|
|
28382
|
+
return shadow(this, "canUseImageDecoder", this.#isChrome || typeof ImageDecoder === "undefined" ? Promise.resolve(false) : ImageDecoder.isTypeSupported("image/bmp"));
|
|
28383
|
+
}
|
|
28211
28384
|
static needsToBeResized(width, height) {
|
|
28212
|
-
if (width <= this
|
|
28385
|
+
if (width <= this.#goodSquareLength && height <= this.#goodSquareLength) {
|
|
28213
28386
|
return false;
|
|
28214
28387
|
}
|
|
28215
28388
|
const {
|
|
@@ -28222,15 +28395,15 @@ class ImageResizer {
|
|
|
28222
28395
|
if (this._hasMaxArea) {
|
|
28223
28396
|
return area > this.MAX_AREA;
|
|
28224
28397
|
}
|
|
28225
|
-
if (area < this
|
|
28398
|
+
if (area < this.#goodSquareLength ** 2) {
|
|
28226
28399
|
return false;
|
|
28227
28400
|
}
|
|
28228
28401
|
if (this._areGoodDims(width, height)) {
|
|
28229
|
-
this
|
|
28402
|
+
this.#goodSquareLength = Math.max(this.#goodSquareLength, Math.floor(Math.sqrt(width * height)));
|
|
28230
28403
|
return false;
|
|
28231
28404
|
}
|
|
28232
|
-
this
|
|
28233
|
-
const maxArea = this.MAX_AREA = this
|
|
28405
|
+
this.#goodSquareLength = this._guessMax(this.#goodSquareLength, MAX_DIM, MAX_ERROR, 0);
|
|
28406
|
+
const maxArea = this.MAX_AREA = this.#goodSquareLength ** 2;
|
|
28234
28407
|
return area > maxArea;
|
|
28235
28408
|
}
|
|
28236
28409
|
static get MAX_DIM() {
|
|
@@ -28238,7 +28411,7 @@ class ImageResizer {
|
|
|
28238
28411
|
}
|
|
28239
28412
|
static get MAX_AREA() {
|
|
28240
28413
|
this._hasMaxArea = true;
|
|
28241
|
-
return shadow(this, "MAX_AREA", this._guessMax(
|
|
28414
|
+
return shadow(this, "MAX_AREA", this._guessMax(this.#goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2);
|
|
28242
28415
|
}
|
|
28243
28416
|
static set MAX_AREA(area) {
|
|
28244
28417
|
if (area >= 0) {
|
|
@@ -28251,6 +28424,10 @@ class ImageResizer {
|
|
|
28251
28424
|
this.MAX_AREA = area >> 2;
|
|
28252
28425
|
}
|
|
28253
28426
|
}
|
|
28427
|
+
static setOptions(opts) {
|
|
28428
|
+
this.setMaxArea(opts.maxArea ?? -1);
|
|
28429
|
+
this.#isChrome = opts.isChrome ?? false;
|
|
28430
|
+
}
|
|
28254
28431
|
static _areGoodDims(width, height) {
|
|
28255
28432
|
try {
|
|
28256
28433
|
const canvas = new OffscreenCanvas(width, height);
|
|
@@ -28280,10 +28457,27 @@ class ImageResizer {
|
|
|
28280
28457
|
}
|
|
28281
28458
|
async _createImage() {
|
|
28282
28459
|
const data = this._encodeBMP();
|
|
28283
|
-
|
|
28284
|
-
|
|
28285
|
-
|
|
28286
|
-
|
|
28460
|
+
let decoder, imagePromise;
|
|
28461
|
+
if (await ImageResizer.canUseImageDecoder) {
|
|
28462
|
+
decoder = new ImageDecoder({
|
|
28463
|
+
data,
|
|
28464
|
+
type: "image/bmp",
|
|
28465
|
+
preferAnimation: false,
|
|
28466
|
+
transfer: [data.buffer]
|
|
28467
|
+
});
|
|
28468
|
+
imagePromise = decoder.decode().catch(reason => {
|
|
28469
|
+
warn(`BMP image decoding failed: ${reason}`);
|
|
28470
|
+
return createImageBitmap(new Blob([this._encodeBMP().buffer], {
|
|
28471
|
+
type: "image/bmp"
|
|
28472
|
+
}));
|
|
28473
|
+
}).finally(() => {
|
|
28474
|
+
decoder.close();
|
|
28475
|
+
});
|
|
28476
|
+
} else {
|
|
28477
|
+
imagePromise = createImageBitmap(new Blob([data.buffer], {
|
|
28478
|
+
type: "image/bmp"
|
|
28479
|
+
}));
|
|
28480
|
+
}
|
|
28287
28481
|
const {
|
|
28288
28482
|
MAX_AREA,
|
|
28289
28483
|
MAX_DIM
|
|
@@ -28304,7 +28498,8 @@ class ImageResizer {
|
|
|
28304
28498
|
steps.splice(-1, 1, factor / (1 << N));
|
|
28305
28499
|
let newWidth = width;
|
|
28306
28500
|
let newHeight = height;
|
|
28307
|
-
|
|
28501
|
+
const result = await imagePromise;
|
|
28502
|
+
let bitmap = result.image || result;
|
|
28308
28503
|
for (const step of steps) {
|
|
28309
28504
|
const prevWidth = newWidth;
|
|
28310
28505
|
const prevHeight = newHeight;
|
|
@@ -28313,6 +28508,7 @@ class ImageResizer {
|
|
|
28313
28508
|
const canvas = new OffscreenCanvas(newWidth, newHeight);
|
|
28314
28509
|
const ctx = canvas.getContext("2d");
|
|
28315
28510
|
ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
|
|
28511
|
+
bitmap.close();
|
|
28316
28512
|
bitmap = canvas.transferToImageBitmap();
|
|
28317
28513
|
}
|
|
28318
28514
|
imgData.data = null;
|
|
@@ -28440,7 +28636,6 @@ class ImageResizer {
|
|
|
28440
28636
|
return bmpData;
|
|
28441
28637
|
}
|
|
28442
28638
|
}
|
|
28443
|
-
ImageResizer._goodSquareLength = MIN_IMAGE_DIM;
|
|
28444
28639
|
|
|
28445
28640
|
;// ./src/shared/murmurhash3.js
|
|
28446
28641
|
const SEED = 0xc3d2e1f0;
|
|
@@ -29594,7 +29789,7 @@ class PDFImage {
|
|
|
29594
29789
|
const bpc = this.bpc;
|
|
29595
29790
|
const rowBytes = originalWidth * numComps * bpc + 7 >> 3;
|
|
29596
29791
|
const mustBeResized = isOffscreenCanvasSupported && ImageResizer.needsToBeResized(drawWidth, drawHeight);
|
|
29597
|
-
if (this.colorSpace.name === "DeviceRGBA") {
|
|
29792
|
+
if (!this.smask && !this.mask && this.colorSpace.name === "DeviceRGBA") {
|
|
29598
29793
|
imgData.kind = ImageKind.RGBA_32BPP;
|
|
29599
29794
|
const imgArray = imgData.data = await this.getImageBytes(originalHeight * originalWidth * 4, {});
|
|
29600
29795
|
if (isOffscreenCanvasSupported) {
|
|
@@ -29613,6 +29808,10 @@ class PDFImage {
|
|
|
29613
29808
|
kind = ImageKind.RGB_24BPP;
|
|
29614
29809
|
}
|
|
29615
29810
|
if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
|
|
29811
|
+
const image = await this.#getImage(originalWidth, originalHeight);
|
|
29812
|
+
if (image) {
|
|
29813
|
+
return image;
|
|
29814
|
+
}
|
|
29616
29815
|
const data = await this.getImageBytes(originalHeight * rowBytes, {});
|
|
29617
29816
|
if (isOffscreenCanvasSupported) {
|
|
29618
29817
|
if (mustBeResized) {
|
|
@@ -29655,6 +29854,10 @@ class PDFImage {
|
|
|
29655
29854
|
break;
|
|
29656
29855
|
}
|
|
29657
29856
|
if (isHandled) {
|
|
29857
|
+
const image = await this.#getImage(drawWidth, drawHeight);
|
|
29858
|
+
if (image) {
|
|
29859
|
+
return image;
|
|
29860
|
+
}
|
|
29658
29861
|
const rgba = await this.getImageBytes(imageLength, {
|
|
29659
29862
|
drawWidth,
|
|
29660
29863
|
drawHeight,
|
|
@@ -29802,6 +30005,19 @@ class PDFImage {
|
|
|
29802
30005
|
interpolate: this.interpolate
|
|
29803
30006
|
};
|
|
29804
30007
|
}
|
|
30008
|
+
async #getImage(width, height) {
|
|
30009
|
+
const bitmap = await this.image.getTransferableImage();
|
|
30010
|
+
if (!bitmap) {
|
|
30011
|
+
return null;
|
|
30012
|
+
}
|
|
30013
|
+
return {
|
|
30014
|
+
data: null,
|
|
30015
|
+
width,
|
|
30016
|
+
height,
|
|
30017
|
+
bitmap,
|
|
30018
|
+
interpolate: this.interpolate
|
|
30019
|
+
};
|
|
30020
|
+
}
|
|
29805
30021
|
async getImageBytes(length, {
|
|
29806
30022
|
drawWidth,
|
|
29807
30023
|
drawHeight,
|
|
@@ -29857,6 +30073,7 @@ const DefaultPartialEvaluatorOptions = Object.freeze({
|
|
|
29857
30073
|
ignoreErrors: false,
|
|
29858
30074
|
isEvalSupported: true,
|
|
29859
30075
|
isOffscreenCanvasSupported: false,
|
|
30076
|
+
isChrome: false,
|
|
29860
30077
|
canvasMaxAreaInBytes: -1,
|
|
29861
30078
|
fontExtraProperties: false,
|
|
29862
30079
|
useSystemFonts: true,
|
|
@@ -29980,7 +30197,10 @@ class PartialEvaluator {
|
|
|
29980
30197
|
this.type3FontRefs = null;
|
|
29981
30198
|
this._regionalImageCache = new RegionalImageCache();
|
|
29982
30199
|
this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
|
|
29983
|
-
ImageResizer.
|
|
30200
|
+
ImageResizer.setOptions({
|
|
30201
|
+
isChrome: this.options.isChrome,
|
|
30202
|
+
maxArea: this.options.canvasMaxAreaInBytes
|
|
30203
|
+
});
|
|
29984
30204
|
}
|
|
29985
30205
|
get _pdfFunctionFactory() {
|
|
29986
30206
|
const pdfFunctionFactory = new PDFFunctionFactory({
|
|
@@ -30104,16 +30324,14 @@ class PartialEvaluator {
|
|
|
30104
30324
|
}
|
|
30105
30325
|
data = {
|
|
30106
30326
|
cMapData: new Uint8Array(await response.arrayBuffer()),
|
|
30107
|
-
|
|
30327
|
+
isCompressed: true
|
|
30108
30328
|
};
|
|
30109
30329
|
} else {
|
|
30110
30330
|
data = await this.handler.sendWithPromise("FetchBuiltInCMap", {
|
|
30111
30331
|
name
|
|
30112
30332
|
});
|
|
30113
30333
|
}
|
|
30114
|
-
|
|
30115
|
-
this.builtInCMapCache.set(name, data);
|
|
30116
|
-
}
|
|
30334
|
+
this.builtInCMapCache.set(name, data);
|
|
30117
30335
|
return data;
|
|
30118
30336
|
}
|
|
30119
30337
|
async fetchStandardFontData(name) {
|
|
@@ -31286,6 +31504,11 @@ class PartialEvaluator {
|
|
|
31286
31504
|
case OPS.setFillColorN:
|
|
31287
31505
|
cs = stateManager.state.patternFillColorSpace;
|
|
31288
31506
|
if (!cs) {
|
|
31507
|
+
if (isNumberArray(args, null)) {
|
|
31508
|
+
args = ColorSpace.singletons.gray.getRgb(args, 0);
|
|
31509
|
+
fn = OPS.setFillRGBColor;
|
|
31510
|
+
break;
|
|
31511
|
+
}
|
|
31289
31512
|
args = [];
|
|
31290
31513
|
fn = OPS.setFillTransparent;
|
|
31291
31514
|
break;
|
|
@@ -31300,6 +31523,11 @@ class PartialEvaluator {
|
|
|
31300
31523
|
case OPS.setStrokeColorN:
|
|
31301
31524
|
cs = stateManager.state.patternStrokeColorSpace;
|
|
31302
31525
|
if (!cs) {
|
|
31526
|
+
if (isNumberArray(args, null)) {
|
|
31527
|
+
args = ColorSpace.singletons.gray.getRgb(args, 0);
|
|
31528
|
+
fn = OPS.setStrokeRGBColor;
|
|
31529
|
+
break;
|
|
31530
|
+
}
|
|
31303
31531
|
args = [];
|
|
31304
31532
|
fn = OPS.setStrokeTransparent;
|
|
31305
31533
|
break;
|
|
@@ -32951,12 +33179,19 @@ class PartialEvaluator {
|
|
|
32951
33179
|
let fontFile, subtype, length1, length2, length3;
|
|
32952
33180
|
try {
|
|
32953
33181
|
fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
|
|
33182
|
+
if (fontFile) {
|
|
33183
|
+
if (!(fontFile instanceof BaseStream)) {
|
|
33184
|
+
throw new FormatError("FontFile should be a stream");
|
|
33185
|
+
} else if (fontFile.isEmpty) {
|
|
33186
|
+
throw new FormatError("FontFile is empty");
|
|
33187
|
+
}
|
|
33188
|
+
}
|
|
32954
33189
|
} catch (ex) {
|
|
32955
33190
|
if (!this.options.ignoreErrors) {
|
|
32956
33191
|
throw ex;
|
|
32957
33192
|
}
|
|
32958
33193
|
warn(`translateFont - fetching "${fontName.name}" font file: "${ex}".`);
|
|
32959
|
-
fontFile =
|
|
33194
|
+
fontFile = null;
|
|
32960
33195
|
}
|
|
32961
33196
|
let isInternalFont = false;
|
|
32962
33197
|
let glyphScaleFactors = null;
|
|
@@ -36297,8 +36532,11 @@ async function writeStream(stream, buffer, transform) {
|
|
|
36297
36532
|
try {
|
|
36298
36533
|
const cs = new CompressionStream("deflate");
|
|
36299
36534
|
const writer = cs.writable.getWriter();
|
|
36300
|
-
writer.
|
|
36301
|
-
writer.
|
|
36535
|
+
await writer.ready;
|
|
36536
|
+
writer.write(bytes).then(async () => {
|
|
36537
|
+
await writer.ready;
|
|
36538
|
+
await writer.close();
|
|
36539
|
+
}).catch(() => {});
|
|
36302
36540
|
const buf = await new Response(cs.readable).arrayBuffer();
|
|
36303
36541
|
bytes = new Uint8Array(buf);
|
|
36304
36542
|
let newFilter, newParams;
|
|
@@ -37815,17 +38053,14 @@ class Catalog {
|
|
|
37815
38053
|
if (!Array.isArray(groupsData)) {
|
|
37816
38054
|
return shadow(this, "optionalContentConfig", null);
|
|
37817
38055
|
}
|
|
37818
|
-
const
|
|
37819
|
-
const groupRefs = new RefSet();
|
|
38056
|
+
const groupRefCache = new RefSetCache();
|
|
37820
38057
|
for (const groupRef of groupsData) {
|
|
37821
|
-
if (!(groupRef instanceof Ref) ||
|
|
38058
|
+
if (!(groupRef instanceof Ref) || groupRefCache.has(groupRef)) {
|
|
37822
38059
|
continue;
|
|
37823
38060
|
}
|
|
37824
|
-
|
|
37825
|
-
groups.push(this.#readOptionalContentGroup(groupRef));
|
|
38061
|
+
groupRefCache.put(groupRef, this.#readOptionalContentGroup(groupRef));
|
|
37826
38062
|
}
|
|
37827
|
-
config = this.#readOptionalContentConfig(defaultConfig,
|
|
37828
|
-
config.groups = groups;
|
|
38063
|
+
config = this.#readOptionalContentConfig(defaultConfig, groupRefCache);
|
|
37829
38064
|
} catch (ex) {
|
|
37830
38065
|
if (ex instanceof MissingDataException) {
|
|
37831
38066
|
throw ex;
|
|
@@ -37843,7 +38078,8 @@ class Catalog {
|
|
|
37843
38078
|
usage: {
|
|
37844
38079
|
print: null,
|
|
37845
38080
|
view: null
|
|
37846
|
-
}
|
|
38081
|
+
},
|
|
38082
|
+
rbGroups: []
|
|
37847
38083
|
};
|
|
37848
38084
|
const name = group.get("Name");
|
|
37849
38085
|
if (typeof name === "string") {
|
|
@@ -37889,7 +38125,7 @@ class Catalog {
|
|
|
37889
38125
|
}
|
|
37890
38126
|
return obj;
|
|
37891
38127
|
}
|
|
37892
|
-
#readOptionalContentConfig(config,
|
|
38128
|
+
#readOptionalContentConfig(config, groupRefCache) {
|
|
37893
38129
|
function parseOnOff(refs) {
|
|
37894
38130
|
const onParsed = [];
|
|
37895
38131
|
if (Array.isArray(refs)) {
|
|
@@ -37897,7 +38133,7 @@ class Catalog {
|
|
|
37897
38133
|
if (!(value instanceof Ref)) {
|
|
37898
38134
|
continue;
|
|
37899
38135
|
}
|
|
37900
|
-
if (
|
|
38136
|
+
if (groupRefCache.has(value)) {
|
|
37901
38137
|
onParsed.push(value.toString());
|
|
37902
38138
|
}
|
|
37903
38139
|
}
|
|
@@ -37910,7 +38146,7 @@ class Catalog {
|
|
|
37910
38146
|
}
|
|
37911
38147
|
const order = [];
|
|
37912
38148
|
for (const value of refs) {
|
|
37913
|
-
if (value instanceof Ref &&
|
|
38149
|
+
if (value instanceof Ref && groupRefCache.has(value)) {
|
|
37914
38150
|
parsedOrderRefs.put(value);
|
|
37915
38151
|
order.push(value.toString());
|
|
37916
38152
|
continue;
|
|
@@ -37924,7 +38160,7 @@ class Catalog {
|
|
|
37924
38160
|
return order;
|
|
37925
38161
|
}
|
|
37926
38162
|
const hiddenGroups = [];
|
|
37927
|
-
for (const groupRef of
|
|
38163
|
+
for (const [groupRef] of groupRefCache.items()) {
|
|
37928
38164
|
if (parsedOrderRefs.has(groupRef)) {
|
|
37929
38165
|
continue;
|
|
37930
38166
|
}
|
|
@@ -37960,9 +38196,28 @@ class Catalog {
|
|
|
37960
38196
|
order: nestedOrder
|
|
37961
38197
|
};
|
|
37962
38198
|
}
|
|
38199
|
+
function parseRBGroups(rbGroups) {
|
|
38200
|
+
if (!Array.isArray(rbGroups)) {
|
|
38201
|
+
return;
|
|
38202
|
+
}
|
|
38203
|
+
for (const value of rbGroups) {
|
|
38204
|
+
const rbGroup = xref.fetchIfRef(value);
|
|
38205
|
+
if (!Array.isArray(rbGroup) || !rbGroup.length) {
|
|
38206
|
+
continue;
|
|
38207
|
+
}
|
|
38208
|
+
const parsedRbGroup = new Set();
|
|
38209
|
+
for (const ref of rbGroup) {
|
|
38210
|
+
if (ref instanceof Ref && groupRefCache.has(ref) && !parsedRbGroup.has(ref.toString())) {
|
|
38211
|
+
parsedRbGroup.add(ref.toString());
|
|
38212
|
+
groupRefCache.get(ref).rbGroups.push(parsedRbGroup);
|
|
38213
|
+
}
|
|
38214
|
+
}
|
|
38215
|
+
}
|
|
38216
|
+
}
|
|
37963
38217
|
const xref = this.xref,
|
|
37964
38218
|
parsedOrderRefs = new RefSet(),
|
|
37965
38219
|
MAX_NESTED_LEVELS = 10;
|
|
38220
|
+
parseRBGroups(config.get("RBGroups"));
|
|
37966
38221
|
return {
|
|
37967
38222
|
name: typeof config.get("Name") === "string" ? stringToPDFString(config.get("Name")) : null,
|
|
37968
38223
|
creator: typeof config.get("Creator") === "string" ? stringToPDFString(config.get("Creator")) : null,
|
|
@@ -37970,7 +38225,7 @@ class Catalog {
|
|
|
37970
38225
|
on: parseOnOff(config.get("ON")),
|
|
37971
38226
|
off: parseOnOff(config.get("OFF")),
|
|
37972
38227
|
order: parseOrder(config.get("Order")),
|
|
37973
|
-
groups:
|
|
38228
|
+
groups: [...groupRefCache]
|
|
37974
38229
|
};
|
|
37975
38230
|
}
|
|
37976
38231
|
setActualNumPages(num = null) {
|
|
@@ -43923,7 +44178,7 @@ class Image extends StringObject {
|
|
|
43923
44178
|
return HTMLResult.EMPTY;
|
|
43924
44179
|
}
|
|
43925
44180
|
if (!buffer && this.transferEncoding === "base64") {
|
|
43926
|
-
buffer =
|
|
44181
|
+
buffer = fromBase64Util(this[$content]);
|
|
43927
44182
|
}
|
|
43928
44183
|
if (!buffer) {
|
|
43929
44184
|
return HTMLResult.EMPTY;
|
|
@@ -54381,7 +54636,7 @@ class Page {
|
|
|
54381
54636
|
}
|
|
54382
54637
|
await this._parsedAnnotations;
|
|
54383
54638
|
const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
|
|
54384
|
-
return structTree
|
|
54639
|
+
return this.pdfManager.ensure(structTree, "serializable");
|
|
54385
54640
|
}
|
|
54386
54641
|
_parseStructTree(structTreeRoot) {
|
|
54387
54642
|
const tree = new StructTreePage(structTreeRoot, this.pageDict);
|
|
@@ -54480,8 +54735,6 @@ class Page {
|
|
|
54480
54735
|
const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
|
|
54481
54736
|
const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
|
|
54482
54737
|
const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
|
|
54483
|
-
const FINGERPRINT_FIRST_BYTES = 1024;
|
|
54484
|
-
const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
|
|
54485
54738
|
function find(stream, signature, limit = 1024, backwards = false) {
|
|
54486
54739
|
const signatureLength = signature.length;
|
|
54487
54740
|
const scanBytes = stream.peekBytes(limit);
|
|
@@ -55014,28 +55267,22 @@ class PDFDocument {
|
|
|
55014
55267
|
return shadow(this, "documentInfo", docInfo);
|
|
55015
55268
|
}
|
|
55016
55269
|
get fingerprints() {
|
|
55270
|
+
const FINGERPRINT_FIRST_BYTES = 1024;
|
|
55271
|
+
const EMPTY_FINGERPRINT = "\x00".repeat(16);
|
|
55017
55272
|
function validate(data) {
|
|
55018
|
-
return typeof data === "string" && data.length
|
|
55019
|
-
}
|
|
55020
|
-
function hexString(hash) {
|
|
55021
|
-
const buf = [];
|
|
55022
|
-
for (const num of hash) {
|
|
55023
|
-
const hex = num.toString(16);
|
|
55024
|
-
buf.push(hex.padStart(2, "0"));
|
|
55025
|
-
}
|
|
55026
|
-
return buf.join("");
|
|
55273
|
+
return typeof data === "string" && data.length === 16 && data !== EMPTY_FINGERPRINT;
|
|
55027
55274
|
}
|
|
55028
|
-
const
|
|
55275
|
+
const id = this.xref.trailer.get("ID");
|
|
55029
55276
|
let hashOriginal, hashModified;
|
|
55030
|
-
if (Array.isArray(
|
|
55031
|
-
hashOriginal = stringToBytes(
|
|
55032
|
-
if (
|
|
55033
|
-
hashModified = stringToBytes(
|
|
55277
|
+
if (Array.isArray(id) && validate(id[0])) {
|
|
55278
|
+
hashOriginal = stringToBytes(id[0]);
|
|
55279
|
+
if (id[1] !== id[0] && validate(id[1])) {
|
|
55280
|
+
hashModified = stringToBytes(id[1]);
|
|
55034
55281
|
}
|
|
55035
55282
|
} else {
|
|
55036
55283
|
hashOriginal = calculateMD5(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
|
|
55037
55284
|
}
|
|
55038
|
-
return shadow(this, "fingerprints", [
|
|
55285
|
+
return shadow(this, "fingerprints", [toHexUtil(hashOriginal), hashModified ? toHexUtil(hashModified) : null]);
|
|
55039
55286
|
}
|
|
55040
55287
|
async _getLinearizationPage(pageIndex) {
|
|
55041
55288
|
const {
|
|
@@ -55247,10 +55494,11 @@ class PDFDocument {
|
|
|
55247
55494
|
}
|
|
55248
55495
|
}
|
|
55249
55496
|
get fieldObjects() {
|
|
55250
|
-
|
|
55251
|
-
|
|
55252
|
-
|
|
55253
|
-
|
|
55497
|
+
const promise = this.pdfManager.ensureDoc("formInfo").then(async formInfo => {
|
|
55498
|
+
if (!formInfo.hasFields) {
|
|
55499
|
+
return null;
|
|
55500
|
+
}
|
|
55501
|
+
const [annotationGlobals, acroForm] = await Promise.all([this.pdfManager.ensureDoc("annotationGlobals"), this.pdfManager.ensureCatalog("acroForm")]);
|
|
55254
55502
|
if (!annotationGlobals) {
|
|
55255
55503
|
return null;
|
|
55256
55504
|
}
|
|
@@ -55293,11 +55541,7 @@ class PDFDocument {
|
|
|
55293
55541
|
return false;
|
|
55294
55542
|
}
|
|
55295
55543
|
get calculationOrderIds() {
|
|
55296
|
-
const
|
|
55297
|
-
if (!acroForm?.has("CO")) {
|
|
55298
|
-
return shadow(this, "calculationOrderIds", null);
|
|
55299
|
-
}
|
|
55300
|
-
const calculationOrder = acroForm.get("CO");
|
|
55544
|
+
const calculationOrder = this.catalog.acroForm?.get("CO");
|
|
55301
55545
|
if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) {
|
|
55302
55546
|
return shadow(this, "calculationOrderIds", null);
|
|
55303
55547
|
}
|
|
@@ -55307,10 +55551,7 @@ class PDFDocument {
|
|
|
55307
55551
|
ids.push(id.toString());
|
|
55308
55552
|
}
|
|
55309
55553
|
}
|
|
55310
|
-
|
|
55311
|
-
return shadow(this, "calculationOrderIds", null);
|
|
55312
|
-
}
|
|
55313
|
-
return shadow(this, "calculationOrderIds", ids);
|
|
55554
|
+
return shadow(this, "calculationOrderIds", ids.length ? ids : null);
|
|
55314
55555
|
}
|
|
55315
55556
|
get annotationGlobals() {
|
|
55316
55557
|
return shadow(this, "annotationGlobals", AnnotationFactory.createGlobals(this.pdfManager));
|
|
@@ -55502,6 +55743,7 @@ function wrapReason(reason) {
|
|
|
55502
55743
|
}
|
|
55503
55744
|
}
|
|
55504
55745
|
class MessageHandler {
|
|
55746
|
+
#messageAC = new AbortController();
|
|
55505
55747
|
constructor(sourceName, targetName, comObj) {
|
|
55506
55748
|
this.sourceName = sourceName;
|
|
55507
55749
|
this.targetName = targetName;
|
|
@@ -55512,66 +55754,70 @@ class MessageHandler {
|
|
|
55512
55754
|
this.streamControllers = Object.create(null);
|
|
55513
55755
|
this.callbackCapabilities = Object.create(null);
|
|
55514
55756
|
this.actionHandler = Object.create(null);
|
|
55515
|
-
this.
|
|
55516
|
-
|
|
55517
|
-
|
|
55518
|
-
|
|
55519
|
-
|
|
55520
|
-
|
|
55521
|
-
|
|
55522
|
-
|
|
55523
|
-
|
|
55524
|
-
|
|
55525
|
-
|
|
55526
|
-
|
|
55527
|
-
|
|
55528
|
-
|
|
55529
|
-
|
|
55530
|
-
|
|
55531
|
-
|
|
55532
|
-
|
|
55533
|
-
|
|
55534
|
-
|
|
55535
|
-
|
|
55536
|
-
|
|
55537
|
-
|
|
55538
|
-
|
|
55539
|
-
|
|
55540
|
-
|
|
55541
|
-
|
|
55542
|
-
throw new Error(`Unknown action from worker: ${data.action}`);
|
|
55757
|
+
comObj.addEventListener("message", this.#onMessage.bind(this), {
|
|
55758
|
+
signal: this.#messageAC.signal
|
|
55759
|
+
});
|
|
55760
|
+
}
|
|
55761
|
+
#onMessage({
|
|
55762
|
+
data
|
|
55763
|
+
}) {
|
|
55764
|
+
if (data.targetName !== this.sourceName) {
|
|
55765
|
+
return;
|
|
55766
|
+
}
|
|
55767
|
+
if (data.stream) {
|
|
55768
|
+
this.#processStreamMessage(data);
|
|
55769
|
+
return;
|
|
55770
|
+
}
|
|
55771
|
+
if (data.callback) {
|
|
55772
|
+
const callbackId = data.callbackId;
|
|
55773
|
+
const capability = this.callbackCapabilities[callbackId];
|
|
55774
|
+
if (!capability) {
|
|
55775
|
+
throw new Error(`Cannot resolve callback ${callbackId}`);
|
|
55776
|
+
}
|
|
55777
|
+
delete this.callbackCapabilities[callbackId];
|
|
55778
|
+
if (data.callback === CallbackKind.DATA) {
|
|
55779
|
+
capability.resolve(data.data);
|
|
55780
|
+
} else if (data.callback === CallbackKind.ERROR) {
|
|
55781
|
+
capability.reject(wrapReason(data.reason));
|
|
55782
|
+
} else {
|
|
55783
|
+
throw new Error("Unexpected callback case");
|
|
55543
55784
|
}
|
|
55544
|
-
|
|
55545
|
-
|
|
55546
|
-
|
|
55547
|
-
|
|
55548
|
-
|
|
55549
|
-
|
|
55550
|
-
|
|
55551
|
-
|
|
55552
|
-
|
|
55553
|
-
|
|
55554
|
-
|
|
55555
|
-
|
|
55556
|
-
|
|
55557
|
-
|
|
55558
|
-
|
|
55559
|
-
|
|
55560
|
-
|
|
55561
|
-
|
|
55562
|
-
|
|
55563
|
-
reason: wrapReason(reason)
|
|
55564
|
-
});
|
|
55785
|
+
return;
|
|
55786
|
+
}
|
|
55787
|
+
const action = this.actionHandler[data.action];
|
|
55788
|
+
if (!action) {
|
|
55789
|
+
throw new Error(`Unknown action from worker: ${data.action}`);
|
|
55790
|
+
}
|
|
55791
|
+
if (data.callbackId) {
|
|
55792
|
+
const sourceName = this.sourceName,
|
|
55793
|
+
targetName = data.sourceName,
|
|
55794
|
+
comObj = this.comObj;
|
|
55795
|
+
new Promise(function (resolve) {
|
|
55796
|
+
resolve(action(data.data));
|
|
55797
|
+
}).then(function (result) {
|
|
55798
|
+
comObj.postMessage({
|
|
55799
|
+
sourceName,
|
|
55800
|
+
targetName,
|
|
55801
|
+
callback: CallbackKind.DATA,
|
|
55802
|
+
callbackId: data.callbackId,
|
|
55803
|
+
data: result
|
|
55565
55804
|
});
|
|
55566
|
-
|
|
55567
|
-
|
|
55568
|
-
|
|
55569
|
-
|
|
55570
|
-
|
|
55571
|
-
|
|
55572
|
-
|
|
55573
|
-
|
|
55574
|
-
|
|
55805
|
+
}, function (reason) {
|
|
55806
|
+
comObj.postMessage({
|
|
55807
|
+
sourceName,
|
|
55808
|
+
targetName,
|
|
55809
|
+
callback: CallbackKind.ERROR,
|
|
55810
|
+
callbackId: data.callbackId,
|
|
55811
|
+
reason: wrapReason(reason)
|
|
55812
|
+
});
|
|
55813
|
+
});
|
|
55814
|
+
return;
|
|
55815
|
+
}
|
|
55816
|
+
if (data.streamId) {
|
|
55817
|
+
this.#createStreamSink(data);
|
|
55818
|
+
return;
|
|
55819
|
+
}
|
|
55820
|
+
action(data.data);
|
|
55575
55821
|
}
|
|
55576
55822
|
on(actionName, handler) {
|
|
55577
55823
|
const ah = this.actionHandler;
|
|
@@ -55863,7 +56109,8 @@ class MessageHandler {
|
|
|
55863
56109
|
delete this.streamControllers[streamId];
|
|
55864
56110
|
}
|
|
55865
56111
|
destroy() {
|
|
55866
|
-
this
|
|
56112
|
+
this.#messageAC?.abort();
|
|
56113
|
+
this.#messageAC = null;
|
|
55867
56114
|
}
|
|
55868
56115
|
}
|
|
55869
56116
|
|
|
@@ -56033,7 +56280,7 @@ class WorkerMessageHandler {
|
|
|
56033
56280
|
docId,
|
|
56034
56281
|
apiVersion
|
|
56035
56282
|
} = docParams;
|
|
56036
|
-
const workerVersion = "4.
|
|
56283
|
+
const workerVersion = "4.8.69";
|
|
56037
56284
|
if (apiVersion !== workerVersion) {
|
|
56038
56285
|
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
|
|
56039
56286
|
}
|
|
@@ -56113,7 +56360,8 @@ class WorkerMessageHandler {
|
|
|
56113
56360
|
return pdfManagerCapability.promise;
|
|
56114
56361
|
}
|
|
56115
56362
|
let pdfStream,
|
|
56116
|
-
cachedChunks = []
|
|
56363
|
+
cachedChunks = [],
|
|
56364
|
+
loaded = 0;
|
|
56117
56365
|
try {
|
|
56118
56366
|
pdfStream = new PDFWorkerStream(handler);
|
|
56119
56367
|
} catch (ex) {
|
|
@@ -56139,21 +56387,6 @@ class WorkerMessageHandler {
|
|
|
56139
56387
|
pdfManagerCapability.reject(reason);
|
|
56140
56388
|
cancelXHRs = null;
|
|
56141
56389
|
});
|
|
56142
|
-
let loaded = 0;
|
|
56143
|
-
const flushChunks = function () {
|
|
56144
|
-
const pdfFile = arrayBuffersToBytes(cachedChunks);
|
|
56145
|
-
if (length && pdfFile.length !== length) {
|
|
56146
|
-
warn("reported HTTP length is different from actual");
|
|
56147
|
-
}
|
|
56148
|
-
try {
|
|
56149
|
-
pdfManagerArgs.source = pdfFile;
|
|
56150
|
-
newPdfManager = new LocalPdfManager(pdfManagerArgs);
|
|
56151
|
-
pdfManagerCapability.resolve(newPdfManager);
|
|
56152
|
-
} catch (ex) {
|
|
56153
|
-
pdfManagerCapability.reject(ex);
|
|
56154
|
-
}
|
|
56155
|
-
cachedChunks = [];
|
|
56156
|
-
};
|
|
56157
56390
|
new Promise(function (resolve, reject) {
|
|
56158
56391
|
const readChunk = function ({
|
|
56159
56392
|
value,
|
|
@@ -56163,7 +56396,14 @@ class WorkerMessageHandler {
|
|
|
56163
56396
|
ensureNotTerminated();
|
|
56164
56397
|
if (done) {
|
|
56165
56398
|
if (!newPdfManager) {
|
|
56166
|
-
|
|
56399
|
+
const pdfFile = arrayBuffersToBytes(cachedChunks);
|
|
56400
|
+
cachedChunks = [];
|
|
56401
|
+
if (length && pdfFile.length !== length) {
|
|
56402
|
+
warn("reported HTTP length is different from actual");
|
|
56403
|
+
}
|
|
56404
|
+
pdfManagerArgs.source = pdfFile;
|
|
56405
|
+
newPdfManager = new LocalPdfManager(pdfManagerArgs);
|
|
56406
|
+
pdfManagerCapability.resolve(newPdfManager);
|
|
56167
56407
|
}
|
|
56168
56408
|
cancelXHRs = null;
|
|
56169
56409
|
return;
|
|
@@ -56571,9 +56811,7 @@ class WorkerMessageHandler {
|
|
|
56571
56811
|
} else {
|
|
56572
56812
|
clearGlobalCaches();
|
|
56573
56813
|
}
|
|
56574
|
-
|
|
56575
|
-
cancelXHRs(new AbortException("Worker was terminated."));
|
|
56576
|
-
}
|
|
56814
|
+
cancelXHRs?.(new AbortException("Worker was terminated."));
|
|
56577
56815
|
for (const task of WorkerTasks) {
|
|
56578
56816
|
waitOn.push(task.finished);
|
|
56579
56817
|
task.terminate();
|
|
@@ -56604,8 +56842,8 @@ if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" &&
|
|
|
56604
56842
|
|
|
56605
56843
|
;// ./src/pdf.worker.js
|
|
56606
56844
|
|
|
56607
|
-
const pdfjsVersion = "4.
|
|
56608
|
-
const pdfjsBuild = "
|
|
56845
|
+
const pdfjsVersion = "4.8.69";
|
|
56846
|
+
const pdfjsBuild = "3634dab10";
|
|
56609
56847
|
|
|
56610
56848
|
var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
|
|
56611
56849
|
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
|