Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.

using System;
using System.Windows.Forms;
using DevExpress.Pdf;
using DevExpress.XtraPdfViewer;
// ...
private void Form1_Load(object sender, EventArgs e) {
    this.pdfViewer.LoadDocument(@"..\..\Demo.pdf");
    this.pdfViewer.ZoomMode = 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;
    }
}