mozilla/pdf.js · error · FormatError
Unknown PatternName: ${patternName}
Error message
Unknown PatternName: ${patternName} What it means
FormatError thrown when a pattern referenced by name cannot be resolved at all: the name is absent from the page/resources Pattern dictionary and xref.fetchIfRef returns nothing. It means the content stream names a pattern that does not exist in the resource chain.
Source
Thrown at src/core/evaluator.js:1667
);
} else if (typeNum === PatternType.SHADING) {
const shading = dict.get("Shading");
const objId = this.parseShading({
shading,
resources,
localColorSpaceCache,
localShadingPatternCache,
});
if (objId) {
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
operatorList.addOp(fn, ["Shading", objId, matrix]);
}
return undefined;
}
throw new FormatError(`Unknown PatternType: ${typeNum}`);
}
}
throw new FormatError(`Unknown PatternName: ${patternName}`);
}
async parseMarkedContentProps(contentProperties, resources) {
return parseMarkedContentProps(this.xref, contentProperties, resources);
}
async getOperatorList({
stream,
task,
resources,
operatorList,
initialState = null,
fallbackFontDict = null,
prevRefs = null,
}) {
if (stream.isAsync) {
const bytes = await stream.asyncGetBytes();
if (bytes) {View on GitHub (pinned to 5903d58d58)
Solutions
- Enable ignoreErrors: true so the missing pattern degrades to a warning.
- Repair the PDF: add the missing Pattern entry or fix the referenced name.
- Verify the resources object passed to getOperatorList is the correct one for that content stream.
Example fix
// before
getDocument({ data }); // render aborts: Unknown PatternName
// after
getDocument({ data, ignoreErrors: true }); // missing pattern skipped Defensive patterns
Strategy: try-catch
Try / catch
try {
await page.render({ canvasContext, viewport }).promise;
} catch (e) {
if (/Unknown PatternName/.test(e.message)) {
await reloadWith({ ignoreErrors: true });
} else throw e;
} Prevention
- Use ignoreErrors:true for untrusted PDFs.
- Repair PDFs whose resource dictionaries reference missing pattern names.
- Log affected pages to identify systematically broken source documents.
When it happens
Trigger: A setFillColorN/setStrokeColorN operator uses a /Pattern color space and names a pattern that is not present in the current resources' Pattern dict (typo, missing entry, or wrong resource scope).
Common situations: PDFs whose resource dictionaries were stripped or merged incorrectly, renamed pattern names, or content streams moved between pages without updating resources.
Related errors
- Unknown PatternType: ${typeNum}
- No shading resource found
- No shading object found
- Unable to decode inline image: "${reason}".
- getOperatorList - ignoring circular reference: ${objId}
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/e48e54439a3a2938.
Report an issue: GitHub.