Skip to main content
A newer version of this page is available. .

PdfViewer.GetDocumentPosition(PointF) Method

Converts the specified point coordinates relative to the client area of the PDF Viewer (in pixels) to the page coordinates in a document.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v18.2.dll

Declaration

public PdfDocumentPosition GetDocumentPosition(
    PointF clientPoint
)

Parameters

Name Type Description
clientPoint PointF

A PointF structure, specifying the coordinates of a point (in pixels) relative to the client area of the PDF Viewer.

Returns

Type Description
PdfDocumentPosition

A PdfDocumentPosition object that returns the page coordinates and the page number in a document.

Remarks

When the point is outside page bounds, the GetDocumentPosition method returns the point coordinates that belong to the closest page in a document.

Example

This example shows how to determine what page was clicked in a document.

using System.IO;
using System.Reflection;
using System.Windows.Forms;
using DevExpress.Pdf;
using DevExpress.XtraBars.Ribbon;


namespace PageHitTest {

    public partial class Form1 : RibbonForm {
        public Form1() {
            InitializeComponent();

            Stream stream = GetResourceStream("PageHitTest.demo.pdf");
            pdfViewer.LoadDocument(stream);
        }

        static Stream GetResourceStream(string resourceName) {
            return Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
        }

        void pdfViewer_MouseClick(object sender, MouseEventArgs e) {
            PdfDocumentPosition position = pdfViewer.GetDocumentPosition(e.Location, true);
            MessageBox.Show(string.Format("You clicked on page {0}", position.PageNumber));
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetDocumentPosition(PointF) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also