: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
throw new Error("Transport destroyed");
this.#pageRefCache.set(pageInfo.refStr, pageNumber);
const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
this.#pageCache.set(pageIndex, page);
this.#pagePromises.set(pageIndex, promise);
return Promise.reject(new Error("Invalid pageIndex request."));
return this.messageHandler.sendWithPromise("GetPageIndex", {
getAnnotations(pageIndex, intent) {
return this.messageHandler.sendWithPromise("GetAnnotations", {
return this.#cacheSimpleMethod("GetFieldObjects");
return this.#cacheSimpleMethod("HasJSActions");
getCalculationOrderIds() {
return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
return this.messageHandler.sendWithPromise("GetDestinations", null);
if (typeof id !== "string") {
return Promise.reject(new Error("Invalid destination request."));
return this.messageHandler.sendWithPromise("GetDestination", {
return this.messageHandler.sendWithPromise("GetPageLabels", null);
return this.messageHandler.sendWithPromise("GetPageLayout", null);
return this.messageHandler.sendWithPromise("GetPageMode", null);
return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
return this.messageHandler.sendWithPromise("GetOpenAction", null);
return this.messageHandler.sendWithPromise("GetAttachments", null);
return this.#cacheSimpleMethod("GetDocJSActions");
getPageJSActions(pageIndex) {
return this.messageHandler.sendWithPromise("GetPageJSActions", {
getStructTree(pageIndex) {
return this.messageHandler.sendWithPromise("GetStructTree", {
return this.messageHandler.sendWithPromise("GetOutline", null);
getOptionalContentConfig(renderingIntent) {
return this.#cacheSimpleMethod("GetOptionalContentConfig").then(data => new OptionalContentConfig(data, renderingIntent));
return this.messageHandler.sendWithPromise("GetPermissions", null);
const name = "GetMetadata",
cachedPromise = this.#methodPromises.get(name);
const promise = this.messageHandler.sendWithPromise(name, null).then(results => ({
metadata: results[1] ? new Metadata(results[1]) : null,
contentDispositionFilename: this._fullReader?.filename ?? null,
contentLength: this._fullReader?.contentLength ?? null
this.#methodPromises.set(name, promise);
return this.messageHandler.sendWithPromise("GetMarkInfo", null);
async startCleanup(keepLoadedFonts = false) {
await this.messageHandler.sendWithPromise("Cleanup", null);
for (const page of this.#pageCache.values()) {
const cleanupSuccessful = page.cleanup();
if (!cleanupSuccessful) {
throw new Error(`startCleanup: Page ${page.pageNumber} is currently rendering.`);
this.#methodPromises.clear();
this.filterFactory.destroy(true);
const refStr = ref.gen === 0 ? `${ref.num}R` : `${ref.num}R${ref.gen}`;
return this.#pageRefCache.get(refStr) ?? null;
const INITIAL_DATA = Symbol("INITIAL_DATA");
#objs = Object.create(null);
return this.#objs[objId] ||= {
...Promise.withResolvers(),
get(objId, callback = null) {
const obj = this.#ensureObj(objId);
obj.promise.then(() => callback(obj.data));
const obj = this.#objs[objId];
if (!obj || obj.data === INITIAL_DATA) {
throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
const obj = this.#objs[objId];
return !!obj && obj.data !== INITIAL_DATA;
resolve(objId, data = null) {
const obj = this.#ensureObj(objId);
for (const objId in this.#objs) {
this.#objs = Object.create(null);
for (const objId in this.#objs) {
if (data === INITIAL_DATA) {
#internalRenderTask = null;
constructor(internalRenderTask) {
this.#internalRenderTask = internalRenderTask;
return this.#internalRenderTask.capability.promise;
this.#internalRenderTask.cancel(null, extraDelay);
} = this.#internalRenderTask.operatorList;
} = this.#internalRenderTask;
return separateAnnots.form || separateAnnots.canvas && annotationCanvasMap?.size > 0;
class InternalRenderTask {
static #canvasInUse = new WeakSet();
useRequestAnimationFrame = false,
this.callback = callback;
this.commonObjs = commonObjs;
this.annotationCanvasMap = annotationCanvasMap;
this.operatorListIdx = null;
this.operatorList = operatorList;
this._pageIndex = pageIndex;
this.canvasFactory = canvasFactory;
this.filterFactory = filterFactory;
this.pageColors = pageColors;
this.graphicsReadyCallback = null;
this.graphicsReady = false;
this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
this.capability = Promise.withResolvers();
this.task = new RenderTask(this);
this._cancelBound = this.cancel.bind(this);
this._continueBound = this._continue.bind(this);
this._scheduleNextBound = this._scheduleNext.bind(this);
this._nextBound = this._next.bind(this);
this._canvas = params.canvasContext.canvas;
return this.capability.promise.catch(function () {});
if (InternalRenderTask.#canvasInUse.has(this._canvas)) {
throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
InternalRenderTask.#canvasInUse.add(this._canvas);
if (this._pdfBug && globalThis.StepperManager?.enabled) {
this.stepper = globalThis.StepperManager.create(this._pageIndex);
this.stepper.init(this.operatorList);
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
this.gfx = new CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
}, this.annotationCanvasMap, this.pageColors);
this.operatorListIdx = 0;
this.graphicsReady = true;
this.graphicsReadyCallback?.();
cancel(error = null, extraDelay = 0) {
InternalRenderTask.#canvasInUse.delete(this._canvas);
this.callback(error || new RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, extraDelay));
if (!this.graphicsReady) {
this.graphicsReadyCallback ||= this._continueBound;
this.stepper?.updateOperatorList(this.operatorList);
if (this.task.onContinue) {
this.task.onContinue(this._scheduleNextBound);
if (this._useRequestAnimationFrame) {
window.requestAnimationFrame(() => {
this._nextBound().catch(this._cancelBound);
Promise.resolve().then(this._nextBound).catch(this._cancelBound);
this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
if (this.operatorListIdx === this.operatorList.argsArray.length) {
if (this.operatorList.lastChunk) {
InternalRenderTask.#canvasInUse.delete(this._canvas);
const version = "4.3.136";
const build = "0cec64437";
// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.flat-map.js
var esnext_iterator_flat_map = __webpack_require__(670);
;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
function makeColorComp(n) {
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
function scaleAndClamp(x) {
return Math.max(0, Math.min(255, 255 * x));
static CMYK_G([c, y, m, k]) {
return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
return ["CMYK", 0, 0, 0, 1 - g];
const G = makeColorComp(g);
static RGB_G([r, g, b]) {
return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
return color.map(scaleAndClamp);
return `#${color.map(makeColorComp).join("")}`;
static CMYK_RGB([c, y, m, k]) {
return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
static CMYK_rgb([c, y, m, k]) {
return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];
static CMYK_HTML(components) {
const rgb = this.CMYK_RGB(components).slice(1);
return this.RGB_HTML(rgb);
static RGB_CMYK([r, g, b]) {
const k = Math.min(c, m, y);
return ["CMYK", c, m, y, k];
;// CONCATENATED MODULE: ./src/display/xfa_layer.js
static setupStorage(html, id, element, storage, intent) {
const storedData = storage.getValue(id, {
if (storedData.value !== null) {
html.textContent = storedData.value;
if (intent === "print") {
html.addEventListener("input", event => {
value: event.target.value
if (element.attributes.type === "radio" || element.attributes.type === "checkbox") {
if (storedData.value === element.attributes.xfaOn) {
html.setAttribute("checked", true);
} else if (storedData.value === element.attributes.xfaOff) {
html.removeAttribute("checked");
if (intent === "print") {
html.addEventListener("change", event => {
value: event.target.checked ? event.target.getAttribute("xfaOn") : event.target.getAttribute("xfaOff")
if (storedData.value !== null) {
html.setAttribute("value", storedData.value);
if (intent === "print") {
html.addEventListener("input", event => {
value: event.target.value
if (storedData.value !== null) {
html.setAttribute("value", storedData.value);
for (const option of element.children) {
if (option.attributes.value === storedData.value) {
option.attributes.selected = true;
} else if (option.attributes.hasOwnProperty("selected")) {
delete option.attributes.selected;
html.addEventListener("input", event => {
const options = event.target.options;
const value = options.selectedIndex === -1 ? "" : options[options.selectedIndex].value;
const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
if (attributes.type === "radio") {
attributes.name = `${attributes.name}-${intent}`;
for (const [key, value] of Object.entries(attributes)) {
if (value === null || value === undefined) {