PDFium Component Docs

DeviceToPage Methode

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

Syntax

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

X, YInteger. The device-space coordinates of the point to convert (screen pixels, origin at top-left).
Left, Top, Width, HeightInteger. The rendering rectangle that was passed to the corresponding RenderPage call.
RotationTRotation. Die beim Rendern verwendete Seitendrehung. Muss dem an RenderPage.
PageX, PageYDouble. Output parameters that receive the converted PDF user-space coordinates (origin at lower-left, units in points).

Return Value

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

Beschreibung

Konvertiert einen Punkt aus dem Geräteraum (Bildschirmpixel) in den PDF-User-Space (Punkte). Verwenden Sie diese Methode, um die Position eines Mausklicks auf einer gerenderten Seite zurück auf die entsprechende Position auf der PDF-Seite umzusetzen

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, Oben, Width, Height, and Rotation parameters must match exactly what was passed to the RenderPage call that produced the image being clicked on.

Beispiel

// 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;

Siehe auch

PageToDevice, RenderPage, PageWidth, PageHeight