PDFium Delphi Component Docs

RenderPage method

Component: TPdf  ·  Unit: PDFium
Render contents of a page to a device (screen, bitmap or printer)

Syntax

procedure RenderPage(DeviceContext: HDC; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []);

DeviceContextHDC. The target Windows device context to render into (screen canvas, printer DC or bitmap DC)
Left, TopInteger. Top-left corner of the destination rectangle within the device context, in device pixels
Width, HeightInteger. Size of the destination rectangle in device pixels. The page is scaled to fill this area
RotationTRotation. Display rotation applied to the page: ro0 (default), ro90, ro180 or ro270
OptionsTRenderOptions. A set of TRenderOption flags controlling rendering quality and behaviour, such as reAnnotations, reLcd, reGrayscale and rePrinting

 

function RenderPage(Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite): TBitmap;

Left, TopInteger. Top-left offset within the output bitmap where rendering begins, in pixels
Width, HeightInteger. Size of the destination area in pixels. The page is scaled to fill this area
RotationTRotation. Display rotation applied to the page: ro0 (default), ro90, ro180 or ro270
OptionsTRenderOptions. A set of TRenderOption flags controlling rendering quality and behaviour
ColorTColor. Background fill colour for the bitmap before rendering. Defaults to clWhite

 

procedure RenderPage(Bitmap: TBitmap; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite);

BitmapTBitmap. An existing TBitmap to render into. The caller is responsible for creating and freeing this bitmap
Left, TopInteger. Top-left offset within the bitmap where rendering begins, in pixels
Width, HeightInteger. Size of the destination area in pixels. The page is scaled to fill this area
RotationTRotation. Display rotation applied to the page: ro0 (default), ro90, ro180 or ro270
OptionsTRenderOptions. A set of TRenderOption flags controlling rendering quality and behaviour
ColorTColor. Background fill colour applied to the bitmap before rendering. Defaults to clWhite

Description

For the bitmap overloads, Color = clNone or Color = clDefault requests a transparent background and a PDFium bitmap with alpha support. Uncovered pixels keep zero alpha even if the native page background-transparency query returns false; clWhite remains the default opaque background

Renders the current page to a device context or bitmap. Three overloads are available: (1) renders directly to an HDC (suitable for printing or on-screen painting); (2) returns a newly created TBitmap that the caller must free; (3) renders into an existing TBitmap passed as parameter

The Left, Top, Width, Height parameters define the output rectangle. Rotation applies a display rotation (use PageRotation to match the stored page rotation) Flags control rendering quality (antialiasing, LCD text, etc.)

Fonts selected through ExtGState

The bundled Windows native modules in internal v3.414.2 resolve the font dictionary referenced by an ExtGState Font array, as specified by ISO 32000-1 Table 58, including fonts that have no entry in the page Font resource map

Type3 selection initialises the same resource context and font metrics as explicit Tf selection, preserving inherited glyph resources; this rendering correction does not add general Type3 text regeneration or editing support

Example

var Bmp: TBitmap;
Bmp := Pdf.RenderPage(0, 0, 800, 1000);
try
  Image1.Picture.Assign(Bmp);
finally
  Bmp.Free;
end;

See Also

RenderTile, PageWidth, PageRotation, ReloadPage