PdfViewerControl.TextMarkupAnnotationCreating Event
Occurs when a text markup annotation (highlight, strikethrough or underline) is being created.
Namespace: DevExpress.Xpf.PdfViewer
Assembly: DevExpress.Xpf.PdfViewer.v18.2.dll
Declaration
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 | Specifies whether to prohibit text markup annotation creation for a selected text. |
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. |
Handled | Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs. |
IsSelected | Gets or sets 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. |
OriginalSource | Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs. |
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. |
RoutedEvent | Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs. |
SelectedText | Gets a selected text for which a markup annotation is being created on a page. |
Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
Style | Specifies the style of a text markup annotation. |
Subject | Specifies a short description of the subject being addressed by the text markup annotation. |
The event data class exposes the following methods:
Method | Description |
---|---|
InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
Remarks
You can prohibit the text markup annotation creation for a selected text by setting the PdfTextMarkupAnnotationCreatingEventArgs.Cancel property to true.
Example
This example shows how to create a markup annotation that highlights a selected text. To create this annotation for a selected text, call one of the PdfViewerControl.HighlightSelectedText overload methods.
To specify the annotation properties when the markup annotation is being created, handle the PdfViewerControl.TextMarkupAnnotationCreating
event.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-create-a-text-markup-annotation-and-specify-its-properties-t574531.
using System.Windows;
using DevExpress.Pdf;
using DevExpress.Xpf.PdfViewer;
namespace MarkupAnnotations {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
// Load a document.
viewer.OpenDocument("..\\..\\Demo.pdf");
// Handle the TextMarkupAnnotationCreating event to specify the annotation properties.
viewer.TextMarkupAnnotationCreating += Viewer_TextMarkupAnnotationCreating;
}
private void Viewer_TextMarkupAnnotationCreating(DependencyObject d, PdfTextMarkupAnnotationCreatingEventArgs e) {
e.Author = "John Smith";
e.Comment = "Note.";
e.Color = System.Windows.Media.Color.FromRgb(229, 214, 0);
}
private void viewer_DocumentLoaded(object sender, RoutedEventArgs e) {
// Select the document area where the markup annotation will be created.
viewer.Select(new PdfDocumentArea(1, new PdfRectangle(90, 100, 240, 230)));
// Highlight a selected text.
viewer.HighlightSelectedText();
}
}
}