How to: Determine the PDF Content Type Corresponding to a Specific Point in a Document
This example illustrates how to determine the type of the PDF content corresponding to the point that is being clicked.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-determine-the-pdf-content-type-corresponding-to-a-specific-document-point-t128105
using System;
using System.Windows.Forms;
using DevExpress.Pdf;
// ...
private void Form1_Load(object sender, EventArgs e) {
this.pdfViewer.LoadDocument(@"..\..\Demo.pdf");
this.pdfViewer.ZoomMode = DevExpress.XtraPdfViewer.PdfZoomMode.FitToWidth;
}
private void pdfViewer_MouseMove(object sender, MouseEventArgs e) {
PdfDocumentContent content = pdfViewer.GetContentInfo(e.Location);
if(content != null) {
string contentTypeText = content.IsSelected ? "Selected " : "Unselected ";
switch(content.ContentType) {
case PdfDocumentContentType.Text:
contentTypeText = contentTypeText + "text";
break;
case PdfDocumentContentType.Image:
contentTypeText = contentTypeText + "image";
break;
default:
contentTypeText = "The content is empty";
break;
}
bsiContentType.Caption = contentTypeText;
}
}