mozilla/pdf.js · error · FormatError
Invalid WhitePoint components, no fallback available
Error message
Invalid WhitePoint components, no fallback available
What it means
Thrown by LabCS when WhitePoint fails spec validation: XW < 0, ZW < 0, or YW !== 1. The check mirrors CalGray/CalRGB; BlackPoint and Range have fallbacks but WhitePoint does not, so an invalid value is unrecoverable.
Source
Thrown at src/core/colorspace.js:1223
if (!whitePoint) {
throw new FormatError(
"WhitePoint missing - required for color space Lab"
);
}
// Translate args to spec variables
[this.XW, this.YW, this.ZW] = whitePoint;
[this.amin, this.amax, this.bmin, this.bmax] = range || [
-100, 100, -100, 100,
];
// These are here just for completeness - the spec doesn't offer any
// formulas that use BlackPoint in Lab
[this.XB, this.YB, this.ZB] = blackPoint || [0, 0, 0];
// Validate vars as per spec
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
throw new FormatError(
"Invalid WhitePoint components, no fallback available"
);
}
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
info("Invalid BlackPoint, falling back to default");
this.XB = this.YB = this.ZB = 0;
}
if (this.amin > this.amax || this.bmin > this.bmax) {
info("Invalid Range, falling back to defaults");
this.amin = -100;
this.amax = 100;
this.bmin = -100;
this.bmax = 100;
}
}
View on GitHub (pinned to 5903d58d58)
Solutions
- Repair the PDF so /WhitePoint has non-negative X/Z and Y exactly 1.
- Update pdf.js.
- When generating PDFs, normalize WhitePoint to Y=1.
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 Lab WhitePoint, falling back', e);
cs = null;
} else throw e;
} Prevention
- When generating /Lab color spaces, normalize /WhitePoint so Y = 1 and X, Z >= 0.
- Validate untrusted PDFs before rendering.
- Keep pdf.js updated.
- Fall back to a default colorspace when Lab construction fails.
When it happens
Trigger: A /Lab /WhitePoint array with negative X or Z, or whose Y component is not 1.
Common situations: Malformed Lab WhitePoint from a broken color-management pipeline; hand-authored PDF; rounding leaving Y != 1.
Related errors
- Invalid WhitePoint components for ${this.name}, no fallback
- WhitePoint missing - required for color space Lab
- WhitePoint missing - required for color space CalGray
- WhitePoint missing - required for color space CalRGB
- IndexedCS - unrecognized lookup table: ${lookup}
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/07452952199829a8.
Report an issue: GitHub.