Skip to main content
All docs
V25.1
  • PdfViewer.AnnotationCreating Event

    Fires before the annotation is created.

    Namespace: DevExpress.XtraPdfViewer

    Assembly: DevExpress.XtraPdfViewer.v25.1.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 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:

    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";
        }
    }
    
    See Also