Q: Can I use PDFNet SDK to rasterize PDF in CMYK and export CMYK
TIFF?
---------
A: As of version 4.1 PDFNet will support direct CMYK and DeviceN
rendering besides RGB, Gray, and monochrome rasterizers which are
already available.
A preliminary version that includes CMYK and DeviceN rasterizer can be
downloaded using the following link: http://www.pdftron.com/IDR_A4985_RP/PDFNet.zip
Also included in the Files secion of this forum (http://
groups.google.com/group/pdfnet-sdk/web/PDFDrawCMYK.zip) is a sample
project (in C#) illustrating how to render PDF in CMYK and how to
preserve CMYK channels during TIFF export. To run the sample extract
the archive under 'PDFNet/Samples' folder and adjust input folders and
test files. The basic use case is illustrated in the following code:
//--------------------------------
PDFNet.Initialize();
PDFNet.SetResourcesPath("../../../../../resources");
PDFNet.SetColorManagement(true);
PDFNet.SetDefaultDeviceCMYKProfile(input_path +
"USWebCoatedSWOP.icc"); PDFNet.SetDefaultDeviceRGBProfile(input_path +
"AdobeRGB1998.icc");
PDFDraw draw = new PDFDraw(); // PDFDraw class is used to rasterize
PDF pages.
// A hint object used to tell the rasterizer and the export
// filter to generate and output the image in CMYK color space.
ObjSet hints = new ObjSet();
Obj cmyk_hint = hints.CreateDict();
cmyk_hint.PutName("ColorSpace", "CMYK");
// Open a PDF document.
PDFDoc doc = new PDFDoc(input_path + "bitmap_cmyk.pdf");
doc.InitSecurityHandler();
// Set the output resolution
draw.SetDPI(92);
// Convert all PDF pages to CMYK TIFF.
for (PageIterator itr=doc.GetPageIterator(); itr.HasNext();
itr.Next()) {
string outname = string.Format("{0}out2{1:d}.tif", output_path,
itr.GetPageNumber());
draw.Export(itr.Current(), outname, "TIFF", cmyk_hint);
}
draw.Dispose();
doc.Close();
//--------------------------------
For testing, you can also use the latest pdf2image command-line
utility (http://www.pdftron.com//pdf2image.zip), which includes --cmyk
(or -k) export option. The following pdf2image command-line will
convert 'my.pdf' to CMYK TIFF:
pdf2image --format tiff --cmyk -o OUT my.pdf