: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
this.transform(...transform);
this.transform(...matrix);
if (this.annotationCanvas) {
this.ctx = this.annotationCanvas.savedCtx;
delete this.annotationCanvas.savedCtx;
delete this.annotationCanvas;
paintImageMaskXObject(img) {
if (!this.contentVisible) {
img = this.getObject(img.data, img);
const glyph = this.processingType3;
if (glyph.compiled === undefined) {
glyph.compiled = compileType3Glyph(img);
const mask = this._createMaskCanvas(img);
const maskCanvas = mask.canvas;
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
paintImageMaskXObjectRepeat(img, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
if (!this.contentVisible) {
img = this.getObject(img.data, img);
const currentTransform = getCurrentTransform(ctx);
ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
const mask = this._createMaskCanvas(img);
ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
for (let i = 0, ii = positions.length; i < ii; i += 2) {
const trans = Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
const [x, y] = Util.applyTransform([0, 0], trans);
ctx.drawImage(mask.canvas, x, y);
paintImageMaskXObjectGroup(images) {
if (!this.contentVisible) {
const fillColor = this.current.fillColor;
const isPatternFill = this.current.patternFill;
for (const image of images) {
const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
const maskCtx = maskCanvas.context;
const img = this.getObject(data, image);
putBinaryImageMask(maskCtx, img);
maskCtx.globalCompositeOperation = "source-in";
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, getCurrentTransformInverse(ctx), PathType.FILL) : fillColor;
maskCtx.fillRect(0, 0, width, height);
ctx.transform(...transform);
drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
paintImageXObject(objId) {
if (!this.contentVisible) {
const imgData = this.getObject(objId);
warn("Dependent image isn't ready yet");
this.paintInlineImageXObject(imgData);
paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
if (!this.contentVisible) {
const imgData = this.getObject(objId);
warn("Dependent image isn't ready yet");
const width = imgData.width;
const height = imgData.height;
for (let i = 0, ii = positions.length; i < ii; i += 2) {
transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
this.paintInlineImageXObjectGroup(imgData, map);
applyTransferMapsToCanvas(ctx) {
if (this.current.transferMaps !== "none") {
ctx.filter = this.current.transferMaps;
ctx.drawImage(ctx.canvas, 0, 0);
applyTransferMapsToBitmap(imgData) {
if (this.current.transferMaps === "none") {
const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
const tmpCtx = tmpCanvas.context;
tmpCtx.filter = this.current.transferMaps;
tmpCtx.drawImage(bitmap, 0, 0);
paintInlineImageXObject(imgData) {
if (!this.contentVisible) {
const width = imgData.width;
const height = imgData.height;
if (filter !== "none" && filter !== "") {
ctx.scale(1 / width, -1 / height);
imgToPaint = this.applyTransferMapsToBitmap(imgData);
} else if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
const tmpCtx = tmpCanvas.context;
putBinaryImageData(tmpCtx, imgData);
imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
const scaled = this._scaleImage(imgToPaint, getCurrentTransformInverse(ctx));
ctx.imageSmoothingEnabled = getImageSmoothingEnabled(getCurrentTransform(ctx), imgData.interpolate);
drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
paintInlineImageXObjectGroup(imgData, map) {
if (!this.contentVisible) {
imgToPaint = imgData.bitmap;
const h = imgData.height;
const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
const tmpCtx = tmpCanvas.context;
putBinaryImageData(tmpCtx, imgData);
imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
for (const entry of map) {
ctx.transform(...entry.transform);
drawImageAtIntegerCoords(ctx, imgToPaint, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
paintSolidColorImageMask() {
if (!this.contentVisible) {
this.ctx.fillRect(0, 0, 1, 1);
markPointProps(tag, properties) {}
beginMarkedContent(tag) {
this.markedContentStack.push({
beginMarkedContentProps(tag, properties) {
this.markedContentStack.push({
visible: this.optionalContentConfig.isVisible(properties)
this.markedContentStack.push({
this.contentVisible = this.isContentVisible();
this.markedContentStack.pop();
this.contentVisible = this.isContentVisible();
const isEmpty = this.current.isEmptyClip();
this.current.updateClipFromPath();
if (this.pendingClip === EO_CLIP) {
this.current.startNewPathAndClipBox(this.current.clipBox);
if (!this._cachedGetSinglePixelWidth) {
const m = getCurrentTransform(this.ctx);
if (m[1] === 0 && m[2] === 0) {
this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
const normX = Math.hypot(m[0], m[2]);
const normY = Math.hypot(m[1], m[3]);
this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;
return this._cachedGetSinglePixelWidth;
if (this._cachedScaleForStroking[0] === -1) {
} = this.ctx.getTransform();
if (b === 0 && c === 0) {
const normX = Math.abs(a);
const normY = Math.abs(d);
scaleX = scaleY = 1 / normX;
const scaledLineWidth = normX * lineWidth;
scaleX = scaleY = scaledLineWidth < 1 ? 1 / scaledLineWidth : 1;
} else if (lineWidth === 0) {
const scaledXLineWidth = normX * lineWidth;
const scaledYLineWidth = normY * lineWidth;
scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;
scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;
const absDet = Math.abs(a * d - b * c);
const normX = Math.hypot(a, b);
const normY = Math.hypot(c, d);
const baseArea = lineWidth * absDet;
scaleX = normY > baseArea ? normY / baseArea : 1;
scaleY = normX > baseArea ? normX / baseArea : 1;
this._cachedScaleForStroking[0] = scaleX;
this._cachedScaleForStroking[1] = scaleY;
return this._cachedScaleForStroking;
rescaleAndStroke(saveRestore) {
const [scaleX, scaleY] = this.getScaleForStroking();
ctx.lineWidth = lineWidth || 1;
if (scaleX === 1 && scaleY === 1) {
const dashes = ctx.getLineDash();
ctx.scale(scaleX, scaleY);
const scale = Math.max(scaleX, scaleY);
ctx.setLineDash(dashes.map(x => x / scale));
ctx.lineDashOffset /= scale;
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
if (!this.markedContentStack[i].visible) {
if (CanvasGraphics.prototype[op] !== undefined) {
CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
;// CONCATENATED MODULE: ./src/display/worker_options.js
class GlobalWorkerOptions {
static get workerPort() {
static set workerPort(val) {
if (!(typeof Worker !== "undefined" && val instanceof Worker) && val !== null) {
throw new Error("Invalid `workerPort` type.");
static set workerSrc(val) {
if (typeof val !== "string") {
throw new Error("Invalid `workerSrc` type.");
;// CONCATENATED MODULE: ./src/shared/message_handler.js
function wrapReason(reason) {
if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
unreachable('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
return new AbortException(reason.message);
case "MissingPDFException":
return new MissingPDFException(reason.message);
case "PasswordException":
return new PasswordException(reason.message, reason.code);
case "UnexpectedResponseException":
return new UnexpectedResponseException(reason.message, reason.status);
case "UnknownErrorException":
return new UnknownErrorException(reason.message, reason.details);
return new UnknownErrorException(reason.message, reason.toString());
constructor(sourceName, targetName, comObj) {
this.sourceName = sourceName;
this.targetName = targetName;
this.streamSinks = Object.create(null);
this.streamControllers = Object.create(null);
this.callbackCapabilities = Object.create(null);
this.actionHandler = Object.create(null);
this._onComObjOnMessage = event => {
if (data.targetName !== this.sourceName) {
this.#processStreamMessage(data);
const callbackId = data.callbackId;
const capability = this.callbackCapabilities[callbackId];
throw new Error(`Cannot resolve callback ${callbackId}`);
delete this.callbackCapabilities[callbackId];
if (data.callback === CallbackKind.DATA) {
capability.resolve(data.data);
} else if (data.callback === CallbackKind.ERROR) {
capability.reject(wrapReason(data.reason));
throw new Error("Unexpected callback case");
const action = this.actionHandler[data.action];
throw new Error(`Unknown action from worker: ${data.action}`);
const cbSourceName = this.sourceName;
const cbTargetName = data.sourceName;
new Promise(function (resolve) {
resolve(action(data.data));
}).then(function (result) {
sourceName: cbSourceName,
targetName: cbTargetName,
callback: CallbackKind.DATA,
callbackId: data.callbackId,
sourceName: cbSourceName,
targetName: cbTargetName,
callback: CallbackKind.ERROR,
callbackId: data.callbackId,
reason: wrapReason(reason)
this.#createStreamSink(data);