Color Management

Top Previous Topic Next Topic  Print this topic

Graphics professionals know the importance of color management. No matter how much thought you put into the color scheme for a given project, all of that work is for naught if you can't get your printed results to match your expectations.

 

Each color is encoded as a combination of Red, Green and Blue values. What do these values mean; e.g. what color is 88/249/17? Without any context, it is a meaningless triplet of numbers. This is where color spaces come in.

 

A color space provides the definition for what color the numerical combination represents.

If our example of 88/249/17 is interpreted using the Adobe RGB color space, it is a vibrant, attention getting green. If, on the other hand, the same value is interpreted using the sRGB color space, it is a pale, yellowish-green.

 

                       (88, 249, 17) in Adobe RGB The same RGB value in sRGB

 

RGB Colors

 

By default all colors used in your XSL-FO documents are considered to be given in the sRGB color space.

 

To use RGB colors, you can either specify values for the each component (Red, Green and Blue), or you can specify a color name. XF Rendering Server supports the extended pallete described in the SVG specifications for both SVG and XSL-FO input.

 

The following notations are equivalent:

 

       <fo:block color="red">Red text.</fo:block>

       <fo:block color="rgb(255,0,0)">Red text.</fo:block>

       <fo:block color="rgb(100%,100%,100%)">Red text.</fo:block>

       <fo:block color="#FF0000">Red text.</fo:block>

       <fo:block color="#F00">Red text.</fo:block>

 

The last notation is called a short notation. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00.

 

When generating PDF, all RGB colors are mapped to a predefined PDF color space called DeviceRGB.

 

CMYK Colors

 

You can use an ECRION specific extension to specify colors in CMYK (Cyan,Magenta,Yellow,Black) format:

 

       

       <fo:block color="cmyk(0,100,100,0)">Red text.</fo:block>

 

 

When generating PDF, all CMYK colors specified using this extension are mapped to DeviceCMYK color space.

If you have a CMYK color profile you wish to use, read below.

 

ICC Profiles

 

In addition, the XSL-FO recommendation specifies how to use colors described by an external ICC profile. With accurate monitor and printer profiles, your prints will closely match what you see on your monitor.

 

To declare a color space use fo:color-profile:

 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

   <fo:declarations>

       <fo:color-profile color-profile-name="RGBColorProfile"

                               src="ColorProfiles\RGB\AppleRGB.icc"/>

       <fo:color-profile color-profile-name="CMYKColorProfile"

                       src="ColorProfiles\CMYK\USWebCoatedSWOP.icc"/> (1)

   </fo:declarations>

   <fo:layout-master-set>

       <fo:simple-page-master master-name="all-pages" page-width="8in"

                                                       page-height="11in">

          <fo:region-body region-name="xsl-region-body" column-gap="0.25in"

                       padding-top="6pt" padding-left="6pt" padding-right="6pt"

                       padding-bottom="6pt" margin-top="0.7in" margin-left="0.7in"

                       margin-right="0.7in" margin-bottom="0.7in"/>

          <fo:region-before region-name="xsl-region-before" display-align="after"

                       extent="0.7in"padding-top="6pt" padding-left="0.7in"

                       padding-right="0.7in" padding-bottom="6pt"/>

          <fo:region-after region-name="xsl-region-after" display-align="before"

                       extent="0.7in" padding-top="6pt" padding-left="0.7in"

                       padding-right="0.7in" padding-bottom="6pt"/>

       </fo:simple-page-master>

       <fo:page-sequence-master master-name="default-sequence">

               <fo:repeatable-page-master-reference master-reference="all-pages"/>

       </fo:page-sequence-master>

   </fo:layout-master-set>

   <fo:page-sequence master-reference="default-sequence">

       <fo:flow flow-name="xsl-region-body"font-size="12pt"

                                       font-family="Times New Roman">

          <fo:block background="rgb(255,0,0)">RGB Color</fo:block>

          <fo:block background="rgb-icc(255,0,0,#RGBColorProfile,1,0,0)">

                                                       ICC RGB Color</fo:block> (2)

          <fo:block background="rgb-icc(255,0,0,#CMYKColorProfile,0,1,1,0)">

                                                       ICC CMYK Color</fo:block>

          <fo:block background="rgb(0,255,0)">RGB Color</fo:block>

          <fo:block background="rgb-icc(0,255,0,#RGBColorProfile,0,1,0)">

                                                       ICC RGB Color</fo:block>

          <fo:block background="rgb-icc(0,255,0,#CMYKColorProfile,0.63,0,1,0)">

                                                       ICC CMYK Color</fo:block>

          <fo:block background="rgb(255,0,255)">RGB Color</fo:block>

          <fo:block background="rgb-icc(255,0,255,#RGBColorProfile,1,0,1)">

                                                       ICC RGB Color</fo:block>

          <fo:block background="rgb-icc(255,0,255,#CMYKColorProfile,0.27,0.82,0,0)">

                                                       ICC CMYK Color</fo:block>

       </fo:flow>

   </fo:page-sequence>

</fo:root>

 

 

The important points in this example are:

 

(1) We declare two color spaces, named "RGBColorProfile" and "CMYKColorProfile".

(2) We use rgb-icc function to specify the intensities of each component in this color space. The name of this function is a little misleading, because rgb-icc can be used to describe not only RGB (Red, Green, Blue) colors, but also Grascale, CMYK and spot (Pantone) colors.

 

rgb-icc takes the following arguments:

 

rgb-icc(fallbackRed,fallbackGreen,fallbackBlue,#colorProfileReference,

       component1,..., componentN)

 

First three parameters are used when the color profile can not be found, or when the document is displayed in XF Designer.
The fourth parameter is a reference to a color profile declared with fo:color-profile.
The fifth and next parameters are used to specify the color.

 

If your color profile is a Grayscale color profile, you will use only component1. If you have a RGB color profile, you must use three values, while for a CMYK color profile you must use four values. Each value is a floating point number and must be between 0.00 and 1.00 and represents the intensity of that color.

 

For a CMYK color profile you have to specify all four components.

 

Note:

XF will output an error if the number of components you specify when using rgb-icc does not match the number of colors defined in the color profile.

 

You can also assign color profiles to images and SVG documents using xf:color-profile:

 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"

         xmlns:xf="http://www.ecrion.com/xf/1.0">

...

<fo:block>

<fo:external-graphic src="redsquare.svg" xf:color-profile="#CMYKColorProfile"/>

</fo:block>

 

Note:

xf namespace must be declared; usually this is done as shown above, in the root element.

 

Blending Color Space

 

You may notice that PDF documents that contain transparent RGB images may not print correctly on CMYK printers. This happens because the mathematics of the blending are occurring the color space of the output device. If you are sending in elements in RGB, and the calculation is occurring in CMYK (the default of most printers), you will be getting poor results.

 

To correct this, you can explicitly set the Blending color space by using xf:page-settings element.

 

<xf:page-settings blending-color-space="DeviceNative | DeviceRGB | DeviceCMYK

                   |DeviceGray | custom"/>

 

To use an external ICC profile:

 

<fo:root>

<xf:page-settings blending-color-space="#CustomCMYKProfile"/>

<fo:declarations>

<fo:color-profile color-profile-name="CustomCMYKProfile"

               src="Adobe ICC Profiles\CMYK Profiles\EuroscaleCoated.icc"/>

</fo:declarations>

<fo:layout-master-set>

...

</fo:layout-master-set>

</fo:root>