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
FilePathorStream— The destination of the document you want to save, either to a file or aStream. Quality— The compression quality level between0(lowest quality and highest compression) and100(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);Using annotationManager As AnnotationManager = New AnnotationManager() ' Load a JPG image to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\source.jpg")
' Create an `AnnotationRubberStamp` object. Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp ' 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)End Using