{"record":{"id":"0ca46fe5d10776c0","repo":"mozilla/pdf.js","slug":"no-domain","errorCode":null,"errorMessage":"No domain","messagePattern":"No domain","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/function.js","lineNumber":294,"sourceCode":"    for (let i = 0, ii = c0.length; i < ii; ++i) {\n      diff.push(c1[i] - c0[i]);\n    }\n    const length = diff.length;\n\n    return function constructInterpolatedFn(src, srcOffset, dest, destOffset) {\n      const x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;\n\n      for (let j = 0; j < length; ++j) {\n        dest[destOffset + j] = c0[j] + x * diff[j];\n      }\n    };\n  }\n\n  static constructStiched(factory, dict) {\n    const domain = toNumberArray(dict.getArray(\"Domain\"));\n\n    if (!domain) {\n      throw new FormatError(\"No domain\");\n    }\n\n    const inputSize = domain.length / 2;\n    if (inputSize !== 1) {\n      throw new FormatError(\"Bad domain for stiched function\");\n    }\n    const { xref } = factory;\n\n    const fns = [];\n    for (const fn of dict.get(\"Functions\")) {\n      fns.push(this.parse(factory, xref.fetchIfRef(fn)));\n    }\n\n    const bounds = toNumberArray(dict.getArray(\"Bounds\"));\n    const encode = toNumberArray(dict.getArray(\"Encode\"));\n    const tmpBuf = new Float32Array(1);\n\n    return function constructStichedFn(src, srcOffset, dest, destOffset) {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/function.js#L276-L312","documentation":"Thrown by PDFFunction.constructStiched (FunctionType 3) when the /Domain array is missing or non-numeric. A stitching function combines several sub-functions over a single input dimension, so Domain is mandatory to define the input range.","triggerScenarios":"A FunctionType 3 dictionary lacking /Domain (or whose Domain is not a number array) is encountered while rendering a shading pattern, gradient, or Indexed color space lookup that uses stitching.","commonSituations":"Malformed PDFs from buggy generators, or PDFs whose stitching function was truncated during a copy/merge operation. Commonly surfaces in multi-stop gradient fills.","solutions":["Verify the PDF renders in Acrobat; if yes, file a pdf.js issue with the file.","When authoring stitching functions, always provide /Domain as exactly one input interval, e.g. [0 1].","Wrap render in try/catch and degrade for the affected page.","Use qpdf/mutool to repair the file's xref/object stream before re-rendering."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function stitchingHasDomain(dict) {\n  const d = dict.getArray?.('Domain');\n  return Array.isArray(d) && d.every(Number.isFinite);\n}","typeGuard":"function isValidStitchingDomain(arr) {\n  return Array.isArray(arr) && arr.length === 2 &&\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('Stitching function missing domain; skipping shading.');\n  } else throw err;\n}","preventionTips":["Always set /Domain on Type 3 stitching functions during PDF generation.","Validate PDFs with qpdf/mutool before distribution.","Wrap rendering per-page so a single bad gradient is non-fatal."],"tags":["pdf","function","stitching","parsing","malformed-pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}