PDF blend modes

A PDF blend mode is a method to combine 2 colors (source and background) in order to get a new color. XFINIUM.PDF 5.4 bring support for executing the blend modes when rendering a PDF page to image.
The simplest blend mode is Normal, the source color covers the background color. The other blend modes are: Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity.
They are all based on a mathematical formula that combine the color components from the source color and background color in order to generate the result color.

A blend mode is activated in the page content stream by setting a new extended graphics state that includes the desired blend mode. The blend mode is active until a new blend mode is set or the graphics state is restored.

The code above can be simplified and less objects created if the page graphics state is saved before setting the blend mode and then restored when it is no longer needed.

The image below (taken from PDF specification) shows the results of applying the PDF blend modes when creating content.
Blend Modes
PDF blend modes are handled automatically when rendering a page that includes them in its content, there is nothing you need to do in your code.

Leave a Reply