VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf.UI.Annotations Namespace / PdfAnnotationTool Class / AddAndBuildAnnotation Methods / AddAndBuildAnnotation(PdfAnnotation) Method
Syntax Exceptions Example Requirements SeeAlso
In This Topic
    AddAndBuildAnnotation(PdfAnnotation) Method (PdfAnnotationTool)
    In This Topic
    Adds and builds the annotation.
    Syntax

    Parameters

    annotation
    The annotation to build.

    Return Value

    The annotation view that corresponds to the annotation.
    Exceptions
    ExceptionDescription
    Thrown if current image is not a PDF page.
    Example

    This C#/VB.NET code shows how to start the building of square annotation.

    
    ''' <summary>
    ''' Adds and builds a polyline annotation.
    ''' </summary>
    ''' <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
    Public Shared Sub AddAndBuildPolylineeAnnotation(annotationTool As Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationTool)
        Dim focusedPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = annotationTool.FocusedPage
        If focusedPage Is Nothing Then
            Throw New System.InvalidOperationException()
        End If
    
        ' create a PDF annotation
        Dim annotation As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(focusedPage)
        annotation.BorderWidth = 5
        annotation.Color = System.Drawing.Color.Red
        annotation.InteriorColor = System.Drawing.Color.Green
        annotation.StartPointLineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.ClosedArrow
    
        ' if tool mode does not allow to build annotation
        If annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.None OrElse annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.View Then
            ' change the tool mode
            annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.Markup
        End If
    
        ' add and build the annotation
        annotationTool.AddAndBuildAnnotation(annotation)
    End Sub
    
    
    
    /// <summary>
    /// Adds and builds a polyline annotation.
    /// </summary>
    /// <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
    public static void AddAndBuildPolylineeAnnotation(Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationTool annotationTool)
    {
        Vintasoft.Imaging.Pdf.Tree.PdfPage focusedPage = annotationTool.FocusedPage;
        if (focusedPage == null)
            throw new System.InvalidOperationException();
    
        // create a PDF annotation
        Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation annotation = 
            new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(focusedPage);
        annotation.BorderWidth = 5;
        annotation.Color = System.Drawing.Color.Red;
        annotation.InteriorColor = System.Drawing.Color.Green;
        annotation.StartPointLineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.ClosedArrow;
    
        // if tool mode does not allow to build annotation
        if (annotationTool.InteractionMode == Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.None ||
            annotationTool.InteractionMode == Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.View)
            // change the tool mode
            annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationInteractionMode.Markup;
    
        // add and build the annotation
        annotationTool.AddAndBuildAnnotation(annotation);
    }
    
    

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also