{"record":{"id":"f53b02eaa87eb651","repo":"mozilla/pdf.js","slug":"unknown-patterntype-typenum","errorCode":null,"errorMessage":"Unknown PatternType: ${typeNum}","messagePattern":"Unknown PatternType: (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":1664,"sourceCode":"            task,\n            localTilingPatternCache,\n            seenRefs\n          );\n        } else if (typeNum === PatternType.SHADING) {\n          const shading = dict.get(\"Shading\");\n          const objId = this.parseShading({\n            shading,\n            resources,\n            localColorSpaceCache,\n            localShadingPatternCache,\n          });\n          if (objId) {\n            const matrix = lookupMatrix(dict.getArray(\"Matrix\"), null);\n            operatorList.addOp(fn, [\"Shading\", objId, matrix]);\n          }\n          return undefined;\n        }\n        throw new FormatError(`Unknown PatternType: ${typeNum}`);\n      }\n    }\n    throw new FormatError(`Unknown PatternName: ${patternName}`);\n  }\n\n  async parseMarkedContentProps(contentProperties, resources) {\n    return parseMarkedContentProps(this.xref, contentProperties, resources);\n  }\n\n  async getOperatorList({\n    stream,\n    task,\n    resources,\n    operatorList,\n    initialState = null,\n    fallbackFontDict = null,\n    prevRefs = null,\n  }) {","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L1646-L1682","documentation":"FormatError thrown by the pattern resolver when a pattern object's PatternType is neither TILING (1) nor SHADING (2) as defined in the PDF spec. It signals a non-standard or corrupt pattern dictionary.","triggerScenarios":"A setFillColorN/setStrokeColorN color operator references a pattern whose resolved dictionary has a PatternType value other than 1 or 2 (e.g. 0, 3, missing, or a non-integer). The error propagates through the color-handling case of getOperatorList; with ignoreErrors true it becomes a warning.","commonSituations":"Malformed PDFs, obscure generators, or PDFs whose pattern dict was truncated. Rare in well-formed documents.","solutions":["Enable ignoreErrors: true so the unknown pattern is skipped and the page renders without it.","Repair the PDF: correct or remove the offending PatternType entry.","Upgrade PDF.js in case newer spec-allowed values are supported."],"exampleFix":"// before\ngetDocument({ data }); // render aborts on unknown PatternType\n\n// after\ngetDocument({ data, ignoreErrors: true }); // pattern skipped, page renders","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  if (/Unknown PatternType/.test(e.message)) {\n    await reloadWith({ ignoreErrors: true }); // unknown pattern skipped\n  } else throw e;\n}","preventionTips":["Render untrusted PDFs with ignoreErrors:true.","Validate incoming PDFs with a repair step (qpdf/ghostscript) before display.","Upgrade PDF.js to pick up new spec-allowed PatternType values."],"tags":["pdf","pattern","color","malformed-pdf","rendering"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}