Skip to main content

PdfHitTestResult.ContentType Property

Indicates the type of the content corresponding to a hit point.

Namespace: DevExpress.Xpf.PdfViewer

Assembly: DevExpress.Xpf.PdfViewer.v23.2.dll

NuGet Package: DevExpress.Wpf.PdfViewer

Declaration

public PdfDocumentContentType ContentType { get; }

Property Value

Type Description
PdfDocumentContentType

A PdfDocumentContentType enumeration value.

Available values:

Name Description
None

The PDF content is not defined.

Text

The PDF content is text.

Image

The PDF content is an image.

Annotation

The PDF content is an annotation.

Example

View Example: https://github.com/DevExpress-Examples/how-to-determine-the-page-content-type-under-the-mouse-pointer

This example illustrates how to use the PdfViewerControl.HitTest method to determine the type of the page content under the mouse pointer.

This method returns a PdfHitTestResult instance with information about the page content type (text, an image or annotation). You can get the page content type using the PdfHitTestResult.ContentType property and the page content selection status using the PdfHitTestResult.IsSelected property.

In this example, the retrieved information is shown on the Content Type ribbon page group.

Call the PdfViewerControl.HitTest method in the PdfViewerControl.MouseMove event handler to perform hit testing.

using DevExpress.Pdf;
using DevExpress.Xpf.PdfViewer;
using System.Windows;
using System.Windows.Input;

namespace DetermineContentType {

    public partial class MainWindow : Window {

        public MainWindow() {
            InitializeComponent();
            viewer.OpenDocument("..\\..\\demo.pdf");
        }

        private void viewer_MouseMove(object sender, MouseEventArgs e) {

            PdfHitTestResult result = viewer.HitTest(e.GetPosition(viewer));
            string contentTypeText = result.IsSelected ? "Selected " : "Unselected ";

            switch (result.ContentType) {
                case PdfDocumentContentType.Text:
                contentTypeText = contentTypeText + "Text";
                break;
                case PdfDocumentContentType.Image:
                contentTypeText = contentTypeText + " Image";
                break;
                case PdfDocumentContentType.Annotation:
                contentTypeText = contentTypeText + "Annotation";
                break;
                default:
                contentTypeText = "The content is empty";
                break;
            }
            barButtonItem.Content = contentTypeText;
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ContentType property.

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