{"record":{"id":"551b74db1418a0f5","repo":"mozilla/pdf.js","slug":"unsupported-paint-type-painttype","errorCode":null,"errorMessage":"Unsupported paint type: ${paintType}","messagePattern":"Unsupported paint type: (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"warning","filePath":"src/display/pattern_helper.js","lineNumber":895,"sourceCode":"  }\n\n  setFillAndStrokeStyleToContext(graphics, paintType, color) {\n    const context = graphics.ctx,\n      current = graphics.current;\n    current.patternFill = current.patternStroke = false;\n    switch (paintType) {\n      case PaintType.COLORED:\n        const { fillStyle, strokeStyle } = this.ctx;\n        context.fillStyle = current.fillColor = fillStyle;\n        context.strokeStyle = current.strokeColor = strokeStyle;\n        break;\n      case PaintType.UNCOLORED:\n        context.fillStyle = context.strokeStyle = color;\n        // Set color needed by image masks (fixes issues 3226 and 8741).\n        current.fillColor = current.strokeColor = color;\n        break;\n      default:\n        throw new FormatError(`Unsupported paint type: ${paintType}`);\n    }\n  }\n\n  isModifyingCurrentTransform() {\n    return false;\n  }\n\n  getPattern(ctx, owner, inverse, pathType, opIdx) {\n    // PDF spec 8.7.2: prepend inverse CTM to patternBaseMatrix to position\n    // the CSS pattern.\n    const matrix =\n      pathType !== PathType.SHADING\n        ? Util.transform(inverse, this.patternBaseMatrix)\n        : inverse;\n\n    const temporaryPatternCanvas = this.createPatternCanvas(owner, opIdx);\n\n    let domMatrix = new DOMMatrix(matrix);","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/display/pattern_helper.js#L877-L913","documentation":"Thrown as a FormatError by TilingPattern when paintType is neither PaintType.COLORED (1) nor PaintType.UNCOLORED (2). It is raised while setting up a tiling pattern's colors, so only the two PDF-spec paint types are valid. Because it is a FormatError (not a plain Error), PDF.js treats it as a recoverable, per-object rendering degradation rather than a fatal crash.","triggerScenarios":"A PDF tiling pattern carries a paintType other than 1 or 2; the pattern setup switch hits the default branch.","commonSituations":"A malformed or non-standard PDF; a pattern stream corrupted in transit; an edge case in a producer tool.","solutions":["Update PDF.js; rendering tolerance improves over releases.","Catch rendering errors per page/object so the rest of the document renders.","Report the PDF to the PDF.js project.","If you control the PDF, regenerate it so patterns use paintType 1 or 2."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext }).promise;\n} catch (e) {\n  if (e instanceof FormatError && /Unsupported paint type/.test(e.message)) {\n    // degrade: continue rendering without this pattern\n  }\n}","preventionTips":["Treat FormatError as recoverable; isolate per-object rendering.","Update PDF.js to benefit from improved rendering tolerance.","Report PDFs whose tiling patterns use unsupported paint types.","If producing PDFs, only emit paintType 1 (COLORED) or 2 (UNCOLORED)."],"tags":["rendering","tiling-pattern","format-error","unsupported-pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}