GroupDocsGists
10/19/2017 - 11:29 AM

AddTextReplacementAnnotation.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)()

    ' Text replacement annotation
    Dim textReplacementAnnotation As New AnnotationInfo() With { _
          .Box = New Rectangle(CSng(101.76), CSng(826.73), CSng(229), 27), _
          .PageNumber = 1, _
          .SvgPath = "[{""x"":101.76,""y"":264.69},{""x"":331,""y"":264.69},{""x"":101.76,""y"":243.06},{""x"":331,""y"":243}]", _
          .Type = AnnotationType.TextReplacement, _
          .CreatorName = "Anonym A.", _
          .FieldText = "Replaced text", _
          .FontSize = 10 _
    }
    ' Add annotation to list
    annotations.Add(textReplacementAnnotation)
    ' Export annotation and save output file
    CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf)
Catch exp As Exception
    Console.WriteLine(exp.Message)
End Try