mozilla/pdf.js · error · FormatError
No shading resource found
Error message
No shading resource found
What it means
FormatError thrown while processing the shadingFill operator when the page/resources dictionary has no 'Shading' entry at all. A shadingFill must reference a shading by name, so the absence of any Shading resource makes the operator unresolvable.
Source
Thrown at src/core/evaluator.js:2130
localShadingPatternCache,
seenRefs
)
);
return;
}
if (!isNumberArray(args, null)) {
continue;
}
args = [cs.getRgbHex(args, 0)];
fn = OPS.setStrokeRGBColor;
break;
case OPS.shadingFill:
let shading;
try {
const shadingRes = resources.get("Shading");
if (!shadingRes) {
throw new FormatError("No shading resource found");
}
shading = shadingRes.get(args[0].name);
if (!shading) {
throw new FormatError("No shading object found");
}
} catch (reason) {
if (reason instanceof AbortException) {
continue;
}
if (self.options.ignoreErrors) {
warn(`getOperatorList - ignoring Shading: "${reason}".`);
continue;
}
throw reason;
}
const patternId = self.parseShading({
shading,View on GitHub (pinned to 5903d58d58)
Solutions
- Enable ignoreErrors: true so the orphan shadingFill is skipped.
- Repair the PDF: add the missing Shading resource dictionary or remove the shadingFill operator.
- Upgrade PDF.js.
Example fix
// before
getDocument({ data }); // shadingFill without Shading resource aborts
// after
getDocument({ data, ignoreErrors: true }); // orphan shadingFill skipped Defensive patterns
Strategy: try-catch
Try / catch
try {
await page.render({ canvasContext, viewport }).promise;
} catch (e) {
if (/No shading resource found/.test(e.message)) {
await reloadWith({ ignoreErrors: true });
} else throw e;
} Prevention
- Enable ignoreErrors for untrusted PDFs.
- Repair PDFs that retain shadingFill after removing the Shading resource.
- Upgrade PDF.js.
When it happens
Trigger: A content stream contains a 'sh' (shadingFill) operator, but resources.get('Shading') returns nothing (no Shading sub-dictionary on this stream/page).
Common situations: Content streams whose resource dictionary was stripped or where shadingFill was left in after the Shading resource was removed; cross-page content reuse with mismatched resources.
Related errors
- No shading object found
- Unknown PatternType: ${typeNum}
- Unknown PatternName: ${patternName}
- 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/aa83e479eee9ece1.
Report an issue: GitHub.