Save a file from the annotation manager in C#
To PDF
To save a document created with the AnnotationManager
class to a PDF file with GdPicture XMP annotation support, use the SaveDocumentToPDF
method. It can save the document to a file or a Stream
object
and uses the file path as a string or a Stream
object as its parameter.
To include the annotations in the document’s content, use the BurnAnnotationsToPage
method.
To save a PDF file from the AnnotationManager
object, use the following code:
using AnnotationManager annotationManager= new AnnotationManager();// Load a PDF file to the `AnnotationManager` object.annotationManager.InitFromFile(@"C:\temp\source.pdf");
// Select the first page.annotationManager.SelectPage(1);
// 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 PDF file.annotationManager.SaveDocumentToPDF(@"C:\temp\output.pdf", 100);
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load a PDF file to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\source.pdf")
' Select the first page. annotationManager.SelectPage(1)
' 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 PDF file. annotationManager.SaveDocumentToPDF("C:\temp\output.pdf", 100)End Using