mozilla/pdf.js · error · FormatError
Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})
Error message
Invalid number: ${String.fromCharCode(ch)} (charCode ${ch}) What it means
Error "Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})" thrown in mozilla/pdf.js.
Source
Thrown at src/core/parser.js:1035
if (ch === /* '.' = */ 0x2e) {
divideBy = 10;
ch = this.nextChar();
}
if (ch < /* '0' = */ 0x30 || ch > /* '9' = */ 0x39) {
const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
if (
isWhiteSpace(ch) ||
/* '(' = */ ch === 0x28 ||
/* '<' = */ ch === 0x3c ||
ch === /* EOF = */ -1
) {
// This is consistent with Adobe Reader (fixes issue9252.pdf,
// issue15604.pdf, bug1753983.pdf, bug1953099.pdf).
info(`Lexer.getNumber - "${msg}".`);
return 0;
}
throw new FormatError(msg);
}
let baseValue = ch - 0x30; // '0'
while ((ch = this.nextChar()) >= 0) {
if (ch >= /* '0' = */ 0x30 && ch <= /* '9' = */ 0x39) {
const currentDigit = ch - 0x30; // '0'
if (divideBy !== 0) {
// We are after a point.
divideBy *= 10;
}
baseValue = baseValue * 10 + currentDigit;
} else if (ch === /* '.' = */ 0x2e) {
if (divideBy === 0) {
divideBy = 1;
} else {
// A number can have only one dot.
break;View on GitHub (pinned to 5903d58d58)
Solutions
- Fix the malformed number token in the content stream or PDF object; numbers must contain only digits, an optional sign, and at most one decimal point.
- Regenerate the PDF with a conforming writer if the number was produced by a broken generator.
When it happens
Trigger: Thrown at src/core/parser.js:1035 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/0e670355919849dc.
Report an issue: GitHub.