Export XMP annotation data in C# .NET
XMP
XMP annotations can be stored in one of the following ways:
- XML file
Streamobject- Base64-encoded string
To export XMP annotations from the currently opened file in the AnnotationManager object, use the SaveAnnotationsToXMP method for XML files and Stream objects, and the SaveAnnotationsToXMPBase64 method for the encoded string.
In the following example, the XMP annotations from a template image are applied to another image:
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 UsingUsed methods
Related topics