![]() | Coordinate Systems |
This topic contains the following sections:
The PDF viewer control uses the client coordinates (measured in pixels) to specify the points position. This coordinate system's starting point is at top-left corner of the PDF Viewer's client area.
Client Coordinate System ![]() | Page Coordinate System ![]() |
On the contrary, The page coordinate system's starting point (0,0) is the left-bottom corner of a page. The Y axis is directed from the bottom of the page to the top.
On the contrary, The page coordinate system's starting point (0,0) is the left-bottom corner of a page. The Y axis is directed from the bottom of the page to the top.
The page coordinate system uses points (1/72 of an inch) as a measurement unit.
To convert page coordinates into client coordinates use the PdfViewer.PageToClient(...) method.
To convert client coordinates into page coordinates use the PdfViewer.ClientToPage(...) method.
private void PdfViewer1_MouseDown(object sender, MouseEventArgs e) { Point clientPoint = e.Location; int pageIndex = pdfViewer1.PointInPage(clientPoint); if (pageIndex < 0) return; //The mouse was pressed outside of the page. //Mouse location in page coordinate system. PointF pagePoint = pdfViewer1.ClientToPage(pageIndex, clientPoint); //Get bottom-left point of a page in client coordinate system Point p1 = pdfViewer1.PageToClient(pageIndex, new PointF(0, 0)); //Get upper-right point of a page in client coordinate system var page = pdfViewer1.Document.Pages[pageIndex]; Point p2 = pdfViewer1.PageToClient(pageIndex, new PointF(page.Width, page.Height)); }
private void PdfViewer1_MouseDown(object sender, MouseButtonEventArgs e) { Point clientPoint = e.GetPosition(pdfViewer1); int pageIndex = pdfViewer1.PointInPage(clientPoint); if (pageIndex < 0) return; //The mouse was pressed outside of the page. //Mouse location in page coordinate system. Point pagePoint = pdfViewer1.ClientToPage(pageIndex, clientPoint); //Get bottom-left point of a page in client coordinate system Point p1 = pdfViewer1.PageToClient(pageIndex, new Point(0, 0)); //Get upper-right point of a page in client coordinate system var page = pdfViewer1.Document.Pages[pageIndex]; Point p2 = pdfViewer1.PageToClient(pageIndex, new Point(page.Width, page.Height)); }