: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const substitutionMap = new Map([["Times-Roman", {
local: ["Times New Roman", "Times-Roman", "Times", "Liberation Serif", "Nimbus Roman", "Nimbus Roman L", "Tinos", "Thorndale", "TeX Gyre Termes", "FreeSerif", "Linux Libertine O", "Libertinus Serif", "DejaVu Serif", "Bitstream Vera Serif", "Ubuntu"],
}], ["Times-BoldItalic", {
local: ["Helvetica", "Helvetica Neue", "Arial", "Arial Nova", "Liberation Sans", "Arimo", "Nimbus Sans", "Nimbus Sans L", "A030", "TeX Gyre Heros", "FreeSans", "DejaVu Sans", "Albany", "Bitstream Vera Sans", "Arial Unicode MS", "Microsoft Sans Serif", "Apple Symbols", "Cantarell"],
path: "LiberationSans-Regular.ttf",
path: "LiberationSans-Bold.ttf",
}], ["Helvetica-Oblique", {
path: "LiberationSans-Italic.ttf",
}], ["Helvetica-BoldOblique", {
path: "LiberationSans-BoldItalic.ttf",
local: ["Courier", "Courier New", "Liberation Mono", "Nimbus Mono", "Nimbus Mono L", "Cousine", "Cumberland", "TeX Gyre Cursor", "FreeMono", "Linux Libertine Mono O", "Libertinus Mono"],
}], ["Courier-Oblique", {
}], ["Courier-BoldOblique", {
fallback: "Helvetica-Bold"
}], ["ArialBlack-Bold", {
}], ["ArialBlack-Italic", {
fallback: "Helvetica-BoldOblique"
}], ["ArialBlack-BoldItalic", {
alias: "ArialBlack-Italic"
local: ["Arial Narrow", "Liberation Sans Narrow", "Helvetica Condensed", "Nimbus Sans Narrow", "TeX Gyre Heros Cn"],
}], ["ArialNarrow-Bold", {
fallback: "Helvetica-Bold"
}], ["ArialNarrow-Italic", {
fallback: "Helvetica-Oblique"
}], ["ArialNarrow-BoldItalic", {
fallback: "Helvetica-BoldOblique"
local: ["Calibri", "Carlito"],
fallback: "Helvetica-Bold"
fallback: "Helvetica-Oblique"
}], ["Calibri-BoldItalic", {
fallback: "Helvetica-BoldOblique"
local: ["Wingdings", "URW Dingbats"],
}], ["Wingdings-Regular", {
const fontAliases = new Map([["Arial-Black", "ArialBlack"]]);
function getStyleToAppend(style) {
if (style?.weight === "bold") {
if (style?.style === "italic") {
function getFamilyName(str) {
const keywords = new Set(["thin", "extralight", "ultralight", "demilight", "semilight", "light", "book", "regular", "normal", "medium", "demibold", "semibold", "bold", "extrabold", "ultrabold", "black", "heavy", "extrablack", "ultrablack", "roman", "italic", "oblique", "ultracondensed", "extracondensed", "condensed", "semicondensed", "normal", "semiexpanded", "expanded", "extraexpanded", "ultraexpanded", "bolditalic"]);
return str.split(/[- ,+]+/g).filter(tok => !keywords.has(tok.toLowerCase())).join(" ");
}, src, localFontPath, useFallback = true, usePath = true, append = "") {
const extra = append ? ` ${append}` : "";
for (const name of local) {
src.push(`local(${name}${extra})`);
const substitution = substitutionMap.get(alias);
const aliasAppend = append || getStyleToAppend(style);
Object.assign(result, generateFont(substitution, src, localFontPath, useFallback && !fallback, usePath && !path, aliasAppend));
result.ultimate = ultimate;
if (useFallback && fallback) {
const fallbackInfo = substitutionMap.get(fallback);
ultimate: fallbackUltimate
} = generateFont(fallbackInfo, src, localFontPath, useFallback, usePath && !path, append);
result.ultimate ||= fallbackUltimate;
if (usePath && path && localFontPath) {
src.push(`url(${localFontPath}${path})`);
function getFontSubstitution(systemFontCache, idFactory, localFontPath, baseFontName, standardFontName, type) {
if (baseFontName.startsWith("InvalidPDFjsFont_")) {
if ((type === "TrueType" || type === "Type1") && /^[A-Z]{6}\+/.test(baseFontName)) {
baseFontName = baseFontName.slice(7);
baseFontName = normalizeFontName(baseFontName);
const key = baseFontName;
let substitutionInfo = systemFontCache.get(key);
let substitution = substitutionMap.get(baseFontName);
for (const [alias, subst] of fontAliases) {
if (baseFontName.startsWith(alias)) {
baseFontName = `${subst}${baseFontName.substring(alias.length)}`;
substitution = substitutionMap.get(baseFontName);
let mustAddBaseFont = false;
substitution = substitutionMap.get(standardFontName);
const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`;
if (!validateFontName(baseFontName)) {
warn(`Cannot substitute the font because of its name: ${baseFontName}`);
systemFontCache.set(key, null);
const bold = /bold/gi.test(baseFontName);
const italic = /oblique|italic/gi.test(baseFontName);
const style = bold && italic && BOLDITALIC || bold && BOLD || italic && ITALIC || NORMAL;
css: `"${getFamilyName(baseFontName)}",${loadedName}`,
src: `local(${baseFontName})`,
systemFontCache.set(key, substitutionInfo);
if (mustAddBaseFont && validateFontName(baseFontName)) {
src.push(`local(${baseFontName})`);
} = generateFont(substitution, src, localFontPath);
const guessFallback = ultimate === null;
const fallback = guessFallback ? "" : `,${ultimate}`;
css: `"${getFamilyName(baseFontName)}",${loadedName}${fallback}`,
systemFontCache.set(key, substitutionInfo);
;// CONCATENATED MODULE: ./src/core/image_resizer.js
const MIN_IMAGE_DIM = 2048;
const MAX_IMAGE_DIM = 65537;
constructor(imgData, isMask) {
static needsToBeResized(width, height) {
if (width <= this._goodSquareLength && height <= this._goodSquareLength) {
if (width > MAX_DIM || height > MAX_DIM) {
const area = width * height;
return area > this.MAX_AREA;
if (area < this._goodSquareLength ** 2) {
if (this._areGoodDims(width, height)) {
this._goodSquareLength = Math.max(this._goodSquareLength, Math.floor(Math.sqrt(width * height)));
this._goodSquareLength = this._guessMax(this._goodSquareLength, MAX_DIM, MAX_ERROR, 0);
const maxArea = this.MAX_AREA = this._goodSquareLength ** 2;
return shadow(this, "MAX_DIM", this._guessMax(MIN_IMAGE_DIM, MAX_IMAGE_DIM, 0, 1));
return shadow(this, "MAX_AREA", this._guessMax(ImageResizer._goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2);
static set MAX_AREA(area) {
shadow(this, "MAX_AREA", area);
static setMaxArea(area) {
this.MAX_AREA = area >> 2;
static _areGoodDims(width, height) {
const canvas = new OffscreenCanvas(width, height);
const ctx = canvas.getContext("2d");
ctx.fillRect(0, 0, 1, 1);
const opacity = ctx.getImageData(0, 0, 1, 1).data[3];
canvas.width = canvas.height = 1;
static _guessMax(start, end, tolerance, defaultHeight) {
while (start + tolerance + 1 < end) {
const middle = Math.floor((start + end) / 2);
const height = defaultHeight || middle;
if (this._areGoodDims(middle, height)) {
static async createImage(imgData, isMask = false) {
return new ImageResizer(imgData, isMask)._createImage();
const data = this._encodeBMP();
const blob = new Blob([data.buffer], {
const bitmapPromise = createImageBitmap(blob);
const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(width * height / MAX_AREA));
const firstFactor = Math.max(minFactor, 2);
const factor = Math.round(10 * (minFactor + 1.25)) / 10 / firstFactor;
const N = Math.floor(Math.log2(factor));
const steps = new Array(N + 2).fill(2);
steps.splice(-1, 1, factor / (1 << N));
let bitmap = await bitmapPromise;
for (const step of steps) {
const prevWidth = newWidth;
const prevHeight = newHeight;
newWidth = Math.floor(newWidth / step) - 1;
newHeight = Math.floor(newHeight / step) - 1;
const canvas = new OffscreenCanvas(newWidth, newHeight);
const ctx = canvas.getContext("2d");
ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
bitmap = canvas.transferToImageBitmap();
imgData.width = newWidth;
imgData.height = newHeight;
let data = this._imgData.data;
let colorTable = new Uint8Array(0);
let maskTable = colorTable;
case ImageKind.GRAYSCALE_1BPP:
colorTable = new Uint8Array(this._isMask ? [255, 255, 255, 255, 0, 0, 0, 0] : [0, 0, 0, 0, 255, 255, 255, 255]);
const rowLen = width + 7 >> 3;
const rowSize = rowLen + 3 & -4;
if (rowLen !== rowSize) {
const newData = new Uint8Array(rowSize * height);
for (let i = 0, ii = height * rowLen; i < ii; i += rowLen, k += rowSize) {
newData.set(data.subarray(i, i + rowLen), k);
case ImageKind.RGB_24BPP:
const rowLen = 3 * width;
const rowSize = rowLen + 3 & -4;
const extraLen = rowSize - rowLen;
const newData = new Uint8Array(rowSize * height);
for (let i = 0, ii = height * rowLen; i < ii; i += rowLen) {
const row = data.subarray(i, i + rowLen);
for (let j = 0; j < rowLen; j += 3) {
newData[k++] = row[j + 2];
newData[k++] = row[j + 1];
for (let i = 0, ii = data.length; i < ii; i += 3) {
case ImageKind.RGBA_32BPP:
maskTable = new Uint8Array(4 + 4 + 4 + 4 + 52);
const view = new DataView(maskTable.buffer);
if (FeatureTest.isLittleEndian) {
view.setUint32(0, 0x000000ff, true);
view.setUint32(4, 0x0000ff00, true);
view.setUint32(8, 0x00ff0000, true);
view.setUint32(12, 0xff000000, true);
view.setUint32(0, 0xff000000, true);
view.setUint32(4, 0x00ff0000, true);
view.setUint32(8, 0x0000ff00, true);
view.setUint32(12, 0x000000ff, true);
throw new Error("invalid format");
const headerLength = 40 + maskTable.length;
const fileLength = 14 + headerLength + colorTable.length + data.length;
const bmpData = new Uint8Array(fileLength);
const view = new DataView(bmpData.buffer);
view.setUint16(i, 0x4d42, true);
view.setUint32(i, fileLength, true);
view.setUint32(i, 0, true);
view.setUint32(i, 14 + headerLength + colorTable.length, true);
view.setUint32(i, headerLength, true);
view.setInt32(i, width, true);
view.setInt32(i, -height, true);
view.setUint16(i, 1, true);
view.setUint16(i, bitPerPixel, true);
view.setUint32(i, compression, true);
view.setUint32(i, 0, true);
view.setInt32(i, 0, true);
view.setInt32(i, 0, true);
view.setUint32(i, colorTable.length / 4, true);
view.setUint32(i, 0, true);
bmpData.set(maskTable, i);
bmpData.set(colorTable, i);
ImageResizer._goodSquareLength = MIN_IMAGE_DIM;