GroupDocsGists
10/19/2017 - 11:28 AM

SaveOutputDocument.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)

Dim documentRepository As IDocumentDataHandler = annotator.GetDocumentDataHandler()
If Not Directory.Exists(cfg.StoragePath) Then
    Directory.CreateDirectory(cfg.StoragePath)
End If

Dim result As Stream = annotator.ExportAnnotationsToDocument(inputFile, annotations, DocumentType.Pdf)

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