mozilla/pdf.js · warning · FormatError
Page count is not an integer.
Error message
Page count is not an integer.
What it means
FormatError thrown inside checkHeader / numPages validation when the resolved numPages (from linearization.numPages or catalog.numPages) is not an integer. The surrounding try/catch clears caches and triggers recovery, so end-user impact is usually degraded performance rather than a hard failure. It indicates the page count entry in the linearization dict or catalog Pages /Count is corrupt.
Source
Thrown at src/core/document.js:1772
let numPages;
try {
await Promise.all([
pdfManager.ensureDoc("xfaFactory"),
pdfManager.ensureDoc("linearization"),
pdfManager.ensureCatalog("numPages"),
]);
if (this.xfaFactory) {
return; // The Page count is always calculated for XFA-documents.
} else if (this.linearization) {
numPages = this.linearization.numPages;
} else {
numPages = catalog.numPages;
}
if (!Number.isInteger(numPages)) {
throw new FormatError("Page count is not an integer.");
} else if (numPages <= 1) {
return;
}
await this.getPage(numPages - 1);
} catch (reason) {
// Clear out the various caches to ensure that we haven't stored any
// inconsistent and/or incorrect state, since that could easily break
// subsequent `this.getPage` calls.
this.#pagePromises.delete(numPages - 1);
await this.cleanup();
if (reason instanceof XRefEntryException && !recoveryMode) {
throw new XRefParseException();
}
warn(`checkLastPage - invalid /Pages tree /Count: ${numPages}.`);
let pagesTree;
try {View on GitHub (pinned to 5903d58d58)
Solutions
- Repair with qpdf --check / --fix or Acrobat Save As.
- Re-generate the PDF with a conformant producer.
- If you observe degraded page-count detection, accept the recovery and log for follow-up.
Defensive patterns
Strategy: fallback
Prevention
- Repair the PDF (qpdf --check / Acrobat Save As) when this warning recurs.
- Treat recurrence as a producer bug—log the file origin for follow-up.
- Do not over-react; the surrounding recovery clears caches and re-derives the page count.
When it happens
Trigger: A linearization dict whose /N is fractional or missing; a catalog whose /Pages /Count is non-numeric; a corrupt PDF where the Pages tree root has no integer Count.
Common situations: Truncated or hand-edited PDFs; buggy producers that omit /Count; partial downloads.
Related errors
- The Linearization dictionary doesn't point to a valid Page d
- Catalog object is not a dictionary.
- Invalid top-level pages dictionary.
- Page count in top-level pages dictionary is not an integer.
- PageLabel is not a dictionary.
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/6b7d1ed032c9209c.
Report an issue: GitHub.