Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Fine tuning PDF image color with ICC profiles

1 min read

Colour can be a complicated topic in PDF because not only can you have lots of different types of color in PDF (Lab, RGB, CMYK, etc), but you can even have different types of RGB and CMYK. This article is part explanation of how color can work in a PDF file and part tutorial on some tweaks you can use to improve display. Thank-you to Random House USA for permission to use their file.

Color can generally be defined using an ICC colorspace file. This is a standard format devised by the ICC who have a website at the appropriately named site If you are seriously interested in Color, they have lots of resources.

In Java you can load an ICC colorspace very easily with the code. This code example shows how you could setup a Colorspace using an ICC example. ICC colorspaces can match different types of Colorspace (so they are either compatible with CMYK or RGB or GRAY or Lab – you cannot create an RGB colorspace with a CMYK ICC profile). You can also use a Color profile( ends .pf) to create a Colorspace with the same code.

String profile="path to RGB icc file";
ColorSpace rgbCS=null;
   rgbCS=new ICC_ColorSpace(ICC_Profile.getInstance(new

Now let us have a look at an example file…

Here is a PDF page in Adobe Acrobat 9.0

This page contains a single image which is encoded using a variation on a CYMK colorspace called a YCCK colorspace.

This is where Color gets complicated because there are different ways to convert YCCK to CMYK – a fast approximate formula and a more accurate, slower way using a YCC color profile and a CMY color profile (K is unchanged so does not need translation). By default we us the fast approximate way in our Java PDF viewer. Here is the same page.


Not bad but the colors are a little brighter than in the original. So lets use a profile conversion (in our PDF viewer we have a JVM option to set the 2 profiles needed for the conversion (-Dorg.jpedal.useICC=”YCC=/Users/markee/colorprofiles/, CMY=/Users/markee/colorprofiles/” ).

It is closer but still clear differences. This is because we convert images into sRGB in Java (and there are different versions of RGB). It turns out Adobe is using a variation of RGB and a close match is CIERGB (the icc file is available to download from their site). So let us use CIERGB instead or sRGB. In our viewer we set the flag -Dorg.jpedal.RGBprofile=/Users/markee/Downloads/CIERGB.icc

That looks better! Let’s see a montage of sRGB (left), Adobe (middle), and CIERGB (right).

So there you are – lots of really nice screenshots showing what differences you can get in colors by using different techniques/profiles. What profiles do you recommend?

This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!

Can we help you to solve any of these problems?

IDRsolutions has been helping companies to solve these problems since 1999.

Convert PDF to HTML5 or SVG with BuildVuConvert PDF to HTML5 or SVGConvert AcroForms and XFA to HTML5 with FormVuConvert PDF forms to HTML5
Java Image SDK for working with Image files with JDeliJava SDK for Image files JPedal Java PDF SDK for working with PDF filesJava SDK for PDF files
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2021. All rights reserved.