mozilla/pdf.js · error · FormatError
Invalid WhitePoint components for ${this.name}, no fallback
Error message
Invalid WhitePoint components for ${this.name}, no fallback available What it means
Thrown by CalGrayCS when the WhitePoint fails spec validation: XW < 0, ZW < 0, or YW !== 1. WhitePoint must be a CIE-relative white with Y normalized to 1; BlackPoint and gamma have fallbacks but WhitePoint does not, so an invalid one is fatal.
Source
Thrown at src/core/colorspace.js:828
* The default color is `new Float32Array([0])`.
*/
class CalGrayCS extends ColorSpace {
constructor(whitePoint, blackPoint, gamma) {
super("CalGray", 1);
if (!whitePoint) {
throw new FormatError(
"WhitePoint missing - required for color space CalGray"
);
}
// Translate arguments to spec variables.
[this.XW, this.YW, this.ZW] = whitePoint;
[this.XB, this.YB, this.ZB] = blackPoint || [0, 0, 0];
this.G = gamma || 1;
// Validate variables as per spec.
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
throw new FormatError(
`Invalid WhitePoint components for ${this.name}, no fallback available`
);
}
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
info(`Invalid BlackPoint for ${this.name}, falling back to default.`);
this.XB = this.YB = this.ZB = 0;
}
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
warn(
`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` +
`ZB: ${this.ZB}, only default values are supported.`
);
}
if (this.G < 1) {
info(View on GitHub (pinned to 5903d58d58)
Solutions
- Repair the PDF so /WhitePoint has non-negative X/Z and Y exactly 1.
- Update pdf.js.
- If you generate PDFs, normalize the white point to Y=1 before writing.
Defensive patterns
Strategy: try-catch
Type guard
function isValidWhitePoint(wp) {
return Array.isArray(wp)
&& wp.length === 3
&& wp[0] >= 0
&& wp[1] === 1
&& wp[2] >= 0;
} Try / catch
try {
cs = ColorSpace.parse(res, xref, cs, pdfFunctionFactory);
} catch (e) {
if (e instanceof FormatError && /Invalid WhitePoint components/.test(e.message)) {
console.warn('Invalid CalGray WhitePoint, falling back', e);
cs = null;
} else throw e;
} Prevention
- When generating /CalGray color spaces, normalize /WhitePoint so Y = 1 and X, Z >= 0.
- Validate untrusted PDFs before rendering.
- Keep pdf.js updated.
- Treat colorspace failures as non-fatal where rendering can proceed.
When it happens
Trigger: A /CalGray /WhitePoint array whose X or Z component is negative, or whose Y component is not exactly 1 (e.g. [0.95, 0.98, 1.08]).
Common situations: Color-managed PDF with a malformed ICC-derived WhitePoint; hand-authored PDF; rounding that left Y != 1.
Related errors
- WhitePoint missing - required for color space CalGray
- Invalid WhitePoint components, no fallback available
- WhitePoint missing - required for color space CalRGB
- WhitePoint missing - required for color space Lab
- IndexedCS - unrecognized lookup table: ${lookup}
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/68ccd1bc22210e0f.
Report an issue: GitHub.