VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Wpf.UI.Annotations Namespace / WpfPdfAnnotationTool Class / AddAndBuildAnnotation Method / AddAndBuildAnnotation(PdfAnnotation) Method
The annotation to build.
Example



In This Topic
    AddAndBuildAnnotation(PdfAnnotation) Method
    In This Topic
    Adds and builds the annotation.
    Syntax
    'Declaration
     
    Public Overloads Function AddAndBuildAnnotation( _
       ByVal annotation As PdfAnnotation _
    ) As WpfPdfAnnotationView
    public WpfPdfAnnotationView AddAndBuildAnnotation( 
       PdfAnnotation annotation
    )
    public: WpfPdfAnnotationView* AddAndBuildAnnotation( 
       PdfAnnotation* annotation
    ) 
    public:
    WpfPdfAnnotationView^ AddAndBuildAnnotation( 
       PdfAnnotation^ annotation
    ) 

    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 example shows how to start 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.Wpf.UI.Annotations.WpfPdfAnnotationTool)
    	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.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.None OrElse annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.View Then
    		' change the tool mode
    		annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.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.Wpf.UI.Annotations.WpfPdfAnnotationTool 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.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.None ||
            annotationTool.InteractionMode == Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.View)
            // change the tool mode
            annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.Markup;
                
        // add and build the annotation
        annotationTool.AddAndBuildAnnotation(annotation);
    }
    Requirements

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

    See Also