Home : Burning Annotations Without UI Elements
Q10397 - HOWTO: Burning 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.

C#

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

//You can get the LayerCollection a number of ways, but the AnnotationController is the simplest.
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);
    }
}

VB.Net

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

Java

String documentPath = "Path to your document";
String annotationsPath = "Path to your annotations";
String newDocumentPath = "Path to your newly saved document";
com.atalasoft.demos.BurnedFileImageSource burnedImages = new BurnedFileImageSource(documentPath, annotationsPath);
PdfEncoder encoder = new PdfEncoder();
FileImageOutputStream newDocumentStream = new FileImageOutputStream(new File(newDocumentPath));
encoder.save(newDocumentStream, burnedImages, null);
newDocumentStream.flush();
newDocumentStream.close();
burnedImages.dispose();
Related Articles
No Related Articles Available.

Article Attachments
BurnedFileImageSource_CS.zip
BurnedFileImageSource_VB.zip
BurnedFileImageSource_java.zip

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved