GroupDocsGists
10/19/2017 - 11:29 AM

AddTextAnnotation.vb

' For complete examples and data files, please go to https://github.com/groupdocsannotation/GroupDocs_Annotation_NET
Try
    ' Get input file stream
    Dim inputFile As Stream = New FileStream(CommonUtilities.MapSourceFilePath(filePath), FileMode.Open, FileAccess.ReadWrite)

    ' Initialize list of AnnotationInfo
    Dim annotations As New List(Of AnnotationInfo)()

    ' Initialize text annotation.
    Dim textAnnotation As New AnnotationInfo() With { _
        .Box = New Rectangle(CSng(265.44), CSng(153.86), 206, 36), _
        .PageNumber = 0, _
        .SvgPath = "[{""x"":265.44,""y"":388.83},{""x"":472.19,""y"":388.83},{""x"": 265.44,""y"":349.14},{""x"":472.19,""y"":349.14}]", _
        .Type = AnnotationType.Text, _
        .CreatorName = "Anonym A." _
    }

    ' Add annotation to list
    annotations.Add(textAnnotation)

    ' Export annotation and save output file
    CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf)
Catch exp As Exception
    Console.WriteLine(exp.Message)
End Try