Save a file from the annotation manager in C#

To JPG

To save a document created with the AnnotationManager class to a JPG image with GdPicture XMP annotation support, use the SaveDocumentToJPEG method. It can save the document to a file or a Stream object

and uses the following parameters:

  • Either FilePath or Stream — The destination of the document you want to save, either to a file or a Stream.
  • Quality — The compression quality level between 0 (lowest quality and highest compression) and 100 (highest quality and lowest compression).

To include the annotations in the document’s content, use the BurnAnnotationsToPage method.

To save a JPG image from the AnnotationManager object, use the following code:

using AnnotationManager annotationManager= new AnnotationManager();
// Load a JPG image to the `AnnotationManager` object.
annotationManager.InitFromFile(@"C:\temp\source.jpg");
// Create an `AnnotationRubberStamp` object.
GdPicture14.Annotations.AnnotationRubberStamp stamp;
// Add the stamp to the `AnnotationManager` object.
stamp = annotationManager.AddRubberStampAnnot(Color.Red,
0.5f, 0.5f, 2, 1, "APPROVED");
stamp.Rotation = 20;
// Save the annotation to the `AnnotationManager` object.
annotationManager.SaveAnnotationsToPage();
// Flatten the annotation.
annotationManager.BurnAnnotationsToPage(false);
// Save the document as a JPG image.
annotationManager.SaveDocumentToJPEG(@"C:\temp\output.jpg", 100);