{"record":{"id":"9d1556d4731a6366","repo":"mozilla/pdf.js","slug":"invalid-style-in-pagelabel-dictionary","errorCode":null,"errorMessage":"Invalid style in PageLabel dictionary.","messagePattern":"Invalid style in PageLabel dictionary\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"warning","filePath":"src/core/catalog.js","lineNumber":882,"sourceCode":"    for (let i = 0, ii = this.numPages; i < ii; i++) {\n      const labelDict = nums.get(i);\n\n      if (labelDict !== undefined) {\n        if (!(labelDict instanceof Dict)) {\n          throw new FormatError(\"PageLabel is not a dictionary.\");\n        }\n\n        if (\n          labelDict.has(\"Type\") &&\n          !isName(labelDict.get(\"Type\"), \"PageLabel\")\n        ) {\n          throw new FormatError(\"Invalid type in PageLabel dictionary.\");\n        }\n\n        if (labelDict.has(\"S\")) {\n          const s = labelDict.get(\"S\");\n          if (!(s instanceof Name)) {\n            throw new FormatError(\"Invalid style in PageLabel dictionary.\");\n          }\n          style = s.name;\n        } else {\n          style = null;\n        }\n\n        if (labelDict.has(\"P\")) {\n          const p = labelDict.get(\"P\");\n          if (typeof p !== \"string\") {\n            throw new FormatError(\"Invalid prefix in PageLabel dictionary.\");\n          }\n          prefix = stringToPDFString(p);\n        } else {\n          prefix = \"\";\n        }\n\n        if (labelDict.has(\"St\")) {\n          const st = labelDict.get(\"St\");","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/catalog.js#L864-L900","documentation":"Thrown in Catalog.#readPageLabels() (catalog.js:882) when a PageLabel dictionary has an /S (style) entry that is not a Name. /S, when present, must be one of the Names /D, /R, /r, /A, /a. A non-Name /S is invalid. Caught and downgraded to a warning by the pageLabels getter.","triggerScenarios":"labelDict.get('S') exists but is not a Name instance (e.g., the string 'D' instead of the Name /D). Reached while computing pdfDocument.pageLabels.","commonSituations":"A producer that serialized the style as a literal string instead of a name object; a corrupt/edited label dict. Non-fatal.","solutions":["Rely on the built-in degradation (pageLabels becomes null) if labels are non-critical.","Repair the PDF (qpdf/mutool) to convert /S to a proper name.","When producing PDFs, write /S as a name object: /D, /R, /r, /A, or /a.","Surface 'labels unavailable' in the UI rather than failing the document."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const labels = pdf.pageLabels; // null if /S is invalid\nif (!labels) {\n  // degrade to default numeric labels\n}","preventionTips":["Accept null labels as the degraded state for invalid /S.","Repair the PDF (qpdf/mutool) when styles are required.","Write /S as a name (/D,/R,/r,/A,/a) when producing PDFs.","Keep label display optional in your UX."],"tags":["pdf-structure","catalog","page-labels","corrupt-pdf","validation"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}