PDFium Component Docs

DeviceToPage-metodi

Component: TPdfView  ·  Unit: PDFium
Muuntaa näkymän sisällä olevan näytön pikselin (X, Y) PDF:n user-space-pisteeksi nykyisellä sivulla.

Syntax

function DeviceToPage(X, Y: Integer; out PageX, PageY: Double): Boolean; overload;

 

function DeviceToPage(X, Y: Integer; var PageNumber: Integer; var PageX, PageY: Double): Boolean; overload;

 

function DeviceToPage(Rectangle: TRect): TPdfRectangle; overload;

Description

Converts a screen pixel (X, Y) inside the view to a PDF user-space point on the current page.

Returns False when the point falls outside the page rectangle; use in OnMouseDown / OnMouseMove to map cursor to PDF coordinates.

TPdfView maintains the device-to-page transform internally based on Zoom, Rotation, page padding, and scroll offset; these helpers are the safe public interface to that transform.

Remarks

Example

procedure TForm1.PdfView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  PageX, PageY: Double;
begin
  if PdfView1.DeviceToPage(X, Y, PageX, PageY) then
    Caption := Format('pt = (%.2f, %.2f)', [PageX, PageY]);
end;

See Also

PageToDevice, CharacterIndexAtPos, LinkAnnotationAtPos, WebLinkAtPos