Atalasoft Knowledge Base

HOWTO: Burn Annotations Without UI Elements


This KB article will introduce and show you how to use the BurnedFileImageSource example class. The BurnedFileImageSource takes a path to your document and a LayerCollection then returns to you images with those annotations rendered on to them. It's very useful for burning annotations while saving a document as it is an ImageSource and can be directly passed in to both the PdfEncoder and TiffEncoder.


string documentPath = "Path to your document";
string annotationsPath "Path to your annotations";
string newDocumentPath "Path to your newly saved document";

using(AnnotationController ac = new AnnotationController())
    //Load the annotations.
    ac.Load(annotationsPath, AnnotationDataFormat.Xmp);
    //Pass the document path and annotation layers

    using (BurnedFileImageSource burnedImages = new BurnedFileImageSource(documentPath, ac.Layers))
        //You can swap out the PdfEncoder for the TiffEncoder without changing anything else.
        MultiFramedImageEncoder encoder = new PdfEncoder();

        using(Stream newDocumentStream = 
        File.Open(newDocumentPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
            encoder.Save(newDocumentStream,burnedImages, null);


Dim documentPath As String = "Path to your document"
Dim annotationsPath As String = "Path to your annotations"
Dim newDocumentPath As String = "Path to your newly saved document"

'You can get the LayerCollection a number of ways, but the AnnotationController is the simplest.
Using ac As New AnnotationController
    'Load the annotations
    ac.Load(annotationsPath, AnnotationDataFormat.Xmp)

    'Pass the document path and annotation layers
    Using burnedImages As New BurnedFileImageSource(documentPath, ac.Layers)
        'You can swap out the PdfEncoder for the TiffEncoder without changing anything else.
         Dim encoder As New PdfEncoder()
         Using newDocumentStream As Stream = File.Open(newDocumentPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read)
             encoder.Save(newDocumentStream, burnedImages, Nothing)
        End Using
    End Using
End Using 

Original Article:
Q10397 - HOWTO: Burning Annotations Without UI Elements

Last Modified: 2 Weeks Ago
Last Modified By: Tananda
Article not rated yet.
Article has been viewed 937 times.
Also In This Category