VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf.UI.Annotations Namespace / PdfAnnotationTool Class / AddAndBuildAnnotation Method / AddAndBuildAnnotation(PdfAnnotationView) Method
The annotation view.
Example



In This Topic
    AddAndBuildAnnotation(PdfAnnotationView) Method
    In This Topic
    Adds and builds the annotation view.
    Syntax
    'Declaration
     
    Public Overloads Sub AddAndBuildAnnotation( _
       ByVal view As PdfAnnotationView _
    ) 
    public void AddAndBuildAnnotation( 
       PdfAnnotationView view
    )
    public: void AddAndBuildAnnotation( 
       PdfAnnotationView* view
    ) 
    public:
    void AddAndBuildAnnotation( 
       PdfAnnotationView^ view
    ) 

    Parameters

    view
    The annotation view.

    Return Value

    The annotation view that corresponds to the annotation.
    Exceptions
    ExceptionDescription
    Thrown if current image is not a PDF page.
    Example
    This example shows how to start the building of freehand polyline annotation.
    ''' <summary>
    ''' Adds and builds a freehand polyline annotation.
    ''' </summary>
    ''' <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
    Public Shared Sub AddAndBuildFreehandPolylineAnnotation(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 the PDF annotation
        Dim annotation As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(focusedPage)
        annotation.BorderWidth = 5
        annotation.Color = System.Drawing.Color.Red
                
        ' 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
                
        ' create the annotation view because view parameters must be changed
        Dim view As Vintasoft.Imaging.Pdf.UI.Annotations.PdfPolygonalAnnotationView = New Vintasoft.Imaging.Pdf.UI.Annotations.PdfPolylineAnnotationView(annotation, annotationTool.FocusedJsDoc)
        ' set the builder for annotation view
        view.Builder = New Vintasoft.Imaging.UI.VisualTools.UserInteraction.PointBasedObjectFreehandBuilder(view, 2, 0.1F)
                
        ' add and build annotation
        annotationTool.AddAndBuildAnnotation(view)
    End Sub
    /// <summary>
    /// Adds and builds a freehand polyline annotation.
    /// </summary>
    /// <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
    public static void AddAndBuildFreehandPolylineAnnotation(
        Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationTool annotationTool)
    {
        Vintasoft.Imaging.Pdf.Tree.PdfPage focusedPage = annotationTool.FocusedPage;
        if (focusedPage == null)
            throw new System.InvalidOperationException();
                
        // create the 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;
                
        // 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;
                
        // create the annotation view because view parameters must be changed
        Vintasoft.Imaging.Pdf.UI.Annotations.PdfPolygonalAnnotationView view = 
            new Vintasoft.Imaging.Pdf.UI.Annotations.PdfPolylineAnnotationView(annotation, annotationTool.FocusedJsDoc);
        // set the builder for annotation view
        view.Builder = new Vintasoft.Imaging.UI.VisualTools.UserInteraction.PointBasedObjectFreehandBuilder(view, 2, 0.1f);
                
        // add and build annotation
        annotationTool.AddAndBuildAnnotation(view);
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also