pdfConvertPageToBitmap2
Convert a page to a bitmap in memory.
int pdfConvertPageToBitmap2(PDFHandle pdf, int page, double dpi, int color,
int reverseBytes, int rowPad, int upsideDown,
PDFImageHeader *imgHdr, char **bits)
This function converts a PDF page to a bitmap in memory. It is
similar to
pdfConvertPageToBitmap
, but offers more control over
the output bitmap format, and has an identical API on all platforms.
The arguments are:
page
= page numberdpi
= resolution (dots per inch)color
= color setting - one of:pdfImageMono
: 1-bit monochromepdfImageGray
: 8-bit grayscalepdfImageRGB
: 8-bit RGBpdfImageCMYK
: 8-bit RGBpdfImageDevNToRGB
: 8-bit RGB, rasterized in DeviceN and then converted to RGBpdfImageDevNToCMYK
: 8-bit CMYK, rasterized in DeviceN and then converted to CMYKpdfImageGrayToMono
: 1-bit monochrome, rasterized in 8-bit grayscale and then converted to 1-bit
reverseBytes
= non-zero to store RGB color data in BGR order (this argument has no effect for pdfImageMono or pdfImageGray)rowPad
= each row will be padded out to a multiple of this number of bytes (typically 1 for no padding, or 4 to pad to a 32-bit boundary)upsideDown
= non-zero to store the bitmap with the bottom row firstimgHdr
= a struct describing the output bitmap, with the following fields:width
= image widthheight
= image heightcolor
= the color argument passed topdfConvertPageToBitmap2
bits
= pointer to the returned bitmap data
pdfImageDevNToRGB
mode produces RGB output
like pdfImageRGB
, but does the rasterization in DeviceN
(CMYK + spot colors) so overprint previews will be more accurate.
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 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.
The pdfConvertPageToBitmap2
function
returns pdfOk
if successful, otherwise an
error code.
The caller is responsible for freeing the bits
pointer
after using it, by calling pdfFreeMemory
.
C:
int reverseBytes, rowPad, upsideDown;
PDFImageHeader hdr;
char *bits;
reverseBytes = 0; /* RGB ordering */
rowPad = 1; /* no extra padding on rows */
upsideDown = 0; /* store top row first */
pdfConvertPageToBitmap2(pdf, 5, 72, pdfImageRGB, reverseBytes, rowPad, upsideDown, &hdr, &bits);
...
pdfFreeMemory(bits);