Text Markup Annotations

  • 4 minutes to read

When reviewing a document, you often need to draw attention to some important text the author can change later.

The PDF Viewer allows you to highlight, strikethrough, or underline text. You can also change the markup annotation properties (for example, add a comment to an annotation) or delete an annotation from a document.


The document includes the following sections:

Create Text Markup Annotation

To highlight, strikethrough or underline text, use:

  • The corresponding text markup tool located in the viewer's Comment toolbar


    The text markup tools are available after opening a document in the PDF Viewer.

    To add a markup to text:

    • Click the corresponding tool button (for example, Highlight);
    • Select the text.

    The image below shows the text highlighted in the default color.


  • the PdfViewer.CursorMode property.

    To markup text:

  • The viewer's context menu

    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.


To highlight, strikethrough or underline selected text in code, call one of the PdfViewer.HighlightSelectedText, PdfViewer.StrikethroughSelectedText or PdfViewer.UnderlineSelectedText overload methods.

Change default markup tool settings

You can customize the default markup tool settings that are applied to newly created markups.

To access the markup tool settings, use the PdfViewer.MarkupToolsSettings property.


You can change, for example, the default color used to underline a text using the PdfMarkupToolsSettings.TextUnderlineColor property.

To change the default markup color at runtime, click the drop-down arrow in the corresponding text markup tool and select the required color.


The default markup settings can also be modified using the Annotation Properties dialog. See the Editing Text Markup Annotation section to learn how to invoke this dialog.

When the markup annotation is being created in a document, it raises the PdfViewer.TextMarkupAnnotationCreating event. In this event, you can specify the markup annotation properties (for example, the annotation author using the PdfTextMarkupAnnotationCreatingEventArgs.Author property) and prohibit creating annotation.

Refer to the How to: Specify the Text Markup Annotation Properties When the Annotation is being Created example to learn more.

The PdfViewer class also provides the PdfViewer.TextMarkupAnnotationCreated event. This event is raised after the markup annotation is created. In this event, you can obtain the name of a created annotation using the PdfTextMarkupAnnotationCreatedEventArgs.Name property.

When a markup annotation receives or loses the input focus, the PdfViewer.MarkupAnnotationGotFocus or PdfViewer.MarkupAnnotationLostFocus event is raised. In these events, you can obtain markup annotation info using the PdfMarkupAnnotationGotFocusEventArgs.Info and PdfMarkupAnnotationLostFocusEventArgs.Info properties correspondingly. These properties return the PdfMarkupAnnotationInfo object.

Edit Text Markup Annotation

You can change the markup annotation properties using the Annotation Properties dialog.

For example, to add a comment to a markup annotation:

  • Right-click the annotation and choose the Properties... item in the context menu;


    This invokes the Annotation Properties dialog.


  • Type a text in the dialog's Comment text box.


  • To save changes, click OK.

    The Annotation Properties dialog also allows you to change default settings for annotation color, opacity, subject, and author. The default settings are applied to newly created markups. To set new settings as the default, click Set as Default.

    If you want to cancel changes, click Cancel.

    The PDF Viewer provides the PdfViewer.TextMarkupAnnotationChanged event. This event is raised after an end-user closes the Annotation Properties dialog if a text markup annotation has been changed. In this event, you can access the markup annotation settings (for example, the author of a text markup annotation using the PdfTextMarkupAnnotationChangedEventArgs.Author property).

    The comment is shown in the markup annotation's pop-up window.


The PDF Viewer also provides the PdfShowAnnotationPropertiesCommand command to invoke this annotation properties dialog in code.

Remove Text Markup Annotation

To remove an annotation:

  • Right-click the annotation;
  • Choose the Delete item in the invoked context menu.



  • Select the annotation and press the Delete key.

You can also use the PdfDeleteAnnotationCommand command to delete the selected annotation programmatically.

When the markup annotation is being deleted, it raises the PdfViewer.AnnotationDeleting event. In this event, you can obtain the annotation name, annotation bounds on a page and the page number using the PdfAnnotationDeletingEventArgs.Name, PdfAnnotationDeletingEventArgs.Rectangle, and PdfAnnotationDeletingEventArgs.PageNumber properties. You can also prohibit deleting the annotation from a page.