[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Collapse]PDF Viewer
   [Expand]Getting Started
   [Expand]Navigation
   [Collapse]Access and Edit Document Content
    [Expand]Interactive Form
     File Attachment
     Text Markup Annotations
     Content Copying
     Printing
   [Expand]Interactivity
   [Expand]Examples
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Text Markup Annotations

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:

Expanded Creating 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 viewer's context menu

    To add a markup to text:

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

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

Changing 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 PdfViewerControl.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 PdfViewerControl.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: Create a Text Markup Annotation and Specify its Properties example to learn more.

The PdfViewerControl class also provides the PdfViewerControl.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 PdfViewerControl.MarkupAnnotationGotFocus or PdfViewerControl.MarkupAnnotationLostFocus event is raised. In these events you can obtain markup annotation info using the MarkupAnnotationGotFocusEventArgs.Info and MarkupAnnotationLostFocusEventArgs.Info properties correspondingly. These properties return the PdfMarkupAnnotationInfo object.

Expanded Editing 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 PdfViewerControl.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 PdfViewerControl.ShowAnnotationPropertiesCommand command to invoke this annotation properties dialog in code.

Expanded Removing Text Markup Annotation

To remove an annotation:

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

  • or...

  • Select the annotation and press the Delete key.

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

When the markup annotation is being deleted, it raises the PdfViewerControl.AnnotationDeleting event. In this event, you can obtain the annotation name, annotation bounds on a page and the page number using the AnnotationDeletingEventArgs.Name, AnnotationDeletingEventArgs.Rectangle, and AnnotationDeletingEventArgs.PageNumber properties. In addition, you can prohibit deleting the annotation from a page using the AnnotationDeletingEventArgs.Cancel property.

Is this topic helpful?​​​​​​​