How to: Determine the Page Number of a Clicked PDF Page
This example shows how to determine what page was clicked in a document.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-determine-the-page-number-of-a-clicked-pdf-page-t121897
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));
}
}
}