{"record":{"id":"733d40f8e4564865","repo":"mozilla/pdf.js","slug":"no-domain-733d40","errorCode":null,"errorMessage":"No domain.","messagePattern":"No domain\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/function.js","lineNumber":348,"sourceCode":"\n      // Prevent the value from becoming NaN as a result\n      // of division by zero (fixes issue6113.pdf).\n      tmpBuf[0] =\n        dmin === dmax\n          ? rmin\n          : rmin + ((v - dmin) * (rmax - rmin)) / (dmax - dmin);\n\n      // call the appropriate function\n      fns[i](tmpBuf, 0, dest, destOffset);\n    };\n  }\n\n  static constructPostScript(factory, fn, dict) {\n    const domain = toNumberArray(dict.getArray(\"Domain\"));\n    const range = toNumberArray(dict.getArray(\"Range\"));\n\n    if (!domain) {\n      throw new FormatError(\"No domain.\");\n    }\n\n    if (!range) {\n      throw new FormatError(\"No range.\");\n    }\n\n    const psCode = fn.getString();\n\n    try {\n      if (factory.useWasm) {\n        const wasmFn = buildPostScriptWasmFunction(psCode, domain, range);\n        if (wasmFn) {\n          return wasmFn; // (src, srcOffset, dest, destOffset) → void\n        }\n      }\n    } catch {}\n\n    warn(\"Failed to compile PostScript function to wasm, falling back to JS\");","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/function.js#L330-L366","documentation":"Thrown by PDFFunction.constructPostScript (FunctionType 4) when the /Domain array is missing or non-numeric. PostScript calculator functions need Domain to know their input dimensionality before the embedded PostScript program can be compiled to JS/Wasm.","triggerScenarios":"A FunctionType 4 stream whose dictionary lacks /Domain or whose Domain is not a clean number array. Reached while rendering shading patterns, transfer functions, or Indexed lookups that embed a PostScript calculator.","commonSituations":"PDFs produced by tools that emit incomplete Type 4 functions, or PostScript functions damaged by a corrupt object stream. Often seen with custom ICC/CalRGB gradients.","solutions":["If authoring Type 4 functions, always set /Domain and /Range as numeric arrays of equal even length.","Validate the PDF in Acrobat and report rendering gaps to pdf.js if Acrobat succeeds.","Catch FormatError and degrade the page render.","Regenerate the PDF with a spec-conformant tool."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function postScriptHasDomain(dict) {\n  const d = dict.getArray?.('Domain');\n  return Array.isArray(d) && d.every(Number.isFinite) && d.length % 2 === 0;\n}","typeGuard":"function isNumericIntervalArray(arr) {\n  return Array.isArray(arr) && arr.length % 2 === 0 &&\n    arr.every(x => typeof x === 'number' && Number.isFinite(x));\n}","tryCatchPattern":"try { await page.render({ canvasContext }).promise; }\ncatch (err) {\n  if (err?.name === 'FormatError' && err.message === 'No domain.') {\n    console.warn('PostScript function missing domain; skipping.');\n  } else throw err;\n}","preventionTips":["Always emit /Domain (and /Range) on Type 4 PostScript functions when generating PDFs.","Validate PDFs with a conformant checker before release.","Wrap per-page rendering in try/catch."],"tags":["pdf","function","postscript","parsing","malformed-pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}