Click or drag to resize

Coordinate Systems

This topic contains the following sections:

Client coordinate system

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.

coordinate systems
Client Coordinate System
client coordinate system
Page 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.

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.

page coordinate system 2

The page coordinate system uses points (1/72 of an inch) as a measurement unit.

Convert coordinates

To convert page coordinates into client coordinates use the PdfViewer.PageToClient(...) method.

To convert client coordinates into page coordinates use the PdfViewer.ClientToPage(...) method.

Convert coordinates in WinForms application.

C#
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));
}

Convert coordinates in WPF application.

C#
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));
}
See Also

Reference

PdfViewerCore.PageToClient(Int32, FS_POINTF)
PdfViewer.PageToClient
PdfViewer.PageToClient
PdfViewerCore.ClientToPage(Int32, SinglePoint)
PdfViewer.ClientToPage
PdfViewer.ClientToPage