Quantcast
Channel: PDF tips & tricks
Viewing all articles
Browse latest Browse all 125

ICC color profiles and ICC-based colors in PDF

$
0
0

Introduction


In color management, an ICC profile is a specific set of data that defines the color representation of the color reproduction device. Common term for this characteristic is “colorspace”.  Therefore each color reproduction device works with its own colorspace, and the rules used to manipulate colors within each colorspace, or to convert them between colorspaces are described in standards created by the International Color Consortium, hence the name ICC. Examples of well-known colorspaces are: RGB, CMYK, GRAY, LAB and XYZ.

A manufacturer of a color reproduction device may include a color profile along with the device for better color management. You may use these profiles and create PDF files which will include all data needed for reproduction on a selected device. Drawing primitives using colors defined by the ICC profile is possible with Apitron PDF Kit, and we’ll show you how to do it in our code section.

Code sample


Consider the code below. It adds two rectangles to PDF page using same colors from CMYK colorspace. The difference is in the way of defining these colorspaces, in first case we’re using ICC color profile downloaded from Adobe website, and in the second case we rely on default behavior provided by the PDF viewer – by means of the colorspace called DeviceCMYK in PDF specification.

staticvoid Main(string[] args)
{
    using (Stream outputStream = File.Create("icccolors.pdf"))
    {
        using (FixedDocument doc = newFixedDocument())
        {
            // register CMYK profile "US Web Uncoated v2",
            // you can get it from Adobe website
            string profileName = "US Web Uncoated v2";
            doc.ResourceManager.RegisterResource(newICCBasedColorSpace(profileName,
 File.ReadAllBytes("../../data/USWebUncoated.icc")));

            // create and add new page
            Page page = newPage();
            doc.Pages.Add(page);

            // create rectangular shape
            Path rectangle = newPath();
            rectangle.AppendRectangle(10,700,200,100);
                   
            // RECT 1
            // select CMYK colorspace for drawing using loaded color profile
            page.Content.SetNonStrokingColorSpace(profileName);
            page.Content.SetStrokingColorSpace(profileName);

            // select fill and stroke colors
            page.Content.SetNonStrokingColor(newdouble[]{0,1,0,0});
            page.Content.SetStrokingColor(newdouble[]{0,0,0,1});

            // fill and stroke the path
            page.Content.FillAndStrokePath(rectangle);
                   
            //RECT 2
            // select colors using device CMYK colorspace, the viewer will
            // use default CMYK profile for representing these colors
            page.Content.SetDeviceNonStrokingColor(newdouble[] { 0, 1, 0, 0 });
            page.Content.SetDeviceStrokingColor(newdouble[] { 0, 0, 0, 1 });

            // fill and stroke the path again
            page.Content.Translate(0,-120);
            page.Content.FillAndStrokePath(rectangle);
                   
            //save document
            doc.Save(outputStream);
        }
    }
}


Resulting document is shown on the image below (callouts are not the part of the generated document, they were added later for clarification).


Pic. 1 Paths drawn using colors from ICC colorspace and DeviceCMYK colorspace

You may clearly see the difference between the two. In first case we used the profile named “US Web Uncoated V2”, according to information about this profile that can be found on the internet, it is “designed to produce quality separations using U.S. inks under the following printing conditions: 260% total area of ink coverage, negative plate, uncoated white offset stock”.

The second one uses default CMYK color profile that is called DeviceCMYKin PDF specification, it seems that Adobe substitutes the profile named “US Web Coated (SWOP) v2” in this case, but we’re not 100% sure.

Using the correct color profile supplied with color reproduction devices, you may prepare your PDF documents for professional printing and avoid color misrepresentations related to color profile difference.

Conclusion


Using ICC colorprofiles, you may create PDF documents ready for professional printing and reproduction. Apitron PDF Kit for .NET component provides all necessary APIs for achieving this goal. You can download it on our website (link) and try for yourself. Create cross platform applications using our .NET PDF components and enjoy the quality of our software and support services. 


Viewing all articles
Browse latest Browse all 125

Trending Articles