PDFium Rendering

Description

Version 3.9.7 adds optional PDFium rendering on Windows. The default renderer remains GDI+. Applications can call SetPDFiumFileName with the full path to pdfium.dll, then call SelectRenderer(3) to render with PDFium. SelectedRenderer returns the active backend, and SelectRenderer(1) switches back to GDI+.

Supported rendering paths

- RenderPageToStream, RenderPageToFile and RenderPagesToFiles support the same raster output options the GDI+ and Cairo renderers accept: 0 (BMP), 1 (JPEG), 5 (PNG), 6 (GIF), 7 (TIFF) and 10 (G4 TIFF). SetJPEGQuality applies to option 1, and the TIFF options honour the active GDI+ settings.

- The metafile output options (2 WMF, 3 EMF, 4 EPS, 8 EMF+, 9 HTML5, 11 EMF+ dual) have no PDFium equivalent. Those calls return 0 and LastRenderError explains which formats the PDFium backend supports.

- RenderPageToDC renders the selected page to a Windows device context using PDFium.

- RenderPageToMemory renders into caller-provided 24-bit or 32-bit memory buffers.

- PrintDocument and PrintPages use PDFium when renderer 3 is selected.

- RenderDocumentToFile renders a contiguous range to individual raster files and reuses the parsed PDFium document. Direct Access rendering can also use PDFium

Deployment notes

The PDFium DLL must match the process architecture. The distribution stores the runtime files under DLL\PDFium\Win32 and DLL\PDFium\Win64. Keep pdfium.dll together with its companion runtime DLLs when deploying an application.

Version 3.23.0 refreshes the bundled optional PDFium runtime DLL payloads under DLL\PDFium\Win32 and DLL\PDFium\Win64; the public renderer-selection API and GDI+ default are unchanged.

Delphi syntax

function TPDFlib.SetPDFiumFileName(const FileName: WideString): Integer;
function TPDFlib.SelectRenderer(RendererID: Integer): Integer;
function TPDFlib.SelectedRenderer: Integer;

Ordinary single-page stream, DC and memory renders reuse one open PDFium session for unchanged document snapshots up to 32 MiB. Each render compares the current serialized snapshot so page and object edits cannot reuse old content. Changing the selected document or PDFium DLL closes the cached session