PdfViewer.AnnotationCreating Event
Fires before the annotation is created.
Namespace: DevExpress.XtraPdfViewer
Assembly: DevExpress.XtraPdfViewer.v24.2.dll
NuGet Package: DevExpress.Win.PdfViewer
#Declaration
public event PdfAnnotationCreatingEventHandler AnnotationCreating
#Event Data
The AnnotationCreating event's data class is PdfAnnotationCreatingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Builder | Gets the object used to build an annotation. |
Cancel |
Gets or sets a value indicating whether the event should be canceled.
Inherited from Cancel |
#Remarks
The AnnotationCreating event fires when the user creates an annotation from the User Interface or after one of the following methods are called:
Method | Description |
---|---|
Pdf |
Highlights selected text. |
Pdf |
Marks the selected text with a strikeout line. |
Pdf |
Underlines the selected text. |
Pdf |
Adds a sticky note at the specified position. |
The PdfAnnotationCreatingEventArgs.Builder property retrieves the annotation parameters. Use the PdfViewerAnnotationBuilderExtensions class methods to obtain a specific type of annotation..
The following code shows how to handle the PdfViewer.AnnotationCreating
event.
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPdfViewer;
private void pdfViewer1_TextMarkupAnnotationCreating(object sender,
PdfAnnotationCreatingEventArgs e)
{
//Specify options for text markup and text annotations:
if (e.Builder.AnnotationType == PdfAnnotationType.TextMarkup
|| e.Builder.AnnotationType == PdfAnnotationType.Text)
{
//Retrieve common options for text and text markup annotations:
var annotationBuilder = e.Builder.AsMarkupAnnotationBuilder();
annotationBuilder.Author = "John Smith";
annotationBuilder.Color = new PdfRGBColor(0.20, 0.60, 1.00);
annotationBuilder.Contents = "Note";
}
}