: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
return capability.promise.catch(reason => {
requestRange(begin, end) {
end = Math.min(end, this.length);
const beginChunk = this.getBeginChunk(begin);
const endChunk = this.getEndChunk(end);
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
return this._requestChunks(chunks);
requestRanges(ranges = []) {
const chunksToRequest = [];
for (const range of ranges) {
const beginChunk = this.getBeginChunk(range.begin);
const endChunk = this.getEndChunk(range.end);
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
if (!chunksToRequest.includes(chunk)) {
chunksToRequest.push(chunk);
chunksToRequest.sort(function (a, b) {
return this._requestChunks(chunksToRequest);
const groupedChunks = [];
for (let i = 0, ii = chunks.length; i < ii; ++i) {
if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
if (i + 1 === chunks.length) {
this.msgHandler.send("DocProgress", {
loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
const chunk = args.chunk;
const isProgressive = args.begin === undefined;
const begin = isProgressive ? this.progressiveDataLength : args.begin;
const end = begin + chunk.byteLength;
const beginChunk = Math.floor(begin / this.chunkSize);
const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
this.stream.onReceiveProgressiveData(chunk);
this.progressiveDataLength = end;
this.stream.onReceiveData(begin, chunk);
if (this.stream.isDataLoaded) {
this._loadedStreamCapability.resolve(this.stream);
const loadedRequests = [];
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
const requestIds = this._requestsByChunk.get(curChunk);
this._requestsByChunk.delete(curChunk);
for (const requestId of requestIds) {
const chunksNeeded = this._chunksNeededByRequest.get(requestId);
if (chunksNeeded.has(curChunk)) {
chunksNeeded.delete(curChunk);
if (chunksNeeded.size > 0) {
loadedRequests.push(requestId);
if (!this.disableAutoFetch && this._requestsByChunk.size === 0) {
if (this.stream.numChunksLoaded === 1) {
const lastChunk = this.stream.numChunks - 1;
if (!this.stream.hasChunk(lastChunk)) {
nextEmptyChunk = lastChunk;
nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
if (Number.isInteger(nextEmptyChunk)) {
this._requestChunks([nextEmptyChunk]);
for (const requestId of loadedRequests) {
const capability = this._promisesByRequest.get(requestId);
this._promisesByRequest.delete(requestId);
this.msgHandler.send("DocProgress", {
loaded: this.stream.numChunksLoaded * this.chunkSize,
this._loadedStreamCapability.reject(err);
return Math.floor(begin / this.chunkSize);
return Math.floor((end - 1) / this.chunkSize) + 1;
this.pdfNetworkStream?.cancelAllRequests(reason);
for (const capability of this._promisesByRequest.values()) {
capability.reject(reason);
// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.filter.js
var esnext_iterator_filter = __webpack_require__(4520);
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.regexp.flags.js
var es_regexp_flags = __webpack_require__(9479);
// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.find.js
var esnext_iterator_find = __webpack_require__(2577);
// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.reduce.js
var esnext_iterator_reduce = __webpack_require__(8872);
;// CONCATENATED MODULE: ./src/core/colorspace.js
function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
alpha01 = alpha01 !== 1 ? 0 : alpha01;
const xScaled = new Uint16Array(w2);
const w1Scanline = w1 * COMPONENTS;
for (let i = 0; i < w2; i++) {
xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
for (let i = 0; i < h2; i++) {
const py = Math.floor(i * yRatio) * w1Scanline;
for (let j = 0; j < w2; j++) {
oldIndex = py + xScaled[j];
dest[newIndex++] = src[oldIndex++];
dest[newIndex++] = src[oldIndex++];
dest[newIndex++] = src[oldIndex++];
constructor(name, numComps) {
if (this.constructor === ColorSpace) {
unreachable("Cannot initialize ColorSpace.");
this.numComps = numComps;
const rgb = new Uint8ClampedArray(3);
this.getRgbItem(src, srcOffset, rgb, 0);
getRgbItem(src, srcOffset, dest, destOffset) {
unreachable("Should not call ColorSpace.getRgbItem");
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
unreachable("Should not call ColorSpace.getRgbBuffer");
getOutputLength(inputLength, alpha01) {
unreachable("Should not call ColorSpace.getOutputLength");
isDefaultDecode(decodeMap, bpc) {
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
const count = originalWidth * originalHeight;
const numComponentColors = 1 << bpc;
const needsResizing = originalHeight !== height || originalWidth !== width;
if (this.isPassthrough(bpc)) {
} else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
for (let i = 0; i < numComponentColors; i++) {
const colorMap = new Uint8ClampedArray(numComponentColors * 3);
this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
for (let i = 0; i < count; ++i) {
const key = comps[i] * 3;
dest[destPos++] = colorMap[key];
dest[destPos++] = colorMap[key + 1];
dest[destPos++] = colorMap[key + 2];
rgbBuf = new Uint8Array(count * 3);
for (let i = 0; i < count; ++i) {
const key = comps[i] * 3;
rgbBuf[rgbPos++] = colorMap[key];
rgbBuf[rgbPos++] = colorMap[key + 1];
rgbBuf[rgbPos++] = colorMap[key + 2];
} else if (!needsResizing) {
this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
rgbBuf = new Uint8ClampedArray(count * 3);
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
for (let i = 0, ii = width * actualHeight; i < ii; i++) {
dest[destPos++] = rgbBuf[rgbPos++];
dest[destPos++] = rgbBuf[rgbPos++];
dest[destPos++] = rgbBuf[rgbPos++];
get usesZeroToOneRange() {
return shadow(this, "usesZeroToOneRange", true);
static _cache(cacheKey, xref, localColorSpaceCache, parsedColorSpace) {
if (!localColorSpaceCache) {
throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');
throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');
if (cacheKey instanceof Ref) {
cacheKey = xref.fetch(cacheKey);
if (cacheKey instanceof Name) {
localColorSpaceCache.set(csName, csRef, parsedColorSpace);
static getCached(cacheKey, xref, localColorSpaceCache) {
if (!localColorSpaceCache) {
throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');
if (cacheKey instanceof Ref) {
const localColorSpace = localColorSpaceCache.getByRef(cacheKey);
cacheKey = xref.fetch(cacheKey);
if (ex instanceof MissingDataException) {
if (cacheKey instanceof Name) {
const localColorSpace = localColorSpaceCache.getByName(cacheKey.name);
static async parseAsync({
const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
const cachedColorSpace = this.getCached(cs, xref, localColorSpaceCache);
const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
static _parse(cs, xref, resources = null, pdfFunctionFactory) {
cs = xref.fetchIfRef(cs);
if (cs instanceof Name) {
return this.singletons.gray;
return this.singletons.rgb;
return this.singletons.cmyk;
return new PatternCS(null);
if (resources instanceof Dict) {
const colorSpaces = resources.get("ColorSpace");
if (colorSpaces instanceof Dict) {
const resourcesCS = colorSpaces.get(cs.name);
if (resourcesCS instanceof Name) {
return this._parse(resourcesCS, xref, resources, pdfFunctionFactory);
throw new FormatError(`Unrecognized ColorSpace: ${cs.name}`);
const mode = xref.fetchIfRef(cs[0]).name;
let params, numComps, baseCS, whitePoint, blackPoint, gamma;
return this.singletons.gray;
return this.singletons.rgb;
return this.singletons.cmyk;
params = xref.fetchIfRef(cs[1]);
whitePoint = params.getArray("WhitePoint");
blackPoint = params.getArray("BlackPoint");
gamma = params.get("Gamma");
return new CalGrayCS(whitePoint, blackPoint, gamma);
params = xref.fetchIfRef(cs[1]);
whitePoint = params.getArray("WhitePoint");
blackPoint = params.getArray("BlackPoint");
gamma = params.getArray("Gamma");
const matrix = params.getArray("Matrix");
return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
const stream = xref.fetchIfRef(cs[1]);
const dict = stream.dict;
numComps = dict.get("N");
const alt = dict.get("Alternate");
const altCS = this._parse(alt, xref, resources, pdfFunctionFactory);
if (altCS.numComps === numComps) {
warn("ICCBased color space: Ignoring incorrect /Alternate entry.");
return this.singletons.gray;
} else if (numComps === 3) {
return this.singletons.rgb;
} else if (numComps === 4) {
return this.singletons.cmyk;
baseCS = this._parse(baseCS, xref, resources, pdfFunctionFactory);
return new PatternCS(baseCS);
baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
const hiVal = xref.fetchIfRef(cs[2]) + 1;
const lookup = xref.fetchIfRef(cs[3]);
return new IndexedCS(baseCS, hiVal, lookup);
const name = xref.fetchIfRef(cs[1]);
numComps = Array.isArray(name) ? name.length : 1;
baseCS = this._parse(cs[2], xref, resources, pdfFunctionFactory);
const tintFn = pdfFunctionFactory.create(cs[3]);
return new AlternateCS(numComps, baseCS, tintFn);
params = xref.fetchIfRef(cs[1]);
whitePoint = params.getArray("WhitePoint");
blackPoint = params.getArray("BlackPoint");
const range = params.getArray("Range");
return new LabCS(whitePoint, blackPoint, range);
throw new FormatError(`Unimplemented ColorSpace object: ${mode}`);
throw new FormatError(`Unrecognized ColorSpace object: ${cs}`);
static isDefaultDecode(decode, numComps) {
if (!Array.isArray(decode)) {
if (numComps * 2 !== decode.length) {
warn("The decode map is not the correct length");
for (let i = 0, ii = decode.length; i < ii; i += 2) {
if (decode[i] !== 0 || decode[i + 1] !== 1) {
static get singletons() {
return shadow(this, "singletons", {
return shadow(this, "gray", new DeviceGrayCS());
return shadow(this, "rgb", new DeviceRgbCS());
return shadow(this, "cmyk", new DeviceCmykCS());
class AlternateCS extends ColorSpace {
constructor(numComps, base, tintFn) {
super("Alternate", numComps);
this.tmpBuf = new Float32Array(base.numComps);
getRgbItem(src, srcOffset, dest, destOffset) {
const tmpBuf = this.tmpBuf;
this.tintFn(src, srcOffset, tmpBuf, 0);
this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
const tintFn = this.tintFn;
const scale = 1 / ((1 << bits) - 1);
const baseNumComps = base.numComps;
const usesZeroToOneRange = base.usesZeroToOneRange;
const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
let pos = isPassthrough ? destOffset : 0;
const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);