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 independent 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 used up

Every worker uses the renderer chosen with SelectRenderer on the calling instance, along with its render scale, crop type and JPEG quality. PDFium is not thread-safe, so a PDFium selection renders the pages on a single worker

Parallel throughput depends on the document, the renderer, the CPU and the output storage. MaxWorkers controls the pool width; pass 0 or a negative value for auto (the lesser 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)

For page 2, page_%p_%p.png becomes page_2_2.png and page.png becomes page2.png; paths with no token keep their directory components

Return values

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