PDFiumVCL Docs

PageToDevice method

Dieser API-Eintrag behält Bezeichner, Signaturen, Codeblöcke und PDF-Begriffe in ihrer Originalform.
Component: TPdf  ·  Unit: PDFium
Convert the page coordinate of a point to screen coordinate.

Syntax

function PageToDevice(PageX, PageY: Double; Left, Top, Width, Height: Integer; Rotation: TRotation; out X, Y: Integer): Boolean;

PageX, PageYDouble. The PDF user-space coordinates to convert (origin at lower-left, units in points).
Left, Top, Width, HeightInteger. The rendering rectangle that was passed to the corresponding RenderPage call.
RotationTRotation. The page rotation used when rendering. Must match the value passed to RenderPage.
X, YInteger. Output parameters that receive the converted device-space pixel coordinates (origin at top-left).

Return Value

Returns True if the conversion succeeded, or False if it failed (for example, if no page is loaded).

Description

Converts a point from PDF user space (points) to device space (screen pixels). Use this method to determine where a known PDF-coordinate position falls on the rendered image — for example, to position an annotation overlay or highlight rectangle.

PDF user space has its origin at the lower-left corner of the page, with the Y axis pointing upward. Device space has its origin at the top-left corner of the render rectangle, with the Y axis pointing downward.

The Left, Top, Width, Height, and Rotation parameters must match exactly what was passed to the RenderPage call that produced the image being mapped onto.

Example

// Draw a marker on screen at a known PDF position
var
  ScreenX, ScreenY: Integer;
begin
  if Pdf.PageToDevice(100.0, 200.0, 0, 0,
    PdfPanel.Width, PdfPanel.Height, ro0, ScreenX, ScreenY) then
  begin
    Canvas.Pen.Color := clRed;
    Canvas.Ellipse(ScreenX - 4, ScreenY - 4, ScreenX + 4, ScreenY + 4);
  end;
end;

See Also

DeviceToPage, RenderPage, PageWidth, PageHeight