mozilla/pdf.js · error · FormatError

PostScript function: unexpected '${tok.value}' operator.

Error message

PostScript function: unexpected '${tok.value}' operator.

What it means

Error "PostScript function: unexpected '${tok.value}' operator." thrown in mozilla/pdf.js.

Source

Thrown at src/core/postscript/ast.js:309

            this._expect(TOKEN.ifelse);
            instructions.push(new PsIfElse(thenBlock, elseBlock));
          } else {
            throw new FormatError(
              "PostScript function: a procedure block must be followed by 'if' or '{…} ifelse'."
            );
          }
          break;
        }

        case TOKEN.rbrace:
        case TOKEN.eof:
          // End of this block; let the caller consume the '}'.
          return new PsBlock(instructions);

        case TOKEN.if:
        case TOKEN.ifelse:
          // 'if'/'ifelse' without a preceding block.
          throw new FormatError(
            `PostScript function: unexpected '${tok.value}' operator.`
          );

        default:
          if (Parser._isRegularOperator(tok.id)) {
            instructions.push(new PsOperator(tok.id));
            this._advance();
            break;
          }
          throw new FormatError(
            `PostScript function: unexpected token id ${tok.id}.`
          );
      }
    }
  }
}

/**

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Remove the unsupported operator from the Type 4 calculator function; only the PostScript operators allowed by the PDF spec (arithmetic, stack, boolean, conditional) may be used.

When it happens

Trigger: Thrown at src/core/postscript/ast.js:309 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/0aff0df0c82fc52c. Report an issue: GitHub.