Skip to content

Blend modes (ExtGState BM) are ignored: every mark composites as Normal #138

Open

Description

@tannevaled

The renderer does not read the BM entry of an ExtGState at all: nothing in the package mentions it. Every mark is composited with Normal, whatever the document asks for.

PDF 32000-1:2008 §11.3.5 defines the separable modes (Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion) and the non-separable ones (Hue, Saturation, Color, Luminosity). BM may also be an array, in which case the first mode the reader recognises is used (§11.6.3).

Effect

Pages that use blend modes render with the wrong colours. Examples are highlighter-style annotation appearances drawn with Multiply, and designed documents that use Screen or Overlay. poppler, MuPDF and pdf.js all honour BM.

Suggested scope

  1. Parse BM (name or array) into the graphics state.
  2. Implement the separable modes in the compositing step.
  3. Add the non-separable modes.
  4. Check against poppler on a corpus page per mode.

Found while designing PDF to SVG output for go-pdfkit/bentogap (SVG mix-blend-mode would carry it).

Prior art: priorart "blend mode BM" at 2026-11-22 11:17 CET reported prior art; checked: priorart 'blend mode BM': only loose matches (#111, #3, #21); git grep finds no BM in the package

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions