Adobe PDF Library

Getting PDF Documents Using Color Spaces

Adobe PDF Library provides several different samples that show you how to define different kinds of color spaces for use with PDF file output.  Each of these Color Space sample programs generates a PDF file with the words “Hello World!” but with different colors.

We can see thousands of different shades of colors, and high-quality digital cameras and scanners can often detect millions of shades.  To manage the broad range of colors for producing graphics images in digital content, imaging professionals have developed models to define these colors, called color spaces.

Many color spaces have been defined.  Some are dependent on hardware devices, and define what a camera can detect, or a printer print, or a monitor display. Others are based on software and thus can be used across many different kinds of devices, such as Adobe RGB or sRGB (standard RGB).  A color space must be defined for any device or software product in order to make sure that coloring patterns remain the same from one device or system to another.

The first color space created was the CIE XYZ color space, developed in 1931 by the International Commission on Illumination.  It is intended to describe all of the shades of color that can be detected by the human eye, and is used as the basis for other color spaces.

The Standard RGB color space, sRGB, was developed by Microsoft and Hewlett Packard to describe colors available on most monitors and other displays.  This color space is also commonly used for web graphics.

Adobe Systems’ own Adobe RGB (Red/Green/Blue) color space is designed to hold all of the colors that are likely to be available on any color CMYK (Cyan/Magenta/Yellow/Black) printer.  It is considerably larger than Standard RGB.

These sample programs are each designed to work with a different color space.

  1. CALGrayColorSpace
  2. CALRGBColorSpace
  3. DeviceNColorSpace
  4. ICCBasedColorSpace
  5. IndexedColorSpace
  6. L*a*b*ColorSpace
  7. SeparationColorSpace


View Sample Code

The Calibrated Gray Space (CALGray) is based on the CIE color space.  “A” represents the gray component.


View Sample Code

The Calibrated RGB Color Space (CALRGB) is based on the CIE color space.  A, B, and C represent red, blue, and green color values.


View Sample Code

Adobe Systems introduced DeviceN with PDF 1.3 to allow systems to combine color channels for composite printing, such as drawing colors from the Pantone Hexachrome color system.  N refers to a channel definition of color, where N can be an integer from 1 to 16, and is defined in terms of a colorant for each channel. The DeviceN allows for printing with an arbitrary number of color components, and thus it can use a wider range of colors.


View Sample Code

This program works with the ICC Color Space, developed by the International Color Consortium (ICC) in 1993 to work across all operating systems and software packages. The ICC standard is usually built into the software that drives the printer, scanner, camera, or computer hardware; if a device does not have an operating system (like an inexpensive scanner or printer) the color standard is defined in the software used to edit the graphics file.  The ICC color standard applies regardless the hardware involved.


View Sample Code

Indexed Color Spaces are used to reduce the amount of system memory used for processing images when a limited number of colors are needed.  Often graphics images store the color information for each pixel within the pixel itself.  So for a standard CMYK graphic, the image file would need four bytes per pixel to describe the color for that pixel.  If the graphic has 4,000 pixels, the image requires 16,000 bytes per storage.  But what if an image only needed a palette of 256 colors, and those colors were stored in a table?  Each pixel in the image could have a tag (one byte) that defines which color entry in the table to use for that pixel.  So the table would need four bytes per color in the table, 4 x 256 or 1,024 bytes, plus one bye for the address byte in each pixel, another 4,000 bytes, or 5,024 bytes total.  By using an indexed color space, this image would be one third the size of the same image with a standard color space.  The Indexed Color Space is a way to compress an image without losing resolution, making it faster to display and transfer content.


View Sample Code

The Lab color space is based on the CIE XYZ color space, but it includes a dimension L, for lightness, along with a and b coordinates, to define the color.


View Sample Code

Color separation is part of high volume offset printing processing.  The original digital content is color separated to create a set of plates for printing, generally one plate per page for each of the primary colors, cyan, magenta, yellow, and black. During printing each color layer is printed separately, one on top of the other, blended together to create the depth and variety of color in the final images.

Use a Separation color space to define the colors used in offset printing.  Each color is specified by a single numeric value (0.0 to 1.0).