mozilla/pdf.js · warning · FormatError

Invalid style "${style}" in PageLabel dictionary.

Error message

Invalid style "${style}" in PageLabel dictionary.

What it means

Thrown in Catalog.#readPageLabels() (catalog.js:933) when the resolved style name is not one of the recognised values (D, R, r, A, a). After validating /S is a Name, the switch on style falls through to default; if style is non-null there, it is an unsupported/unknown style. Caught and downgraded to a warning by the pageLabels getter.

Source

Thrown at src/core/catalog.js:933

        case "r":
          currentLabel = toRomanNumerals(currentIndex, style === "r");
          break;
        case "A":
        case "a":
          const LIMIT = 26; // Use only the characters A-Z, or a-z.
          const A_UPPER_CASE = 0x41,
            A_LOWER_CASE = 0x61;

          const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
          const letterIndex = currentIndex - 1;
          const character = String.fromCharCode(
            baseCharCode + (letterIndex % LIMIT)
          );
          currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
          break;
        default:
          if (style) {
            throw new FormatError(
              `Invalid style "${style}" in PageLabel dictionary.`
            );
          }
          currentLabel = "";
      }

      pageLabels[i] = prefix + currentLabel;
      currentIndex++;
    }
    return pageLabels;
  }

  get pageLayout() {
    const obj = this.#catDict.get("PageLayout");
    // Purposely use a non-standard default value, rather than 'SinglePage', to
    // allow differentiating between `undefined` and /SinglePage since that does
    // affect the Scroll mode (continuous/non-continuous) used in Adobe Reader.
    let pageLayout = "";

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Accept the null-labels degradation if labels are cosmetic.
  2. Repair the PDF to use a standard /S (/D, /R, /r, /A, /a).
  3. When producing PDFs, use only the five standard label styles.
  4. Check for an updated PDF.js build that may support additional styles.
Defensive patterns

Strategy: fallback

Try / catch

const labels = pdf.pageLabels; // null when style is unsupported
if (!labels) { /* fall back to default numbering */ }

Prevention

When it happens

Trigger: labelDict /S is a Name but its .name is something other than D/R/r/A/a (e.g., /I, /i, or a typo). The switch default branch fires and, because style is truthy, throws. Reached via pdfDocument.pageLabels.

Common situations: A producer using a non-standard or future style name PDF.js does not support; a corrupt label dict; an edited PDF. Non-fatal.

Related errors


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