Coordinate Systems
- 2 minutes to read
This document describes the coordinate systems the PDF Viewer uses.
Client Coordinate System
Points’ position in the PDF Viewer control is specified using the client coordinates (measured in pixels). The client coordinate system’s origin is at the top-left corner of the PDF Viewer’s client area. See Windows Forms Coordinates for more details.
The dimensions of the client area are described by a RectangleF structure that contains client coordinates for the area.
Page Coordinate System
The page coordinate system’s origin (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 PDF Viewer’s pages are measured in points (1/72 of an inch).
Using Coordinate System in API
The following methods use client coordinates:
- PdfViewer.GetContentInfo
- the PdfViewer.Select overloaded method that uses the client’s rectangle (client area) as an argument. The RectangleF structure represents this rectangle.
The page coordinates are used in the following methods:
- PdfViewer.FindText overloaded methods.
- PdfViewer.Select overloaded method that uses the PdfDocumentPosition object as arguments.
Coordinate Transformations
The PDF Viewer provides the following methods to convert client coordinates to page coordinates and vice versa:
- PdfViewer.GetDocumentPosition overloaded methods return the PdfDocumentPosition object containing the page number and page coordinates.
- PdfViewer.GetClientPoint method returns a PointF structure representing the client point.
The page coordinates should be transformed into client coordinates to perform some tasks with the PDF Viewer, for example, draw custom graphics on the Control.Paint event in the PDF Viewer. See the How to: Custom Draw in the PDF Viewer example.
The conversion from client coordinates to page coordinates should be provided, for example, when you need to determine what page was clicked in a document. See the How to: Determine the Page Number of a Clicked PDF Page example.