{"record":{"id":"706ca33ef175df4d","repo":"mozilla/pdf.js","slug":"xobject-should-have-a-name-subtype","errorCode":null,"errorMessage":"XObject should have a Name subtype","messagePattern":"XObject should have a Name subtype","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":1799,"sourceCode":"                    localImageCache.getByRef(xobj) ||\n                    self._regionalImageCache.getByRef(xobj) ||\n                    self.globalImageCache.getData(xobj, self.pageIndex);\n                  if (cachedImage) {\n                    addCachedImageOps(operatorList, cachedImage);\n                    resolveXObject();\n                    return;\n                  }\n\n                  xobj = xref.fetch(xobj);\n                }\n\n                if (!(xobj instanceof BaseStream)) {\n                  throw new FormatError(\"XObject should be a stream\");\n                }\n\n                const type = xobj.dict.get(\"Subtype\");\n                if (!(type instanceof Name)) {\n                  throw new FormatError(\"XObject should have a Name subtype\");\n                }\n\n                if (type.name === \"Form\") {\n                  stateManager.save();\n                  self\n                    .buildFormXObject(\n                      resources,\n                      xobj,\n                      null,\n                      operatorList,\n                      task,\n                      stateManager.state.clone({ newPath: true }),\n                      localColorSpaceCache,\n                      seenRefs\n                    )\n                    .then(function () {\n                      stateManager.restore();\n                      resolveXObject();","sourceCodeStart":1781,"sourceCodeEnd":1817,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L1781-L1817","documentation":"FormatError thrown when a valid XObject stream's dict has a 'Subtype' entry that is not a PDF Name. The subtype (Form/Image/PS) must be a Name to be dispatched; any other type is malformed.","triggerScenarios":"An XObject stream whose /Subtype is missing, a string, a number, or an unresolvable reference, so 'type instanceof Name' is false.","commonSituations":"Corrupt XObject dictionaries, missing Subtype entries, or broken indirect refs to the Subtype value.","solutions":["Enable ignoreErrors: true to skip the XObject.","Repair the XObject stream to include a valid /Subtype Name (Form, Image, or PS).","Upgrade PDF.js."],"exampleFix":"// before\ngetDocument({ data }); // XObject without Name Subtype aborts\n\n// after\ngetDocument({ data, ignoreErrors: true }); // bad XObject skipped","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  if (/XObject should have a Name subtype/.test(e.message)) {\n    await reloadWith({ ignoreErrors: true });\n  } else throw e;\n}","preventionTips":["Enable ignoreErrors for untrusted PDFs.","Repair XObject dictionaries missing /Subtype.","Upgrade PDF.js."],"tags":["pdf","xobject","malformed-pdf","rendering"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}