API reference › Rendering & Viewer
pdfRenderPageEx
Render the active document page into a caller-supplied
BOOL32 __stdcall pdfRenderPage(PPDF IPDF, IPGE PagePtr, IRAS RasPtr, TPDFRasterImage* Img);
BOOL32 __stdcall pdfRenderPageEx(PPDF IPDF, HDC DC, int32_t* DestX, int32_t* DestY, IPGE PagePtr, IRAS RasPtr, TPDFRasterImage* Img);
function pdfRenderPage(const IPDF: PPDF; PagePtr: IPGE; RasPtr: IRAS; var Img: TPDFRasterImage): LongBool; stdcall;
function pdfRenderPageEx(const IPDF: PPDF; DC: HDC; var DestX, DestY: Integer; PagePtr: IPGE; RasPtr: IRAS; var Img: TPDFRasterImage): LongBool; stdcall;
Purpose. Render the active document page into a caller-supplied IRAS rasterizer buffer (pdfRenderPage), or the same plus an immediate GDI blit to a device context (pdfRenderPageEx).
Description. Two distinct code paths inside the same function, selected purely by whether a usable IRAS was supplied. If RasPtr resolves to a rasterizer (GetRas) with an already-sized, non-nil pixel buffer, rendering goes through RenderIntoRas — the full the engine software rasterizer (blend modes, soft masks, shadings, embedded TrueType glyph outlines; see the unit's own header comment for the complete supported-operator list). Img.Flags is consulted here: rfScaleToMediaBox computes an aspect-fit CTM from the page's own media box into the IRAS buffer's pixel dimensions (only when no explicit CTM was already supplied via Img), and rfInitBlack selects a black vs. white initial background. If no usable IRAS is supplied (RasPtr doesn't resolve, or its buffer is nil/zero-sized), it silently falls back to the simpler, separate RenderPageRGBStruct engine, sized either from Img.DefScale or an engine-owned default — this fallback path does not go through the engine at all. PagePtr (IPGE) is accepted by both declarations but the implementation renders D.ActivePageIndex in either branch — PagePtr is not consulted to select which page renders. pdfRenderPageEx additionally blits the resulting RGB24 buffer into DC at (DestX, DestY) via SetDIBitsToDevice with a top-down (negative height) DIB — but only through the IRAS-less fallback path (it always calls RenderPageRGBStruct, never RenderIntoRas), so pdfRenderPageEx never benefits from the fuller the engine feature set even when a valid RasPtr might otherwise be usable via pdfRenderPage.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
DC | *(Ex only)* Target device context for the immediate GDI blit. |
DestX, DestY | *(Ex only)* Blit destination in DC; not read as input despite the C int32_t* signature — always written by FillPageSpace. |
PagePtr | Accepted but not used to select the rendered page — always the document's active page. |
RasPtr | An IRAS rasterizer; if it has a real sized buffer, the full software rasterizer path is used; otherwise a simpler RGB fallback renders instead. |
Img | In: Flags (rfScaleToMediaBox, rfInitBlack), DefScale, ClipRect, an optional explicit CTM. Out: OutWidth/OutHeight/OutPitch/OutPixFmt/OutData, plus page-space and render-stat fields. |
Return value. True on successful render; False if IPDF is invalid or the page/geometry can't be resolved.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfRenderPageEx
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.