function RenderPagesParallel(
const PageNumbers : array of Integer;
const Options : TPdfParallelRenderOptions;
const CancellationToken: IPdfCancellationToken = nil): TPdfParallelRenderReport;
RenderPagesParallel captures the current document once into TPdfRandomAccessStore, removes snapshot encryption and keeps the source immutable until every worker document closes
An in-memory capture is shared directly without a second byte-array copy, a spilled capture is exposed through one read-only file mapping, and mapping failure falls back to FPDF_LoadCustomDocument block reads from the same thread-safe store
Every worker loads a private temporary copy of the active PDFium binary as an independent module, initialises that module on its worker thread, and reuses its own FPDF_DOCUMENT whilst loading and closing assigned pages
Module, document, page, progressive-render and bitmap state never crosses worker boundaries, avoiding unsafe concurrent calls into one PDFium module
PageNumbers uses the public one-based page convention and the returned Results array always matches the request order, even when workers finish out of order or an individual page fails
Each successful result owns a top-down 32-bit pixel buffer with Stride = Width * 4, using BGRA byte order unless reReverseByteOrder requests RGBA
| Field | Default | Meaning |
|---|---|---|
Dpi | 96 | Target resolution from more than 0 through 2400 DPI |
MaxWorkers | 0 | 0 selects up to four workers, otherwise 1 through 64 bounded by the request count |
MaxPixelsPerPage | 64 MiPixels | Rejects a page before allocating an oversized result buffer |
MaxTotalOutputBytes | 512 MiB | Bounds the sum of retained successful pixel buffers |
Rotation | ro0 | Applies the same rotation to every request and swaps output dimensions for 90 or 270 degrees |
RenderOptions | [] | Native PDFium render flags including annotations, greyscale, printing, smoothing and reverse byte order |
BackgroundColor | clWhite | Initial pixel background before PDFium paints page content |
pprsSucceeded returns dimensions, stride, pixel format, pixels and elapsed timepprsCancelled returns no pixels when cancellation is observed before or during the progressive render looppprsFailed isolates an invalid page, native load or render failure, or resource-budget rejection in ErrorMessageTotalOutputBytes and end-to-end elapsed timeSucceededCount, CancelledCount, and FailedCount total the per-page terminal statuses in Results: SucceededCount pages returned a usable pixel buffer, CancelledCount pages ended as pprsCancelled because the cancellation token fired, and the three counts together always account for every requested pageSourceSize, SourcePeakMemoryBytes and SourceStorageBackend expose the bounded capture costSourceBackingKind is ppsbSharedMemory, ppsbMemoryMappedFile or ppsbRandomAccessStore after source captureModules is a TPdfParallelModuleIdentities array containing TPdfParallelModuleIdentity records. Each keeps the private FileName, native InitializationAddress and Unloaded clean-up result, so callers can distinguish genuinely isolated modules from a loader reusing an existing imageUnloaded records successful release of the owned native loader handle. The operating system may keep the image mapped afterwards, so the field does not confirm that its address space was immediately unmapped/usr/bin/codesign to apply an ad-hoc signature after assigning the owned copy a unique identity. Signing is limited to 30000 milliseconds, and platform security policy must allow the resulting native imageUnloaded result does not mean that the pooled file is deleted immediatelyreInvert and reNightDuotone are post-render bitmap transforms and are rejected by this raw-buffer APISaveMemoryLimit and SaveTemporaryDirectory govern the captured source whilst the output budget covers retained result buffers rather than PDFium internal allocationsTPdf instance concurrently whilst the initial snapshot is being capturedPixels arrays after consuming them
uses FPdfAsync;
var
Options: TPdfParallelRenderOptions;
Report: TPdfParallelRenderReport;
I: Integer;
begin
Options := TPdfParallelRenderOptions.Default;
Options.Dpi := 150;
Options.MaxWorkers := 4;
Options.RenderOptions := [reAnnotations];
Report := Pdf1.RenderPagesParallel([1, 3, 5, 7], Options, CancelToken);
for I := 0 to High(Report.Results) do
if Report.Results[I].Status = pprsSucceeded then
ConsumeTopDownPixels(Report.Results[I]);
end;