PDF Transparency Model

The PDF transparency model defines how overlapping translucent objects are composited — how their colours and opacities combine to produce the final rendered result. It is based on the PDF/X compositing algebra: each object has an opacity (alpha), a blend mode, and an associated colour space, and they are combined using the Porter-Duff compositing rules extended for PDF blending modes.

PDF's transparency model, introduced in PDF 1.4 (2001), defines how transparent and semi-transparent graphical objects are composited together to produce a final visual result. Before PDF 1.4, PDF was strictly opaque — every object either fully painted over what was beneath it or was invisible. Transparency enabled the full range of modern graphic design effects: semi-transparent overlays, soft shadows, glows, blending modes, and complex multi-layer compositions.

The transparency model is specified in the PDF specification as a superset of the <a href="https://www.w3.org/TR/compositing/" target="_blank" rel="noopener">Porter-Duff compositing algebra</a>, extended with additional blend modes originally defined by Photoshop. The same compositing rules are used in CSS (<code>mix-blend-mode</code>), SVG, HTML canvas, and other web standards — PDF transparency and web transparency are based on the same underlying mathematics.

PDF transparency is architecturally complex: it requires PDF generators to manage transparency groups, soft masks, and blend modes correctly, and requires PDF viewers to implement a multi-pass rendering algorithm. This complexity is why many PDF transparency issues arise and why some simple PDF viewers don't support full transparency.

Alpha compositing and the basic compositing formula

The fundamental operation in PDF transparency is alpha compositing: combining a source object (the object being painted) with a backdrop (everything already rendered beneath it) using their respective alpha values to produce a result colour.

The basic Porter-Duff "source over backdrop" formula:

<code>result_colour = alpha_source × colour_source + (1 - alpha_source) × colour_backdrop</code> <code>result_alpha = alpha_source + (1 - alpha_source) × alpha_backdrop</code>

Where alpha values are in [0.0, 1.0] — 0.0 is fully transparent, 1.0 is fully opaque.

In PDF, there are two alpha parameters in the graphics state: <strong>ca</strong> (constant alpha for non-stroke painting — fill, images, text) and <strong>CA</strong> (constant alpha for stroke painting). These are set via an ExtGState dictionary and the <code>gs</code> operator.

The compositing also depends on the blend mode (see below) and the soft mask (a per-pixel alpha mask). The full compositing formula in PDF is more complex than the basic source-over — it accounts for: the blend mode's colour calculation; the source alpha; the source constant alpha (ca/CA); and the soft mask alpha at each pixel.

<strong>Knockout vs. non-isolated groups</strong> — Within a transparency group (see below), objects may be composited in "knockout" mode (each object composites against the initial group backdrop, ignoring earlier objects in the group — like Photoshop's "clear layer" behaviour) or "non-knockout" mode (each object composites against the accumulated result of earlier objects in the group). This distinction produces significantly different visual results for overlapping semi-transparent objects.

Blend modes

PDF defines 16 blend modes that control how a source colour is mixed with the backdrop colour during compositing. These are the same blend modes as CSS <code>mix-blend-mode</code> and Photoshop's layer blending:

<strong>Normal group (separable)</strong>: - <strong>Normal</strong>: Source colour replaces backdrop (modulated by alpha). The default. - <strong>Multiply</strong>: Multiplies source and backdrop colour components. Darkens — white is identity. Used for shadows, darkening. - <strong>Screen</strong>: Complements of the products of the complements. Lightens — black is identity. Used for glows, lightening. - <strong>Overlay</strong>: Multiply or Screen depending on backdrop luminance. Increases contrast. - <strong>Darken</strong>: Takes the darker of source and backdrop at each component. - <strong>Lighten</strong>: Takes the lighter of source and backdrop at each component. - <strong>ColorDodge</strong>: Divides backdrop by complement of source. Extreme lightening. - <strong>ColorBurn</strong>: Inverse of ColorDodge. Extreme darkening. - <strong>HardLight</strong>: Overlay with source/backdrop swapped. - <strong>SoftLight</strong>: Softer version of HardLight. - <strong>Difference</strong>: Absolute difference of source and backdrop. White inverts. - <strong>Exclusion</strong>: Similar to Difference but lower contrast.

<strong>Non-separable blend modes</strong> (operate on the full colour, not component-by-component): - <strong>Hue</strong>: Source hue with backdrop saturation and luminance. - <strong>Saturation</strong>: Source saturation with backdrop hue and luminance. - <strong>Color</strong>: Source hue and saturation with backdrop luminance. Useful for colorising. - <strong>Luminosity</strong>: Source luminance with backdrop hue and saturation. Inverse of Color.

Blend modes are set via the BM key in an ExtGState dictionary: <code>/BM /Multiply</code>.

Transparency groups and soft masks

<strong>Transparency groups</strong> — A transparency group is a Form XObject with a /Group dictionary that specifies how its contents are composited. Objects within the group are first composited against each other in an isolated buffer (if the group is isolated — /I true), then the group's composited result is composited against the underlying page content.

Transparency groups are essential for correct rendering of complex layered graphics: a Photoshop document exported to PDF uses transparency groups to preserve Photoshop's layer structure. Without transparency groups, semi-transparent objects that overlap within the group would be composited multiple times with the page background, producing incorrect colour blending.

The two key parameters of a transparency group: - <strong>Isolated</strong> (/I true/false): If true, the group's initial backdrop is transparent (fully clear); objects composite against each other without the page showing through initially. If false, the page shows through as the initial backdrop. - <strong>Knockout</strong> (/K true/false): If true, each object in the group knocks out earlier objects (composites against the initial group backdrop rather than the accumulated result).

<strong>Soft masks</strong> — A soft mask is a per-pixel alpha mask used in compositing, where each pixel of the mask defines a separate alpha value for compositing at that pixel position. Soft masks enable: smooth-edged shadows with gradient alpha; vignette effects; complex image compositing where the mask shape is determined by another image.

A soft mask is specified in the ExtGState dictionary's SMask key. The mask can be derived from the alpha channel of a Form XObject (type Luminosity or Alpha) that is rendered just to compute the per-pixel mask values.

<strong>PDF transparency and PDF/A</strong> — PDF/A-1 prohibits transparency (no transparent objects). PDF/A-2 and PDF/A-3 permit transparency but require that documents using transparency specify an output intent (see <a href="https://pdftheguide.com/glossary/pdf-output-intent" target="_blank" rel="noopener">PDF Output Intent</a>) for consistent colour rendering.

Frequently asked questions

What is the Porter-Duff compositing model and what does it have to do with PDF?

The Porter-Duff compositing model was published by Thomas Porter and Tom Duff in 1984 in a paper "Compositing Digital Images". It defined 12 operations for compositing two images with alpha channels (source over, source in, source out, etc.). The "source over" operation — painting source on top of backdrop, modulated by alpha — is the basis of virtually all alpha compositing in digital graphics today, including PDF, CSS, SVG, and HTML canvas. PDF's transparency model extends Porter-Duff with Photoshop-derived blend modes. When CSS uses mix-blend-mode: multiply and PDF uses blend mode Multiply, they are implementing the same Porter-Duff extended compositing formula — which is why design software like Figma can export to PDF with accurate transparency rendering.

What is transparency flattening and when is it needed?

Transparency flattening is the process of converting a PDF containing transparent objects into an equivalent PDF where all objects are opaque. The flattener resolves all transparency interactions by rasterising regions where transparent objects overlap and replacing them with opaque pixels, while leaving non-overlapping regions as vector objects. Flattening is needed when: (1) sending a PDF to a PostScript printer or PostScript RIP that doesn't support PDF transparency; (2) converting to PDF/A-1 (which prohibits transparency); (3) certain legacy workflows that require opaque PDFs. Flattening has drawbacks: text in flattened regions may be rasterised (lowering quality and making it non-searchable); the file size typically increases; and the process is irreversible. Modern print workflows avoid flattening by using PDF-native printing workflows.

How does PDF transparency affect PDF/A archiving?

PDF/A-1 (ISO 19005-1) explicitly prohibits transparency — no transparent objects, no soft masks, no blend modes other than Normal. PDF/A-2 and PDF/A-3 permit transparency, but with additional requirements: an output intent must be specified (to ensure consistent colour rendering of transparent compositing across different output devices), and the blending colour space must be specified. If you need to archive a PDF with transparency as PDF/A-1, transparency must be flattened first. If archiving as PDF/A-2 or PDF/A-3, transparency can be preserved — but the PDF must specify an output intent (typically an ICC profile for the intended output device). See PDF Output Intent for details.