GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / LoadAnnotationsFromXMP Method / LoadAnnotationsFromXMP(Stream) Method
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.
Example





In This Topic
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 SaveAnnotationsToXMP(Stream) method or the SaveAnnotationsToXMPEx(Stream) 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
'Declaration
 
Public Overloads Function LoadAnnotationsFromXMP( _
   ByVal Stream As Stream _
) As GdPictureStatus
public GdPictureStatus LoadAnnotationsFromXMP( 
   Stream Stream
)
public function LoadAnnotationsFromXMP( 
    Stream: Stream
): GdPictureStatus; 
public function LoadAnnotationsFromXMP( 
   Stream : Stream
) : GdPictureStatus;
public: GdPictureStatus LoadAnnotationsFromXMP( 
   Stream* Stream
) 
public:
GdPictureStatus LoadAnnotationsFromXMP( 
   Stream^ Stream
) 

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.

Remarks
The input stream should remain open and can only be closed/disposed of by the user as well.

Be aware that the loaded annotations will replace the current annotations presented in the document. For adding new annotations you can use the AddAnnotationFromXML method.

This method requires the Annotations component to run.

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