Q:
How can I remove ICC color profiles from an exsiting PDF document? The
CKYK profiles are talking more than 7MB of file size so in order to
optimize file I would like to replace them with DeviceCMYK. How can I
do this using PDFNet?
---
A:
You can access all color spaces used on the page using:
page.GetResources().Get("ColorSpace")
The color space 'replacement code' may look along the following
lines... (please note that this code does not account for all possible
cases, but is only used to illustrate the concept).
Obj cs_dict = page.GetResources().Get("ColorSpace").Value();
DictIterator itr = cs_dict.DictBegin(), end=cs_dict.DictEnd();
for (; itr!=end; ++itr) {
ColorSpace cs = new ColorSpace(itr.Value());
ColorSpace.Type type = cs.GetType();
if (type == ColorSpace.Type.e_device_n && cs.GetComponentNum()==4) {
// replace the color space with device N color space...
cs_dict.Replace(itr, Obj.CreateName("DeviceCMYK"));
}
}