•  
  •  
  •  
 

Adding annotation to an AtalaImage

Last post 07 Jun 2009, 5:49 PM by cfforeman. 2 replies.
Sort Posts: Previous Next
  •  17 Apr 2009, 4:12 PM 18327

    Adding annotation to an AtalaImage

    Is it possible to add an Annotation to an AtalaImage without using the AnnotationViewer? When I print certain images to a PDF document, I would like to add an Annotation to each page.

     Thanks

     

    Ben

  •  29 Apr 2009, 11:08 AM 18380 in reply to 18327

    Re: Adding annotation to an AtalaImage

    Attachment: BurnAnnots.zip

    Yes you can -- Here are the basic steps:

    1. Create a LayerCollection, add a layer per page, add annotations to the appropriate layer

    2. Read each page from the PDF, burn the annotation to it

    3. Print the image

    If you do step one, use the attached code to do step 2 with this code (some cs files you need are attached):

    using System;

    using Atalasoft.Imaging.Extras;
    using Atalasoft.Annotate.UI;
    using Atalasoft.Imaging;
    using Atalasoft.Imaging.Codec;
    using Atalasoft.Imaging.Codec.Pdf;
    using System.Drawing;
    using Atalasoft.Annotate;

    namespace BurnAnnotOnPDF
    {
        class Program
        {
            static void Main(string[] args)
            {
                // register the PDF Reader
                RegisteredDecoders.Decoders.Add(new PdfDecoder());


                // create annotations
                LayerCollection coll = new LayerCollection();
                LayerAnnotation l = new LayerAnnotation();
                coll.Add(l);
                TextAnnotation t = new TextAnnotation("hello");
                t.Data.Location = new PointF(10f, 10f);
                t.Data.Size = new SizeF(50f, 50f);
                ((TextData)t.Data).Fill = new AnnotationBrush(Color.Yellow);
                l.Items.Add(t);

                // use burned image source to get them
                BurnedFileImageSource imgSource = new BurnedFileImageSource(@"answer sheet.pdf", coll);
                TiffEncoder asTiff = new TiffEncoder();
                asTiff.Append = false;
                while (imgSource.HasMoreImages())
                {
                    AtalaImage img = imgSource.AcquireNext();
                    img.Save("annotated.tiff", asTiff, null); // save to a tiff, you could print it here
                    asTiff.Append = true;
                }
            }
        }
    }

     

      

  •  07 Jun 2009, 5:49 PM 18596 in reply to 18380

    Re: Adding annotation to an AtalaImage

    Hi Lou,

    We are currently evaluating DotImage 7.0b for use in a large imaging project at my company.  I used the technique you mentioned here (with very slight modifications - just used PdfEncoder rather than TiffEncoder) to burn annotations onto a PDF file for printing.  Everything worked great, except the memory utilization was very high.  I just had a couple of text annotations on a 13-page PDF and it used several hundred megabytes of memory.  It also didn't seem to be releasing the memory after each attempt and I wound up with memory allocation issues.  In our application, we might wind up needing to create annotations on much larger files.

    Do you have any thoughts as to what might be causing this high memory utilization and the possible memory leak issue?  Also, do you generally recommend a 64-bit architecture when dealing with large multi-page documents and/or large format TIFF images (i.e. E-size Engineering drawings)?

    Thanks,

    Charlie

     

View as RSS news feed in XML