RenderPagesToFilesParallel

Rendering and printing

Description

Renders every page from StartPage to EndPage of the source PDF to one image file per page, using a pool of parallel TTask workers. Each worker creates its own TPDFlib instance on the same file (TPDFlib is not thread-safe), CoInitializes its thread for GDI+ apartment safety, and renders pages claimed from a shared atomic counter until the range is exhausted.

This scales near-linearly with CPU cores for CPU-bound raster output (BMP/PNG/TIFF). MaxWorkers controls the pool width; pass 0 or negative for auto (min of page count and CPU count). Windows-only: CoInitialize and GDI+ are Windows primitives.

Syntax

Delphi

Function TPDFlib.RenderPagesToFilesParallel(Const FileName, Password: WideString; DPI: Double; StartPage, EndPage, Options: Integer; Const OutputPattern: WideString; MaxWorkers: Integer): Integer;

Parameters

FileName, PasswordSource PDF path and its password (empty if unencrypted)
DPIRender resolution
StartPage, EndPage1-based inclusive page range
OptionsFormat (same as RenderPageToFile: 0=BMP 1=JPEG 5=PNG ...)
OutputPatternOutput path; '%p' is replaced by the page number, else the number is appended
MaxWorkersPool width (0 = auto, capped at page count and CPU count)

Return values

>= 0Number of pages successfully rendered (single-page failures are isolated, not fatal)