{"record":{"id":"8624262d0a23d04e","repo":"mozilla/pdf.js","slug":"whitepoint-missing-required-for-color-space-calr","errorCode":null,"errorMessage":"WhitePoint missing - required for color space CalRGB","messagePattern":"WhitePoint missing - required for color space CalRGB","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/colorspace.js","lineNumber":942,"sourceCode":"    3.2404542, -1.5371385, -0.4985314,\n    -0.9692660, 1.8760108, 0.0415560,\n    0.0556434, -0.2040259, 1.0572252]);\n\n  static #FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);\n\n  static #tempNormalizeMatrix = new Float32Array(3);\n\n  static #tempConvertMatrix1 = new Float32Array(3);\n\n  static #tempConvertMatrix2 = new Float32Array(3);\n\n  static #DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;\n\n  constructor(whitePoint, blackPoint, gamma, matrix) {\n    super(\"CalRGB\", 3);\n\n    if (!whitePoint) {\n      throw new FormatError(\n        \"WhitePoint missing - required for color space CalRGB\"\n      );\n    }\n    // Translate arguments to spec variables.\n    const [XW, YW, ZW] = (this.whitePoint = whitePoint);\n    const [XB, YB, ZB] = (this.blackPoint = blackPoint || new Float32Array(3));\n\n    [this.GR, this.GG, this.GB] = gamma || new Float32Array([1, 1, 1]);\n    [\n      this.MXA,\n      this.MYA,\n      this.MZA,\n      this.MXB,\n      this.MYB,\n      this.MZB,\n      this.MXC,\n      this.MYC,\n      this.MZC,","sourceCodeStart":924,"sourceCodeEnd":960,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/colorspace.js#L924-L960","documentation":"Thrown by the CalRGBCS constructor when the /WhitePoint array is missing or falsy for a /CalRGB color space. As with CalGray, WhitePoint is mandatory per spec and pdf.js will not guess a default for it.","triggerScenarios":"Constructing CalRGBCS with whitePoint = null/undefined/[], or parsing a PDF /CalRGB dictionary lacking /WhitePoint.","commonSituations":"Corrupt PDF with an incomplete CalRGB dictionary; a faulty PDF writer that omitted the calibration white point.","solutions":["Repair the PDF to include a valid /WhitePoint array (Y normalized to 1).","Update pdf.js."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasWhitePoint(csDict) {\n  const wp = csDict.get('WhitePoint');\n  return Array.isArray(wp) && wp.length === 3;\n}","tryCatchPattern":"try {\n  cs = ColorSpace.parse(res, xref, cs, pdfFunctionFactory);\n} catch (e) {\n  if (e instanceof FormatError && /WhitePoint missing.*CalRGB/.test(e.message)) {\n    console.warn('CalRGB missing WhitePoint, falling back', e);\n    cs = null;\n  } else throw e;\n}","preventionTips":["When generating /CalRGB color spaces, always include /WhitePoint.","Validate untrusted PDFs before rendering.","Keep pdf.js updated.","Fall back to DeviceRGB when CalRGB construction fails."],"tags":["colorspace","calrgb","cie","parsing","pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}