pdfConvertPageToDeviceNImage
Convert a page to a DeviceN image.
int pdfConvertPageToDeviceNImage(PDFHandle pdf, int page, double dpi)
This function rasterizes a page in DeviceN mode, i.e., with separate
color channels for each process color (cyan, magenta, yellow, and
black), and for each custom (a.k.a., spot) color.
After calling pdfConvertPageToDeviceNImage
:
- call
pdfGetNumDeviceNChannels
to retrieve the number of color channels - call
pdfGetDeviceNChannelName
andpdfGetDeviceNChannelCMYK
to get the name and CMYK value for a particular channel - call
pdfGetDeviceNBitmap
to get a bitmap for a particular channel
pdfClearDeviceNImage
to release the memory used by
pdfConvertPageToDeviceNImage
.
To enable an overprint preview rasterization, call pdfSetConfig
to
set the overprintPreview
parameter before
calling pdfConvertPageToDeviceNImage
:
pdfSetConfig("overprintPreview yes");
C:
int nChannels, i;
char *channelName;
unsigned int channelCMYK;
PDFImageHeader hdr;
char *bits;
int err;
err = pdfConvertPageToDeviceNImage(pdf, pageNum, dpi);
if (err != pdfOk) {
/* handle the error */
...
}
nChannels = pdfGetNumDeviceNChannels(pdf);
for (i = 0; i < nChannels; ++i) {
channelName = pdfGetDeviceNChannelName(pdf, i);
channelCMYK = pdfGetDeviceNChannelCMYK(pdf, i);
printf("channel %d: %s = %08x\n", channelName, channelCMYK);
pdfGetDeviceNBitmap(pdf, i, 1, 0, &hdr, &bits);
/* hdr and bits represent a grayscale bitmap --
similar to pdfConvertPageToBitmap2 with pdfImageGray */
/* each channel has an 8-bit bitmap; the bitmaps for
all channels will have the same width and height */
...
/* the bitmap memory must be freed when you are finished */
pdfFreeMemory(bits);
}
/* free the internal storage used by pdfConvertPageToDeviceNImage */
pdfClearDeviceNImage(pdf);