Write a rectangular region to an image file.
int pdfWriteRegionBitmap2(PDFHandle pdf, int page, int regionX, int regionY, int regionW, int regionH, double hDPI, double vDPI, int color, int format, char *fileName)
This function converts a rectangular region of a PDF page to an image file on disk. This can be useful if the page is too large to fit in memory at the desired resolution, or if only part of the page is needed for some purpose. It is identical to pdfWriteRegionBitmap, except that it allows the horizontal and vertical resolutions to be controlled independently.

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.

The arguments are:

The pdfImageDevNToCMYK mode produces CMYK output like pdfImageCMYK, but does the rasterization in DeviceN (CMYK + spot colors) so overprint previews will be more accurate.

The pdfImageDevNToRGB mode is similar to pdfImageDevNToCMYK, but converts to RGB output.

The pdfImageGrayToMono mode does the rasterization in 8-bit grayscale and converts to 1-bit monochrome at the end. This is useful for files that use transparency – because 1-bit monochrome mode doesn't support transparency.

CMYK output is only available in TIFF format.

/* convert the top part of page 5 to a 144x72 dpi color TIFF file */ pdfWriteRegionBitmap2(pdf, 5, 0, 0, 1000, 500, 144, 72, pdfImageRGB, pdfImageFileTIFF, "test1.tiff");