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 exhausted

Every worker uses the renderer chosen with SelectRenderer on the calling instance, together 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, renderer, CPU and output storage. 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 using the same template rules as RenderPagesToFiles; every %p token is replaced by the page number, or the number is inserted before the final filename extension when no token is present
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 without a token retain their directory components

Return values

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