usmanazizgroupdocs
3/15/2016 - 5:43 PM

ExportAnnotationInFile.vb

' For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET
' Create instance of annotator. 
Dim cfg As AnnotationConfig = CommonUtilities.GetConfiguration()

Dim annotator As New AnnotationImageHandler(cfg)

' Get file stream
Dim manifestResourceStream As Stream = New FileStream(CommonUtilities.MapSourceFilePath(filePath), FileMode.Open, FileAccess.ReadWrite)
Dim annotations As New List(Of AnnotationInfo)()

Dim stream As Stream = annotator.ExportAnnotationsToDocument(manifestResourceStream, annotations, DocumentType.Pdf)

' Save result stream to file.
Using fileStream As New FileStream(CommonUtilities.MapDestinationFilePath("Annotated.pdf"), FileMode.Create)
    Dim buffer As Byte() = New Byte(stream.Length - 1) {}
    stream.Seek(0, SeekOrigin.Begin)
    stream.Read(buffer, 0, buffer.Length)
    fileStream.Write(buffer, 0, buffer.Length)
    fileStream.Close()