ImageEn, unit iexUserInteractions

TIEPdfViewerInteraction.ScrToPage

TIEPdfViewerInteraction.ScrToPage


Declaration

function ScrToPage(ScrX, ScrY: Integer; CheckBounds: Boolean = True): TDPoint; overload;
function ScrToPage(ScrRect: TRect; CheckBounds: Boolean = True): TDRect; overload;


Description

Convert a screen position (in pixels) to a value on the current page (in points).
When CheckBounds is true, the result will be -1 for values that are outside the page area

Notes:
- PDF Points are not affected by the display DPI
- The origin of PDF page points (i.e. 0,0) is the bottom-left


Examples

// Convert a screen point to a page point
pagePt := ImageEnView1.PdfViewer.ScrToPage( 100, 100 );


// Show position on page as the cursor is moved
procedure TfrmMain.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  pt: TDPoint;
begin
  pt := ImageEnView1.PdfViewer.ScrToPage( X, Y, True );
  if ( pt.X = -1 ) or ( pt.Y = -1 ) then
    Caption := 'Page Pos: INVALID'
  else
    Caption := format( 'Page Pos: %d, %d', [ Round( pt.X ), Round( pt.Y )]);
end;


See Also

- PageToScr