GdPicture.NET.14
GdPicture14 Namespace / GdViewer 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 displayed in the GdViewer control to the current 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.

The method only handles GdPicture/XMP annotations 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.

Example
How to transfer GdPicture/XMP annotations from one document to another.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
            
'Assuming you have already annotated the displayed document.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
If GdViewer1.SaveAnnotationsToXMPEx(annotStream) = GdPictureStatus.OK Then
    GdViewer1.CloseDocument()
    If (GdViewer1.DisplayFromFile("test.pdf") = GdPictureStatus.OK) AndAlso
       (GdViewer1.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
        GdViewer1.Redraw()
        If GdViewer1.SaveDocumentToPDF("test_annotated.pdf") = GdPictureStatus.OK Then
            MessageBox.Show("Done!", "GdViewer.LoadAnnotationsFromXMP")
        Else
            MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.LoadAnnotationsFromXMP")
        End If
    Else
        MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.LoadAnnotationsFromXMP")
    End If
End If
annotStream.Dispose()
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
            
//Assuming you have already annotated the displayed document.
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
if (GdViewer1.SaveAnnotationsToXMPEx(annotStream) == GdPictureStatus.OK)
{
    GdViewer1.CloseDocument();
    if ((GdViewer1.DisplayFromFile("test.pdf") == GdPictureStatus.OK) &&
        (GdViewer1.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
    {
        GdViewer1.Redraw();
        if (GdViewer1.SaveDocumentToPDF("test_annotated.pdf") == GdPictureStatus.OK)
            MessageBox.Show("Done!", "GdViewer.LoadAnnotationsFromXMP");
        else
            MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.LoadAnnotationsFromXMP");
    }
    else
    {
        MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.LoadAnnotationsFromXMP");
    }
}
annotStream.Dispose();
See Also