mozilla/pdf.js · warning · FormatError

Invalid start in PageLabel dictionary.

Error message

Invalid start in PageLabel dictionary.

What it means

Thrown in Catalog.#readPageLabels() (catalog.js:902) when a PageLabel dictionary has an /St (start) entry that is not a positive integer (>= 1). /St sets the starting page number for a label range. Caught and downgraded to a warning by the pageLabels getter.

Source

Thrown at src/core/catalog.js:902

          style = s.name;
        } else {
          style = null;
        }

        if (labelDict.has("P")) {
          const p = labelDict.get("P");
          if (typeof p !== "string") {
            throw new FormatError("Invalid prefix in PageLabel dictionary.");
          }
          prefix = stringToPDFString(p);
        } else {
          prefix = "";
        }

        if (labelDict.has("St")) {
          const st = labelDict.get("St");
          if (!(Number.isInteger(st) && st >= 1)) {
            throw new FormatError("Invalid start in PageLabel dictionary.");
          }
          currentIndex = st;
        } else {
          currentIndex = 1;
        }
      }

      switch (style) {
        case "D":
          currentLabel = currentIndex;
          break;
        case "R":
        case "r":
          currentLabel = toRomanNumerals(currentIndex, style === "r");
          break;
        case "A":
        case "a":
          const LIMIT = 26; // Use only the characters A-Z, or a-z.

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Accept null pageLabels (the built-in degradation) if labels are non-essential.
  2. Repair the PDF with qpdf/mutool to set a valid /St >= 1 (or omit it to default to 1).
  3. When producing PDFs, write /St as an integer >= 1, or omit it.
  4. Handle missing labels gracefully in the UI.
Defensive patterns

Strategy: fallback

Try / catch

const labels = pdf.pageLabels; // null if /St invalid
if (!labels) { /* default numeric labels */ }

Prevention

When it happens

Trigger: labelDict.get('St') exists but fails Number.isInteger(st) && st >= 1 (e.g., 0, a negative, a float, or a non-number). Reached while computing pdfDocument.pageLabels.

Common situations: A producer that wrote /St as 0 or a float; a corrupt start value; an edited PDF. Non-fatal.

Related errors


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