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
orStream
— 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
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
To save a document created with the AnnotationManager
class to a TIFF image with GdPicture XMP annotation support, use the SaveDocumentToTIFF
method. It can save the document to a file or a Stream
object
and uses the following parameters:
-
Either
FilePath
orStream
— The destination of the document you want to save, either to a file or aStream
. -
Compression
— A member of theTiffCompression
enumeration. It specifies the compression method.
To include the annotations in the document’s content, use the
BurnAnnotationsToPage
method.
To save a TIFF image from the AnnotationManager
object, use the following code:
using AnnotationManager annotationManager= new AnnotationManager(); // Load a TIFF image to the `AnnotationManager` object. annotationManager.InitFromFile(@"C:\temp\source.tiff"); // 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 TIFF image. annotationManager.SaveDocumentToTIFF(@"C:\temp\output.tiff", 100);
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load a TIFF image to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\source.tiff") ' 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 TIFF image. annotationManager.SaveDocumentToTIFF("C:\temp\output.tiff", 100) End Using
GdPicture.NET SDK allows you to save GdPicture XMP annotations located in a file with the SaveAnnotationsToXMP
and SaveAnnotationsToXMPEx
methods. They allow you to do the following:
-
Save annotations from a specific page of a multipage file.
-
Save annotations from all pages of a multipage file.
Saving Annotations from an Image
To save GdPicture XMP annotations created with the AnnotationManager
class from an image to an XML file or a Stream
object, use the SaveAnnotationsToXMP
method. It uses the file path as a string or a Stream
object as its parameter.
To save annotations from an image, use the following code:
using AnnotationManager annotationManager= new AnnotationManager(); // Load an 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(); // Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMP(@"C:\temp\output.xml");
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load an 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() ' Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMP("C:\temp\output.xml") End Using
Saving Annotations from a Specific Page
To save the GdPicture XMP annotations created with the AnnotationManager
class from a specific document page to an XML file or a Stream
object, use the SaveAnnotationsToXMP
method. It uses the file path as a string, or a Stream
object as its parameter.
Use the
SelectPage
method for multipage files like PDF documents and TIFF images.
To save annotations on the first page of a PDF document, use the following code:
using AnnotationManager annotationManager= new AnnotationManager(); // Load a PDF document 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(); // Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMP(@"C:\temp\output.xml");
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load a PDF document 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() ' Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMP("C:\temp\output.xml") End Using
Saving Annotations from All Pages
To save the GdPicture XMP annotations created with the AnnotationManager
class from all pages of a multipage file to an XML file or a Stream
object, use the SaveAnnotationsToXMPEx
method. It uses the file path as a string or a Stream
object as its parameter.
To save annotations from all pages of a PDF document, use the following code:
using AnnotationManager annotationManager= new AnnotationManager(); // Load a PDF document to the `AnnotationManager` object. annotationManager.InitFromFile(@"C:\temp\source.pdf"); // 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(); // Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMPEx(@"C:\temp\output.xml");
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load a PDF document to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\source.pdf") ' 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() ' Save the annotation to an XML file. annotationManager.SaveAnnotationsToXMPEx("C:\temp\output.xml") End Using