{"record":{"id":"4ff36422786ecb50","repo":"mozilla/pdf.js","slug":"invalid-prefix-in-pagelabel-dictionary","errorCode":null,"errorMessage":"Invalid prefix in PageLabel dictionary.","messagePattern":"Invalid prefix in PageLabel dictionary\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"warning","filePath":"src/core/catalog.js","lineNumber":892,"sourceCode":"          !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\");\n          if (!(Number.isInteger(st) && st >= 1)) {\n            throw new FormatError(\"Invalid start in PageLabel dictionary.\");\n          }\n          currentIndex = st;\n        } else {\n          currentIndex = 1;\n        }\n      }\n\n      switch (style) {","sourceCodeStart":874,"sourceCodeEnd":910,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/catalog.js#L874-L910","documentation":"Thrown in Catalog.#readPageLabels() (catalog.js:892) when a PageLabel dictionary has a /P (prefix) entry that is not a string. /P, when present, must be a text string used as the label prefix. Caught and downgraded to a warning by the pageLabels getter.","triggerScenarios":"labelDict.get('P') exists but typeof p !== 'string' (e.g., a name, number, or array). Reached while computing pdfDocument.pageLabels.","commonSituations":"A producer that wrote /P as the wrong object type; a corrupt prefix entry. Non-fatal; labels are dropped.","solutions":["Accept the degraded null labels if prefixes are cosmetic.","Repair with qpdf/mutool to remove or fix the /P entry.","When producing PDFs, write /P as a PDF text string.","Treat null pageLabels as 'unavailable' in your application."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const labels = pdf.pageLabels; // null if /P is invalid\nif (!labels) { /* use default numbering */ }","preventionTips":["Handle null labels gracefully.","Repair the PDF to fix /P if prefixes are needed.","Write /P as a PDF text string when producing PDFs.","Do not require prefixes for core functionality."],"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"}