Skip to main content
A newer version of this page is available.
All docs
V19.2

PdfViewer.TextMarkupAnnotationCreating Event

Occurs when a text markup annotation (highlight, strikethrough or underline) is being created.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v19.2.dll

Declaration

public event PdfTextMarkupAnnotationCreatingEventHandler TextMarkupAnnotationCreating

Event Data

The TextMarkupAnnotationCreating event's data class is PdfTextMarkupAnnotationCreatingEventArgs. The following properties provide information specific to this event:

Property Description
Author Specifies the author of a text markup annotation.
Bounds Gets the text markup annotation’s bounds on a page.
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
Color Specifies the markup annotation color and transparency.
Comment Specifies text to be displayed when the markup annotation’s popup window is opened over a page.
CreationDate Specifies the date and time when the markup annotation was created on the page.
IsSelected Specifies whether a newly created markup annotation is selected.
ModificationDate Specifies the date and time of the markup annotation’s last modification.
Name Specifies the markup annotation name.
PageNumber Gets the page number where the annotation is being created.
Quads Gets a collection of quadrilaterals that encompass the text markup annotation drawing area.
SelectedText Gets a selected text for which a markup annotation is being created on a page.
Style Specifies the style of a text markup annotation.
Subject Specifies a short description of the subject being addressed by the text markup annotation.

Remarks

You can prohibit the text markup annotation creation for a selected text by setting the e.Cancel property to true.

Example

This example demonstrates how to specify the text markup annotation properties when the annotation is being created in a document.

To add a markup to text:

  • Select the text;
  • Right-click the text and choose Highlight, Strikethrough or Underline item in the invoked context menu.

    MarkupContextMenu

When the text markup annotation is being created in a document, the PdfViewer.TextMarkupAnnotationCreating event is raised. In this event, you can specify the annotation properties (for example, the default color used to underline a text using the PdfTextMarkupAnnotationCreatingEventArgs.Color property as shown in the code below).

You can see properties applied to a newly created annotation in the Annotation Properties dialog.

To open this dialog, right-click the annotation and choose the Properties… item in the context menu.

ClickAnnotationPropertiesItem

The Annotation Properties dialog is shown below.

AnnotationPropertiesExampleResult

The following code shows how to handle the PdfViewer.TextMarkupAnnotationCreating event.

using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPdfViewer;

namespace SpecifyAnnotationProperties {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();

            // Load a document.
            pdfViewer1.LoadDocument("..\\..\\Demo.pdf");

            // Handle the TextMarkupAnnotationCreating event to specify the text markup annotation properties when the annotation is being created. 
            pdfViewer1.TextMarkupAnnotationCreating += pdfViewer1_TextMarkupAnnotationCreating;
        }

        private void pdfViewer1_TextMarkupAnnotationCreating(object sender, PdfTextMarkupAnnotationCreatingEventArgs e) {
            e.Author = "John Smith";
            e.Comment = "Note.";
            e.Color = Color.Gold;
        }
    }
}

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

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