Convert a rectangular region to a DeviceN image with an alpha channel.
int pdfConvertRegionToDeviceNImageWithAlpha(PDFHandle pdf, int page, int regionX, int regionY, int regionW, int regionH, double dpi)
This function rasterizes a rectangular region of a PDF 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.

The rectangular region is specified by the x,y coordinates of its upper-left corner and its width and height - in bitmap coordinates, not PDF coordinates. That is, if the whole-page bitmap would have been 1000 pixels wide and 2000 pixels high, and you request a region with (x,y) = (0,0) and (w,h) = (1000,500), the resulting bitmap will be the top fourth of the page.

This function differs from pdfConvertRegionToDeviceNImage in that it skips the final page compositing step, and maintains an alpha bitmap. The alpha bitmap can be retrieved with pdfGetDeviceNAlphaBitmap.

Note: The alpha bitmap is only useful with PDF files that have been constructed with a transparent background.

After calling pdfConvertRegionToDeviceNImageWithAlpha:

Finally, call pdfClearDeviceNImage to release the memory used by pdfConvertRegionToDeviceNImage.

To enable an overprint preview rasterization, call pdfSetConfig to set the overprintPreview parameter before calling pdfConvertRegionToDeviceNImage:

pdfSetConfig("overprintPreview yes");
int nChannels, i; char *channelName; unsigned int channelCMYK; PDFImageHeader hdr; char *bits; int err; err = pdfConvertRegionToDeviceNImage(pdf, 5, 0, 0, 1000, 500, 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 pdfConvertRegionToBitmap2 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); } pdfGetDeviceNAlphaBitmap(pdf, 1, 0, &hdr, &bits); /* hdr and bits work the same as for the color channel bitmaps */ ... pdfFreeMemory(bits); /* free the internal storage used by pdfConvertRegionToDeviceNImage */ pdfClearDeviceNImage(pdf);