PDFium Component Docs

DeviceToPage 메서드

이 API 항목은 식별자, 시그니처, 코드 블록, PDF 용어를 원래 형태로 유지합니다.
컴포넌트: TPdf  ·  유닛: PDFium
화면 point의 device coordinate를 page coordinate로 변환합니다

구문

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. 렌더링할 때 사용한 page rotation입니다. RenderPage에 전달한 값과 일치해야 합니다
PageX, PageYDouble. Output parameters that receive the converted PDF user-space coordinates (origin at lower-left, units in points).

Return Value

변환에 성공하면 True를, 실패하면 False를 반환합니다(예: page가 로드되지 않은 경우)

설명

device space(screen pixel)의 point를 PDF user space(point)로 변환합니다. 렌더링된 page의 mouse click 위치를 PDF page에서의 대응 위치로 되돌릴 때 사용하세요

PDF user space의 원점은 page의 왼쪽 아래이며 Y axis는 위로 향합니다. device space의 원점은 render rectangle의 왼쪽 위이며 Y axis는 아래로 향합니다

Left, Top, Width, Height, Rotation parameter는 클릭한 image를 만든 RenderPage 호출에 전달한 값과 정확히 일치해야 합니다

예제

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

참고 항목

PageToDevice, RenderPage, PageWidth, PageHeight