function RenderPageProgressive(
Bitmap : TBitmap;
Left, Top, Width, Height: Integer;
const AToken : IPdfCancellationToken;
Rotation : TRotation = ro0;
Options : TRenderOptions = [];
Colour : TColor = clWhite): TPdfProgressiveStatus;
RenderPageProgressive renders the current page into the supplied
Bitmap using PDFium's
FPDF_RenderPageBitmap_Start +
FPDF_RenderPage_Continue loop. Between iterations,
PDFium's IFSDK_PAUSE callback polls
AToken.IsCancelled — when the application has
cancelled, the loop unwinds cleanly and the bitmap holds the
partial work done so far.
The same zero-copy fast path introduced in v1.21.0 applies: PDFium renders directly into the destination TBitmap's DIB buffer instead of staging through an internal buffer. A legacy per-scanline fallback exists for the unlikely case where the destination DIB cannot be wrapped.
The return value identifies how the render finished:
FPDF_RENDER_FAILED. The bitmap state is undefined.Pass AToken = nil to render to completion without
ever pausing. In that case the function still pumps
FPDF_RenderPage_Continue until DONE but never returns
prsCancelled. This is useful when the caller wants the
progressive loop's intermediate redraw points (a custom OnPaint
that mirrors the in-progress bitmap) but does not need cancellation.
PixelFormat = pf32bit for the zero-copy path to engage; other pixel formats are upgraded to pf32bit before the render starts.TPdf serialises render calls per instance; callers still must avoid mutating or unloading the document while a render is in flight.EPdfError is raised when Bitmap is nil — the contract requires a caller-allocated bitmap because the zero-copy path needs a known DIB layout.
uses FPdfAsync;
var
Bitmap: TBitmap;
Status: TPdfProgressiveStatus;
begin
Bitmap := TBitmap.Create;
try
Bitmap.PixelFormat := pf32bit;
Bitmap.SetSize(2480, 3508); // A4 @ 300 DPI
Status := Pdf1.RenderPageProgressive(Bitmap,
0, 0, Bitmap.Width, Bitmap.Height,
CancelToken, ro0, [reAnnotations]);
case Status of
prsDone: SaveBitmap(Bitmap);
prsCancelled: Log.Add('Cancelled mid-page');
prsFailed: Log.Add('PDFium FPDF_RENDER_FAILED');
end;
finally
Bitmap.Free;
end;
end;