usmanazizgroupdocs
3/15/2016 - 5:40 PM

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

    ' Distance annotation
    Dim distanceAnnotation As New AnnotationInfo() With { _
          .AnnotationPosition = New Point(852.0, 287.0), _
          .Box = New Rectangle(248.0F, 287.0F, 115.0F, 25.0F), _
          .PageNumber = 0, _
          .PenColor = 1201033, _
          .PenStyle = 0, _
          .PenWidth = 1, _
          .SvgPath = "M248.73201877934272,295.5439436619718 l115.28309859154929,-4.192112676056338", _
          .Text = vbCr & vbLf & "Anonym A.: 115px", _
          .Type = AnnotationType.Distance, _
          .CreatorName = "Anonym A." _
    }
    ' Add annotation to list
    annotations.Add(distanceAnnotation)
    ' Export annotation and save output file
    CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf)
Catch exp As Exception
    Console.WriteLine(exp.Message)
End Try