Load an XML file for the annotation manager in C#
XML
To load XMP or GdPicture annotations stored in an XML file or a Stream
object to the AnnotationManager
object, use the LoadAnnotationsFromXMP
method. As its parameter, this method requires either the full path of the XML file or a stream object containing XML data. This method replaces all annotations previously added to the AnnotationManager
object.
The AnnotationManager
object only handles GdPicture and XMP annotations contained in the source document.
To apply annotations from a template image to another image, use the following code:
using AnnotationManager annotationManager = new AnnotationManager();// Load the template image to the `AnnotationManager` object.annotationManager.InitFromFile(@"C:\temp\template.jpg");// Save the annotations from the template image to an XML file.annotationManager.SaveAnnotationsToXMP(@"C:\temp\annotTemplate.xml");// Load the source image to the `AnnotationManager` object.annotationManager.InitFromFile(@"C:\temp\source.jpg");// Load the XML file with the annotations to the `AnnotationManager` object.annotationManager.LoadAnnotationsFromXMP(@"C:\temp\annotTemplate.xml");// Flatten the annotations into the image.annotationManager.BurnAnnotationsToPage(false);// Save the image to a file.annotationManager.SaveDocumentToJPEG(@"C:\temp\output.jpg", 100);
Using annotationManager As AnnotationManager = New AnnotationManager() ' Load the template image to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\template.jpg") ' Save the annotations from the template image to an XML file. annotationManager.SaveAnnotationsToXMP("C:\temp\annotTemplate.xml") ' Load the source image to the `AnnotationManager` object. annotationManager.InitFromFile("C:\temp\source.jpg") ' Load the XML file with the annotations to the `AnnotationManager` object. annotationManager.LoadAnnotationsFromXMP("C:\temp\annotTemplate.xml") ' Flatten the annotations into the image. annotationManager.BurnAnnotationsToPage(False) ' Save the image to a file. annotationManager.SaveDocumentToJPEG("C:\temp\output.jpg", 100)End Using