Skip to main content

PdfViewer.GetDocumentPosition(PointF) Method

Converts the specified point coordinates relative to the PDF Viewer’s client area to the page coordinates.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v26.1.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 PDF Viewer’s client area.

Returns

Type Description
PdfDocumentPosition

A PdfDocumentPosition object that returns the page coordinates and the page number.

Remarks

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

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