: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function bytesToString(bytes) {
if (typeof bytes !== "object" || bytes?.length === undefined) {
unreachable("Invalid argument for bytesToString");
const length = bytes.length;
const MAX_ARGUMENT_COUNT = 8192;
if (length < MAX_ARGUMENT_COUNT) {
return String.fromCharCode.apply(null, bytes);
for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
const chunk = bytes.subarray(i, chunkEnd);
strBuf.push(String.fromCharCode.apply(null, chunk));
function stringToBytes(str) {
if (typeof str !== "string") {
unreachable("Invalid argument for stringToBytes");
const length = str.length;
const bytes = new Uint8Array(length);
for (let i = 0; i < length; ++i) {
bytes[i] = str.charCodeAt(i) & 0xff;
function string32(value) {
return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
function objectSize(obj) {
return Object.keys(obj).length;
function objectFromMap(map) {
const obj = Object.create(null);
for (const [key, value] of map) {
function isLittleEndian() {
const buffer8 = new Uint8Array(4);
const view32 = new Uint32Array(buffer8.buffer, 0, 1);
function isEvalSupported() {
static get isLittleEndian() {
return shadow(this, "isLittleEndian", isLittleEndian());
static get isEvalSupported() {
return shadow(this, "isEvalSupported", isEvalSupported());
static get isOffscreenCanvasSupported() {
return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
if (typeof navigator !== "undefined" && typeof navigator?.platform === "string") {
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac")
return shadow(this, "platform", {
static get isCSSRoundSupported() {
return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));
static makeHexColor(r, g, b) {
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
static scaleMinMax(transform, minMax) {
minMax[0] *= transform[0];
minMax[2] *= transform[0];
minMax[1] *= transform[3];
minMax[3] *= transform[3];
minMax[1] *= transform[1];
minMax[3] *= transform[1];
minMax[0] *= transform[2];
minMax[2] *= transform[2];
minMax[0] += transform[4];
minMax[1] += transform[5];
minMax[2] += transform[4];
minMax[3] += transform[5];
static transform(m1, m2) {
return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
static applyTransform(p, m) {
const xt = p[0] * m[0] + p[1] * m[2] + m[4];
const yt = p[0] * m[1] + p[1] * m[3] + m[5];
static applyInverseTransform(p, m) {
const d = m[0] * m[3] - m[1] * m[2];
const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
static getAxialAlignedBoundingBox(r, m) {
const p1 = this.applyTransform(r, m);
const p2 = this.applyTransform(r.slice(2, 4), m);
const p3 = this.applyTransform([r[0], r[3]], m);
const p4 = this.applyTransform([r[2], r[1]], m);
return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
static inverseTransform(m) {
const d = m[0] * m[3] - m[1] * m[2];
return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
static singularValueDecompose2dScale(m) {
const transpose = [m[0], m[2], m[1], m[3]];
const a = m[0] * transpose[0] + m[1] * transpose[2];
const b = m[0] * transpose[1] + m[1] * transpose[3];
const c = m[2] * transpose[0] + m[3] * transpose[2];
const d = m[2] * transpose[1] + m[3] * transpose[3];
const first = (a + d) / 2;
const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
const sx = first + second || 1;
const sy = first - second || 1;
return [Math.sqrt(sx), Math.sqrt(sy)];
static normalizeRect(rect) {
static intersect(rect1, rect2) {
const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
return [xLow, yLow, xHigh, yHigh];
static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
minMax[0] = Math.min(minMax[0], x);
minMax[1] = Math.min(minMax[1], y);
minMax[2] = Math.max(minMax[2], x);
minMax[3] = Math.max(minMax[3], y);
static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
if (Math.abs(a) < 1e-12) {
if (Math.abs(b) >= 1e-12) {
this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
const delta = b ** 2 - 4 * c * a;
const sqrtDelta = Math.sqrt(delta);
this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
minMax[0] = Math.min(minMax[0], x0, x3);
minMax[1] = Math.min(minMax[1], y0, y3);
minMax[2] = Math.max(minMax[2], x0, x3);
minMax[3] = Math.max(minMax[3], y0, y3);
minMax = [Math.min(x0, x3), Math.min(y0, y3), Math.max(x0, x3), Math.max(y0, y3)];
this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
function stringToPDFString(str) {
if (str[0] === "\xFE" && str[1] === "\xFF") {
if (str.length % 2 === 1) {
} else if (str[0] === "\xFF" && str[1] === "\xFE") {
if (str.length % 2 === 1) {
} else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
const decoder = new TextDecoder(encoding, {
const buffer = stringToBytes(str);
const decoded = decoder.decode(buffer);
if (!decoded.includes("\x1b")) {
return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
warn(`stringToPDFString: "${ex}".`);
for (let i = 0, ii = str.length; i < ii; i++) {
const charCode = str.charCodeAt(i);
while (++i < ii && str.charCodeAt(i) !== 0x1b) {}
const code = PDFStringTranslateTable[charCode];
strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
function stringToUTF8String(str) {
return decodeURIComponent(escape(str));
function utf8StringToString(str) {
return unescape(encodeURIComponent(str));
function isArrayEqual(arr1, arr2) {
if (arr1.length !== arr2.length) {
for (let i = 0, ii = arr1.length; i < ii; i++) {
if (arr1[i] !== arr2[i]) {
function getModificationDate(date = new Date()) {
const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
let NormalizeRegex = null;
let NormalizationMap = null;
function normalizeUnicode(str) {
NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
NormalizationMap = new Map([["ſt", "ſt"]]);
return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));
if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
return crypto.randomUUID();
const buf = new Uint8Array(32);
if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
crypto.getRandomValues(buf);
for (let i = 0; i < 32; i++) {
buf[i] = Math.floor(Math.random() * 255);
return bytesToString(buf);
const AnnotationPrefix = "pdfjs_internal_id_";
// EXTERNAL MODULE: ./node_modules/core-js/modules/esnext.iterator.every.js
var esnext_iterator_every = __webpack_require__(3215);
;// CONCATENATED MODULE: ./src/core/primitives.js
const CIRCULAR_REF = Symbol("CIRCULAR_REF");
const EOF = Symbol("EOF");
let CmdCache = Object.create(null);
let NameCache = Object.create(null);
let RefCache = Object.create(null);
function clearPrimitiveCaches() {
CmdCache = Object.create(null);
NameCache = Object.create(null);
RefCache = Object.create(null);
return NameCache[name] ||= new Name(name);
return CmdCache[cmd] ||= new Cmd(cmd);
const nonSerializable = function nonSerializableClosure() {
constructor(xref = null) {
this._map = Object.create(null);
this.suppressEncryption = false;
this.__nonSerializable__ = nonSerializable;
return Object.keys(this._map).length;
let value = this._map[key1];
if (value === undefined && key2 !== undefined) {
if (value === undefined && key3 !== undefined) {
if (value instanceof Ref && this.xref) {
return this.xref.fetch(value, this.suppressEncryption);
async getAsync(key1, key2, key3) {
let value = this._map[key1];
if (value === undefined && key2 !== undefined) {
if (value === undefined && key3 !== undefined) {
if (value instanceof Ref && this.xref) {
return this.xref.fetchAsync(value, this.suppressEncryption);
getArray(key1, key2, key3) {
let value = this._map[key1];
if (value === undefined && key2 !== undefined) {
if (value === undefined && key3 !== undefined) {
if (value instanceof Ref && this.xref) {
value = this.xref.fetch(value, this.suppressEncryption);
if (Array.isArray(value)) {
for (let i = 0, ii = value.length; i < ii; i++) {
if (value[i] instanceof Ref && this.xref) {
value[i] = this.xref.fetch(value[i], this.suppressEncryption);
return Object.keys(this._map);
return Object.values(this._map);
return this._map[key] !== undefined;
for (const key in this._map) {
callback(key, this.get(key));
const emptyDict = new Dict(null);
emptyDict.set = (key, value) => {
unreachable("Should not call `set` on the empty dictionary.");
return shadow(this, "empty", emptyDict);
const mergedDict = new Dict(xref),
for (const dict of dictArray) {
if (!(dict instanceof Dict)) {
for (const [key, value] of Object.entries(dict._map)) {
let property = properties.get(key);
if (property === undefined) {
properties.set(key, property);
} else if (!mergeSubDicts || !(value instanceof Dict)) {
for (const [name, values] of properties) {
if (values.length === 1 || !(values[0] instanceof Dict)) {
mergedDict._map[name] = values[0];
const subDict = new Dict(xref);
for (const dict of values) {
for (const [key, value] of Object.entries(dict._map)) {
if (subDict._map[key] === undefined) {
subDict._map[key] = value;