: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const length = this.queue.fnArray.length;
this.lastProcessed = (0, this.match.processFn)(this.context, length);
static CHUNK_SIZE = 1000;
static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
constructor(intent = 0, streamSink) {
this._streamSink = streamSink;
this.optimizer = streamSink && !(intent & RenderingIntentFlag.OPLIST) ? new QueueOptimizer(this) : new NullOptimizer(this);
this.dependencies = new Set();
this._resolved = streamSink ? null : Promise.resolve();
set isOffscreenCanvasSupported(value) {
this.optimizer.isOffscreenCanvasSupported = value;
return this.argsArray.length;
return this._resolved || this._streamSink.ready;
return this._totalLength + this.length;
this.optimizer.push(fn, args);
if (this.weight >= OperatorList.CHUNK_SIZE) {
} else if (this.weight >= OperatorList.CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
addImageOps(fn, args, optionalContent) {
if (optionalContent !== undefined) {
this.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
if (optionalContent !== undefined) {
this.addOp(OPS.endMarkedContent, []);
addDependency(dependency) {
if (this.dependencies.has(dependency)) {
this.dependencies.add(dependency);
this.addOp(OPS.dependency, [dependency]);
addDependencies(dependencies) {
for (const dependency of dependencies) {
this.addDependency(dependency);
if (!(opList instanceof OperatorList)) {
warn('addOpList - ignoring invalid "opList" parameter.');
for (const dependency of opList.dependencies) {
this.dependencies.add(dependency);
for (let i = 0, ii = opList.length; i < ii; i++) {
this.addOp(opList.fnArray[i], opList.argsArray[i]);
argsArray: this.argsArray,
for (let i = 0; i < length; i++) {
case OPS.paintInlineImageXObject:
case OPS.paintInlineImageXObjectGroup:
case OPS.paintImageMaskXObject:
const arg = argsArray[i][0];
if (!arg.cached && arg.data?.buffer instanceof ArrayBuffer) {
transfers.push(arg.data.buffer);
flush(lastChunk = false, separateAnnots = null) {
const length = this.length;
this._totalLength += length;
this._streamSink.enqueue({
argsArray: this.argsArray,
this.dependencies.clear();
this.argsArray.length = 0;
;// CONCATENATED MODULE: ./src/core/image.js
function decodeAndClamp(value, addend, coefficient, max) {
value = addend + value * coefficient;
} else if (value > max) {
function resizeImageMask(src, bpc, w1, h1, w2, h2) {
dest = new Uint8Array(length);
dest = new Uint16Array(length);
dest = new Uint32Array(length);
const xScaled = new Uint16Array(w2);
for (i = 0; i < w2; i++) {
xScaled[i] = Math.floor(i * xRatio);
for (i = 0; i < h2; i++) {
py = Math.floor(i * yRatio) * w1Scanline;
for (j = 0; j < w2; j++) {
oldIndex = py + xScaled[j];
dest[newIndex++] = src[oldIndex];
const filter = dict.get("F", "Filter");
if (filter instanceof Name) {
filterName = filter.name;
} else if (Array.isArray(filter)) {
const filterZero = xref.fetchIfRef(filter[0]);
if (filterZero instanceof Name) {
filterName = filterZero.name;
componentsCount: image.numComps,
bitsPerComponent: image.bitsPerComponent
} = JpxImage.parseImageProperties(image.stream));
image.bitsPerComponent = 1;
let width = dict.get("W", "Width");
let height = dict.get("H", "Height");
if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
warn("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
if (width < 1 || height < 1) {
throw new FormatError(`Invalid image width: ${width} or height: ${height}`);
this.interpolate = dict.get("I", "Interpolate");
this.imageMask = dict.get("IM", "ImageMask") || false;
this.matte = dict.get("Matte") || false;
let bitsPerComponent = image.bitsPerComponent;
bitsPerComponent = dict.get("BPC", "BitsPerComponent");
throw new FormatError(`Bits per component missing in image: ${this.imageMask}`);
this.bpc = bitsPerComponent;
let colorSpace = dict.getRaw("CS") || dict.getRaw("ColorSpace");
info("JPX images (which do not require color spaces)");
switch (image.numComps) {
colorSpace = Name.get("DeviceGray");
colorSpace = Name.get("DeviceRGB");
colorSpace = Name.get("DeviceCMYK");
throw new Error(`JPX images with ${image.numComps} color components not supported.`);
this.colorSpace = ColorSpace.parse({
resources: isInline ? res : null,
this.numComps = this.colorSpace.numComps;
this.ignoreColorSpace = jpxDecode && this.colorSpace.name === "Indexed";
this.decode = dict.getArray("D", "Decode");
this.needsDecode = false;
if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
const max = (1 << bitsPerComponent) - 1;
this.decodeCoefficients = [];
const isIndexed = this.colorSpace?.name === "Indexed";
for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
const dmin = this.decode[i];
const dmax = this.decode[i + 1];
this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
this.smask = new PDFImage({
if (mask instanceof BaseStream) {
const maskDict = mask.dict,
imageMask = maskDict.get("IM", "ImageMask");
warn("Ignoring /Mask in image without /ImageMask.");
this.mask = new PDFImage({
static async buildImage({
const smask = image.dict.get("SMask");
const mask = image.dict.get("Mask");
if (smask instanceof BaseStream) {
warn("Unsupported /SMask format.");
if (mask instanceof BaseStream || Array.isArray(mask)) {
warn("Unsupported /Mask format.");
const computedLength = (width + 7 >> 3) * height;
const actualLength = imgArray.byteLength;
const haveFullData = computedLength === actualLength;
if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
} else if (!inverseDecode) {
data = new Uint8Array(imgArray);
data = new Uint8Array(computedLength);
data.fill(0xff, actualLength);
for (i = 0; i < actualLength; i++) {
static async createMask({
isOffscreenCanvasSupported = false
const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128));
if (isSingleOpaquePixel) {
if (isOffscreenCanvasSupported) {
if (ImageResizer.needsToBeResized(width, height)) {
const data = new Uint8ClampedArray(width * height * 4);
convertBlackAndWhiteToRGBA({
return ImageResizer.createImage({
kind: ImageKind.RGBA_32BPP,
const canvas = new OffscreenCanvas(width, height);
const ctx = canvas.getContext("2d");
const imgData = ctx.createImageData(width, height);
convertBlackAndWhiteToRGBA({
ctx.putImageData(imgData, 0, 0);
const bitmap = canvas.transferToImageBitmap();
return this.createRawMask({
return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
return Math.max(this.height, this.smask?.height || 0, this.mask?.height || 0);
const numComps = this.numComps;
const decodeAddends = this.decodeAddends;
const decodeCoefficients = this.decodeCoefficients;
const max = (1 << bpc) - 1;
for (i = 0, ii = buffer.length; i < ii; i++) {
for (i = 0, ii = this.width * this.height; i < ii; i++) {
for (let j = 0; j < numComps; j++) {
buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);