function DeviceToPage(X, Y, Left, Top, Width, Height: Integer; Rotation: TRotation; out PageX, PageY: Double): Boolean;
| X, Y | Integer. The device-space coordinates of the point to convert (screen pixels, origin at top-left). |
| Left, Top, Width, Height | Integer. The rendering rectangle that was passed to the corresponding RenderPage call. |
| Rotation | TRotation. The page rotation used when rendering. Must match the value passed to RenderPage. |
| PageX, PageY | Double. Output parameters that receive the converted PDF user-space coordinates (origin at lower-left, units in points). |
True if the conversion succeeded, or False if it failed (for example, if no page is loaded).Converts a point from device space (screen pixels) to PDF user space (points). Use this method to translate a mouse click position on a rendered page back to the corresponding position on the PDF page.
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 clicked on.
// Translate a mouse click on the painted page to PDF coordinates
procedure TForm1.PdfPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
PageX, PageY: Double;
begin
if Pdf.DeviceToPage(X, Y, 0, 0, PdfPanel.Width, PdfPanel.Height,
ro0, PageX, PageY) then
StatusBar1.SimpleText := Format('Page pos: %.1f, %.1f pt', [PageX, PageY]);
end;