Back to Devexpress

PdfViewer.AnnotationCreating Event

windowsforms-devexpress-dot-xtrapdfviewer-dot-pdfviewer-507d1fc7.md

latest4.3 KB
Original Source

PdfViewer.AnnotationCreating Event

Fires before the annotation is created.

Namespace : DevExpress.XtraPdfViewer

Assembly : DevExpress.XtraPdfViewer.v25.2.dll

NuGet Package : DevExpress.Win.PdfViewer

Declaration

csharp
public event PdfAnnotationCreatingEventHandler AnnotationCreating
vb
Public Event AnnotationCreating As PdfAnnotationCreatingEventHandler

Event Data

The AnnotationCreating event's data class is PdfAnnotationCreatingEventArgs. The following properties provide information specific to this event:

PropertyDescription
BuilderGets the object used to build an annotation.
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.

Remarks

The AnnotationCreating event fires when the user creates an annotation from the User Interface or after one of the following methods are called:

MethodDescription
PdfViewer.HighlightSelectedTextHighlights selected text.
PdfViewer.StrikethroughSelectedTextMarks the selected text with a strikeout line.
PdfViewer.UnderlineSelectedTextUnderlines the selected text.
PdfViewer.AddStickyNoteAdds 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.

csharp
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";
    }
}
vb
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

PdfViewer Class

PdfViewer Members

DevExpress.XtraPdfViewer Namespace