RenderPageToMemory
Rendering and printing
Description
Renders one page into a caller-supplied bitmap memory buffer when the PDFium or Cairo renderer is selected.
Syntax
Delphi
Function TPDFlib.RenderPageToMemory(DPI: Double; Page: Integer; Target: Pointer; Width, Height, BitsPerPixel: Integer): Integer;
Parameters
| DPI | Requested rendering resolution before the current render scale is applied. |
|---|---|
| Page | 1-based page number. Values outside the document range are clamped to the nearest valid page. |
| Target | Pointer to the destination pixel buffer supplied by the caller. |
| Width | Destination bitmap width in pixels. |
| Height | Destination bitmap height in pixels. |
| BitsPerPixel | Pixel format depth. Only 24 and 32 are accepted. |
Return values
Returns 1 when the selected renderer fills the buffer. Returns 0 for unsupported bit depths, an invalid buffer, when the default renderer is selected, when the PDFium or Cairo library is unavailable, or when rendering fails; LastRenderError describes the failure
Remarks
SelectRenderer(3) for PDFium or SelectRenderer(2) for Cairo must be active. The page is scaled to fill the whole Width by Height buffer. Rows are written top-down with a packed stride of Width * BitsPerPixel / 8 bytes in blue, green, red order, followed by an alpha byte for 32-bit output
With Cairo, a page rendered smaller than the buffer at the requested DPI is rendered again at a higher resolution, then the result is resampled to the exact buffer size; 32-bit Cairo and PDFium output is fully opaque. The buffer must hold at least Width * Height * BitsPerPixel / 8 bytes
See also
SetPDFiumFileName, SelectRenderer, PDFiumRendering, SetCairoFileName