windowsforms-devexpress-dot-xtrapdfviewer-dot-pdfviewer-507d1fc7.md
Fires before the annotation is created.
Namespace : DevExpress.XtraPdfViewer
Assembly : DevExpress.XtraPdfViewer.v25.2.dll
NuGet Package : DevExpress.Win.PdfViewer
public event PdfAnnotationCreatingEventHandler AnnotationCreating
Public Event AnnotationCreating As PdfAnnotationCreatingEventHandler
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 CancelEventArgs. |
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 |
|---|---|
| PdfViewer.HighlightSelectedText | Highlights selected text. |
| PdfViewer.StrikethroughSelectedText | Marks the selected text with a strikeout line. |
| PdfViewer.UnderlineSelectedText | Underlines the selected text. |
| PdfViewer.AddStickyNote | 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";
}
}
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraPdfViewer
Private Sub pdfViewer1_TextMarkupAnnotationCreating(ByVal sender As Object,
ByVal e As PdfAnnotationCreatingEventArgs)
'Specify options for text markup and text annotations:
If e.Builder.AnnotationType = PdfAnnotationType.TextMarkup
OrElse e.Builder.AnnotationType = PdfAnnotationType.Text Then
'Retrieve common options for text and text markup annotations:
Dim annotationBuilder = e.Builder.AsMarkupAnnotationBuilder()
annotationBuilder.Author = "John Smith"
annotationBuilder.Color = New PdfRGBColor(0.20, 0.60, 1.00)
annotationBuilder.Contents = "Note"
End If
End Sub
See Also