Search

Atalasoft Knowledge Base

HOWTO: Burn Annotations Without UI Elements

Administrator
DotImage

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

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

Details
Last Modified: 4 Months Ago
Last Modified By: Administrator
Type: HOWTO
Article not rated yet.
Article has been viewed 32 times.
Options
Also In This Category