: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
firstDigit = toHexDigit(ch);
secondDigit = toHexDigit(ch);
if (secondDigit === -1) {
strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
isFirstHex = !isFirstHex;
let ch = this.currentChar;
if (ch === 0x0a || ch === 0x0d) {
} else if (ch === 0x25) {
} else if (specialChars[ch] !== 1) {
return this.getHexString();
throw new FormatError(`Illegal character: ${ch}`);
let str = String.fromCharCode(ch);
if (ch < 0x20 || ch > 0x7f) {
const nextCh = this.peekChar();
if (nextCh >= 0x20 && nextCh <= 0x7f) {
const knownCommands = this.knownCommands;
let knownCommandFound = knownCommands?.[str] !== undefined;
while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
const possibleCommand = str + String.fromCharCode(ch);
if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
if (str.length === 128) {
throw new FormatError(`Command token too long: ${str.length}`);
knownCommandFound = knownCommands?.[str] !== undefined;
this.beginInlineImagePos = this.stream.pos;
let ch = this.currentChar;
} else if (ch === 0x0a) {
function getInt(linDict, name, allowZeroValue = false) {
const obj = linDict.get(name);
if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
function getHints(linDict) {
const hints = linDict.get("H");
if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
for (let index = 0; index < hintsLength; index++) {
const hint = hints[index];
if (!(Number.isInteger(hint) && hint > 0)) {
throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
throw new Error("Hint array in the linearization dictionary is invalid.");
const parser = new Parser({
lexer: new Lexer(stream),
const obj1 = parser.getObj();
const obj2 = parser.getObj();
const obj3 = parser.getObj();
const linDict = parser.getObj();
if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && isCmd(obj3, "obj") && linDict instanceof Dict && typeof (obj = linDict.get("Linearized")) === "number" && obj > 0)) {
} else if ((length = getInt(linDict, "L")) !== stream.length) {
throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
hints: getHints(linDict),
objectNumberFirst: getInt(linDict, "O"),
endFirst: getInt(linDict, "E"),
numPages: getInt(linDict, "N"),
mainXRefEntriesOffset: getInt(linDict, "T"),
pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
;// CONCATENATED MODULE: ./src/core/cmap.js
const BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
const MAX_MAP_RANGE = 2 ** 24 - 1;
constructor(builtInCMap = false) {
this.codespaceRanges = [[], [], [], []];
this.numCodespaceRanges = 0;
this.builtInCMap = builtInCMap;
addCodespaceRange(n, low, high) {
this.codespaceRanges[n - 1].push(low, high);
this.numCodespaceRanges++;
mapCidRange(low, high, dstLow) {
if (high - low > MAX_MAP_RANGE) {
throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
this._map[low++] = dstLow++;
mapBfRange(low, high, dstLow) {
if (high - low > MAX_MAP_RANGE) {
throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
const lastByte = dstLow.length - 1;
this._map[low++] = dstLow;
const nextCharCode = dstLow.charCodeAt(lastByte) + 1;
if (nextCharCode > 0xff) {
dstLow = dstLow.substring(0, lastByte - 1) + String.fromCharCode(dstLow.charCodeAt(lastByte - 1) + 1) + "\x00";
dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
mapBfRangeToArray(low, high, array) {
if (high - low > MAX_MAP_RANGE) {
throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
while (low <= high && i < ii) {
this._map[low] = array[i++];
return this._map[code] !== undefined;
const length = map.length;
for (let i = 0; i < length; i++) {
if (map[i] !== undefined) {
if (map.length <= 0x10000) {
return map.indexOf(value);
for (const charCode in map) {
if (map[charCode] === value) {
readCharCode(str, offset, out) {
const codespaceRanges = this.codespaceRanges;
for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
const codespaceRange = codespaceRanges[n];
for (let k = 0, kk = codespaceRange.length; k < kk;) {
const low = codespaceRange[k++];
const high = codespaceRange[k++];
if (c >= low && c <= high) {
getCharCodeLength(charCode) {
const codespaceRanges = this.codespaceRanges;
for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
const codespaceRange = codespaceRanges[n];
for (let k = 0, kk = codespaceRange.length; k < kk;) {
const low = codespaceRange[k++];
const high = codespaceRange[k++];
if (charCode >= low && charCode <= high) {
if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
if (this._map.length !== 0x10000) {
for (let i = 0; i < 0x10000; i++) {
if (this._map[i] !== i) {
class IdentityCMap extends CMap {
constructor(vertical, n) {
this.vertical = vertical;
this.addCodespaceRange(n, 0, 0xffff);
mapCidRange(low, high, dstLow) {
unreachable("should not call mapCidRange");
mapBfRange(low, high, dstLow) {
unreachable("should not call mapBfRange");
mapBfRangeToArray(low, high, array) {
unreachable("should not call mapBfRangeToArray");
unreachable("should not call mapCidOne");
return Number.isInteger(code) && code <= 0xffff ? code : undefined;
return Number.isInteger(code) && code <= 0xffff;
for (let i = 0; i <= 0xffff; i++) {
return Number.isInteger(value) && value <= 0xffff ? value : -1;
const map = new Array(0x10000);
for (let i = 0; i <= 0xffff; i++) {
unreachable("should not access .isIdentityCMap");
for (let i = 0; i < str.length; i++) {
a = a << 8 | str.charCodeAt(i);
function expectString(obj) {
if (typeof obj !== "string") {
throw new FormatError("Malformed CMap: expected string.");
function expectInt(obj) {
if (!Number.isInteger(obj)) {
throw new FormatError("Malformed CMap: expected int.");
function parseBfChar(cMap, lexer) {
let obj = lexer.getObj();
if (isCmd(obj, "endbfchar")) {
const src = strToInt(obj);
function parseBfRange(cMap, lexer) {
let obj = lexer.getObj();
if (isCmd(obj, "endbfrange")) {
const low = strToInt(obj);
const high = strToInt(obj);
if (Number.isInteger(obj) || typeof obj === "string") {
const dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
cMap.mapBfRange(low, high, dstLow);
} else if (isCmd(obj, "[")) {
while (!isCmd(obj, "]") && obj !== EOF) {
cMap.mapBfRangeToArray(low, high, array);
throw new FormatError("Invalid bf range.");
function parseCidChar(cMap, lexer) {
let obj = lexer.getObj();
if (isCmd(obj, "endcidchar")) {
const src = strToInt(obj);
function parseCidRange(cMap, lexer) {
let obj = lexer.getObj();
if (isCmd(obj, "endcidrange")) {
const low = strToInt(obj);
const high = strToInt(obj);
cMap.mapCidRange(low, high, dstLow);
function parseCodespaceRange(cMap, lexer) {
let obj = lexer.getObj();
if (isCmd(obj, "endcodespacerange")) {