RenderPageToMemoryEx
Rendering and printing
Description
Renders a page or a separate page layer into a caller-owned buffer with explicit row stride, capacity and pixel layout
Syntax
function TPDFlib.RenderPageToMemoryEx(DPI: Double; Page: Integer;
Target: Pointer; Width, Height, Stride: Integer; Capacity: NativeUInt;
PixelFormat, LayerKind: Integer): Integer;
Parameters
| DPI, Page | Positive finite DPI before render scaling and a 1-based page number. Page values outside the document are clamped |
|---|---|
| Target, Capacity | Writable buffer address and the number of available bytes at that address |
| Width, Height | Positive dimensions in pixels. The rendered page or layer is resampled to the exact dimensions |
| Stride | Positive distance in bytes between row starts, at least Width * BytesPerPixel. Rows run from the top of the image downward |
| LayerKind | PDF_PIXEL_WHOLE_PAGE (-1) uses the active page render settings. Values 0, 1, 2 and 3 select base content, annotations, form widgets and both interactive layers, respectively |
| PixelFormat | One of the four PDF_PIXEL_* layouts listed below. Any other value returns 0 |
Pixel layouts
| PDF_PIXEL_BGR24 (0) | Blue, green, red on a white backdrop |
|---|---|
| PDF_PIXEL_BGRX32 (1) | Blue, green, red on a white backdrop, followed by a byte set to 255 |
| PDF_PIXEL_BGRA32 (2) | Blue, green, red and straight alpha on an isolated transparent backdrop |
| PDF_PIXEL_PBGRA32 (3) | Blue, green, red premultiplied by alpha, then alpha, on an isolated transparent backdrop |
The minimum capacity is (Height - 1) * Stride + Width * BytesPerPixel. Row padding remains untouched. Calculate the capacity in a type wide enough for the product
Return values
Returns 1 on success and 0 for invalid parameters, insufficient capacity, cancellation or rendering failure. Invalid buffer layouts are rejected before rendering or writing pixels. LastRenderError describes the failure
Renderer behavior
The built-in and Cairo renderers handle all four formats and all layer selections. They use the selected page box and view layer configuration. PDFium handles opaque whole-page requests through its existing raster path. Requests for alpha or a separate layer use the built-in renderer while PDFium is selected
Transparent output uses Normal blending for independent composition. For results that depend on blending against page content, use opaque whole-page rendering
RenderPageToMemory continues to accept packed opaque buffers with Cairo or PDFium