: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const domain = toNumberArray(dict.getArray("Domain"));
throw new FormatError("No domain");
const inputSize = domain.length / 2;
throw new FormatError("Bad domain for stiched function");
for (const fn of dict.get("Functions")) {
const bounds = toNumberArray(dict.getArray("Bounds"));
const encode = toNumberArray(dict.getArray("Encode"));
const tmpBuf = new Float32Array(1);
return function constructStichedFn(src, srcOffset, dest, destOffset) {
const clip = function constructStichedFromIRClip(v, min, max) {
const v = clip(src[srcOffset], domain[0], domain[1]);
const length = bounds.length;
for (i = 0; i < length; ++i) {
const rmin = encode[2 * i];
const rmax = encode[2 * i + 1];
tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
fns[i](tmpBuf, 0, dest, destOffset);
static constructPostScript({
const domain = toNumberArray(dict.getArray("Domain"));
const range = toNumberArray(dict.getArray("Range"));
throw new FormatError("No domain.");
throw new FormatError("No range.");
const lexer = new PostScriptLexer(fn);
const parser = new PostScriptParser(lexer);
const code = parser.parse();
if (isEvalSupported && FeatureTest.isEvalSupported) {
const compiled = new PostScriptCompiler().compile(code, domain, range);
return new Function("src", "srcOffset", "dest", "destOffset", compiled);
info("Unable to compile PS function");
const numOutputs = range.length >> 1;
const numInputs = domain.length >> 1;
const evaluator = new PostScriptEvaluator(code);
const cache = Object.create(null);
const MAX_CACHE_SIZE = 2048 * 4;
let cache_available = MAX_CACHE_SIZE;
const tmpBuf = new Float32Array(numInputs);
return function constructPostScriptFn(src, srcOffset, dest, destOffset) {
for (i = 0; i < numInputs; i++) {
value = src[srcOffset + i];
const cachedValue = cache[key];
if (cachedValue !== undefined) {
dest.set(cachedValue, destOffset);
const output = new Float32Array(numOutputs);
const stack = evaluator.execute(input);
const stackIndex = stack.length - numOutputs;
for (i = 0; i < numOutputs; i++) {
value = stack[stackIndex + i];
let bound = range[i * 2];
bound = range[i * 2 + 1];
if (cache_available > 0) {
dest.set(output, destOffset);
function isPDFFunction(v) {
} else if (v instanceof BaseStream) {
return fnDict.has("FunctionType");
static MAX_STACK_SIZE = 100;
constructor(initialStack) {
this.stack = initialStack ? Array.from(initialStack) : [];
if (this.stack.length >= PostScriptStack.MAX_STACK_SIZE) {
throw new Error("PostScript function stack overflow.");
if (this.stack.length <= 0) {
throw new Error("PostScript function stack underflow.");
if (this.stack.length + n >= PostScriptStack.MAX_STACK_SIZE) {
throw new Error("PostScript function stack overflow.");
const stack = this.stack;
for (let i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
this.push(this.stack[this.stack.length - n - 1]);
const stack = this.stack;
const l = stack.length - n;
const r = stack.length - 1;
const c = l + (p - Math.floor(p / n) * n);
for (let i = l, j = r; i < j; i++, j--) {
for (let i = l, j = c - 1; i < j; i++, j--) {
for (let i = c, j = r; i < j; i++, j--) {
class PostScriptEvaluator {
this.operators = operators;
const stack = new PostScriptStack(initialStack);
const operators = this.operators;
const length = operators.length;
while (counter < length) {
operator = operators[counter++];
if (typeof operator === "number") {
if (typeof a === "boolean" && typeof b === "boolean") {
a = Math.atan2(a, b) / Math.PI * 180;
stack.push(Math.ceil(a));
stack.push(Math.cos(a % 360 / 180 * Math.PI));
stack.push(Math.floor(a));
stack.push(Math.log10(a));
if (typeof a === "boolean") {
if (typeof a === "boolean" && typeof b === "boolean") {
stack.push(Math.round(a));
stack.push(Math.sin(a % 360 / 180 * Math.PI));
stack.push(Math.sqrt(a));
a = a < 0 ? Math.ceil(a) : Math.floor(a);
if (typeof a === "boolean" && typeof b === "boolean") {
throw new FormatError(`Unknown operator ${operator}`);
unreachable("abstract method");
class AstArgument extends AstNode {
constructor(index, min, max) {
visitor.visitArgument(this);
class AstLiteral extends AstNode {
visitor.visitLiteral(this);
class AstBinaryOperation extends AstNode {
constructor(op, arg1, arg2, min, max) {
visitor.visitBinaryOperation(this);
class AstMin extends AstNode {
class AstVariable extends AstNode {
constructor(index, min, max) {
visitor.visitVariable(this);
class AstVariableDefinition extends AstNode {
constructor(variable, arg) {
this.variable = variable;
visitor.visitVariableDefinition(this);
class ExpressionBuilderVisitor {
this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
visitVariable(variable) {
this.parts.push("v", variable.index);