mozilla/pdf.js · warning · Error

Unsupported pattern kind: ${kind}

Error message

Unsupported pattern kind: ${kind}

What it means

Thrown by the display-layer shading-pattern IR transform when a pattern's `kind` is not one of the recognized kinds (the branch shown returns the 'Mesh' IR; anything else falls through). It indicates the worker produced a pattern intermediate-representation the display layer does not know how to render. This is effectively an unsupported-PDF-feature condition surfaced during rendering.

Source

Thrown at src/display/obj_bin_transform_display.js:426

      if (coords.length > 0) {
        bounds = BBOX_INIT.slice();

        for (let i = 0, ii = coords.length; i < ii; i += 2) {
          Util.pointBoundingBox(coords[i], coords[i + 1], bounds);
        }
      }
      return [
        "Mesh",
        shadingType,
        coords,
        colors,
        nCoord,
        bounds,
        bbox,
        background,
      ];
    }
    throw new Error(`Unsupported pattern kind: ${kind}`);
  }
}

class FontPathInfo {
  #buffer;

  constructor(buffer) {
    this.#buffer = buffer;
  }

  get path() {
    if (
      (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
      FeatureTest.isFloat16ArraySupported
    ) {
      return new Float16Array(this.#buffer);
    }
    return new Float32Array(this.#buffer);

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Ensure the worker build and API build are the same PDF.js version.
  2. Update to the latest PDF.js; newer versions handle more pattern kinds.
  3. Report the PDF to the PDF.js project so the kind can be supported.
  4. Catch render errors per-page so the rest of the document still renders.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await page.render({ canvasContext })?.promise;
} catch (e) {
  if (e.message.startsWith('Unsupported pattern kind')) {
    // unsupported shading in this PDF; skip or render blank
  }
}

Prevention

When it happens

Trigger: A PDF page contains a shading/tiling pattern whose serialized kind tag is not in the handled set; the transform switch falls through to the throw.

Common situations: A rare or malformed shading pattern type; a version skew between pdf.worker and the display layer; a PDF authored by a tool emitting a non-standard pattern kind.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/194b50b2bcfc6487. Report an issue: GitHub.