Skip to Content

PDDocColorConvertPage and de-calibration

Estimated Reading Time: 2 Minutes

A single PDF document can support a wide variety of elements using different color models. Often a PDF file is produced and saved with elements in the DeviceRGB, DeviceCMYK and DeviceGray spaces that have an associated ICC profile. An element (such as a graphic image) in a PDF that has an associated profile is considered calibrated. In this case the image has its own input profile.

Elements that do not have embedded profiles are considered un-calibrated. PDF processing software products, such as Datalogics PDF2IMG, often assign default profiles (referred to as working profiles) to un-calibrated elements within a PDF document. Graphics files, however, such as PNG, TIF, or JPG, can only hold a single color profile.

You can de-callibrate colors in a PDF document, or remove color profiles from elements that document. That way, the color profiles used when printing or rendering that PDF document will default to the profiles provided on the printer or other hardware used.

In Adobe Acrobat, you would use the Convert Colors feature. Select Tools, Print Production, and Convert Colors. Then, with the Convert Command set to “Convert to Profile,” select the Conversion Profile you want and check the “Embed” checkbox. To calibrate the PDF document, select the Embed checkbox, and the color profile will be embedded in the PDF document.

To decallibrate, uncheck the Embed checkbox.

You can also use the Adobe PDF Library to decalibrate PDFs, and in the same way as the Acrobat Convert Colors feature, but the effort requires more than just specifying decalibrate in the method called PDColorConvertActionRecEx on the call to PDDocColorConvertPage(). You must also remove default profiles from the page tree and Resources dictionary in that PDF document.

Code Sample:

void RemoveDefaultFromResource (CosObj Object)

     {
 if ((CosObjGetType (Object) != CosDict) && (CosObjGetType (Object) != CosStream))
        return;

     CosObj Resource = CosDictGet (Object, ASAtomFromString ("Resources"));

 if (CosObjGetType (Resource) != CosDict)
        return;

 if (CosDictKnown (Resource, ASAtomFromString ("ColorSpace")))

          {
          CosObj Spaces = CosDictGet (Resource, ASAtomFromString ("ColorSpace"));

 if (CosDictKnown (Spaces, ASAtomFromString ("DefaultRGB")))
             CosDictRemove (Spaces, ASAtomFromString ("DefaultRGB"));

 if (CosDictKnown (Spaces, ASAtomFromString ("DefaultCMYK")))
             CosDictRemove (Spaces, ASAtomFromString ("DefaultCMYK"));

 if (CosDictKnown (Spaces, ASAtomFromString ("DefaultGray")))
             CosDictRemove (Spaces, ASAtomFromString ("DefaultGray"));
          }
     }

void RemoveDefaultFromPageTree (CosObj Tree)

     {
     RemoveDefaultFromResource (Tree);
 if (CosDictKnown (Tree, ASAtomFromString ("Kids")))

          {
          CosObj Kids = CosDictGet (Tree, ASAtomFromString ("Kids"));
          for (int index = 0; index < CosArrayLength (Kids); index++)
            RemoveDefaultFromPageTree (CosArrayGet (Kids, index));
          }
 return;
     } 

ASBool RemoveDefaultFromXObject (CosObj obj, CosObj value, void *clientData)
     {
 if (CosObjGetType (obj) != CosStream)
        return (true);

 if (CosDictKnown (obj, ASAtomFromString ("Resources")))
        RemoveDefaultFromResource (obj);

 return (true);
     }

 void RemoveDefaultColorsFromDoc (PDDoc doc)

     {
     CosDoc cosDoc = PDDocGetCosDoc (doc);
     CosObj PageTree = CosDictGet (CosDocGetRoot (cosDoc), ASAtomFromString ("Pages"));
     RemoveDefaultFromPageTree (PageTree);
     PDDocEnumResources (doc, 0, PDDocGetNumPages (doc)-1, ASAtomFromString ("XObject"), RemoveDefaultFromXObject, NULL);
 return;
     }

RemoveDefaultColorsFromDoc (pdfDoc);
PDDocColorConvertPage and de-calibration
  • COMMENT