LoadAnnotationsFromXMP(Stream) Method
In This Topic
Loads the GdPicture/XMP annotations from an instantiated Stream object containing XML formatted data, that has been previously generated using the
AnnotationManager.SaveAnnotationsToXMP method or the
AnnotationManager.SaveAnnotationsToXMPEx method. The loaded annotations are subsequently applied to the document currently handled by this AnnotationManager object to the selected page or all pages, respectively. This means that the loaded annotations will replace the current annotations presented in the document.
Be aware that this method only handles GdPicture/XMP annotations.
Syntax
Parameters
- Stream
- A System.IO.Stream object containing the properly formatted XML annotations data.
This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP(annotStream) = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Dispose()
annotStream.Dispose()
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP(annotStream) == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Dispose();
annotStream.Dispose();
Example
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP(annotStream) = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Dispose()
annotStream.Dispose()
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP(annotStream) == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Dispose();
annotStream.Dispose();
See Also