GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / SaveAnnotationsToXMPEx Method / SaveAnnotationsToXMPEx(Stream) Method
A Stream object where all GdPicture/XMP annotations from the currently displayed document will be saved to. 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
SaveAnnotationsToXMPEx(Stream) Method
In This Topic
Saves the GdPicture/XMP annotation part of all pages of the document displayed in the GdViewer control in XML format to an instantiated Stream object according to what you have specified.

Be aware that this method only handles GdPicture/XMP annotations.

Syntax
'Declaration
 
Public Overloads Function SaveAnnotationsToXMPEx( _
   ByVal Stream As Stream _
) As GdPictureStatus
public GdPictureStatus SaveAnnotationsToXMPEx( 
   Stream Stream
)
public function SaveAnnotationsToXMPEx( 
    Stream: Stream
): GdPictureStatus; 
public function SaveAnnotationsToXMPEx( 
   Stream : Stream
) : GdPictureStatus;
public: GdPictureStatus SaveAnnotationsToXMPEx( 
   Stream* Stream
) 
public:
GdPictureStatus SaveAnnotationsToXMPEx( 
   Stream^ Stream
) 

Parameters

Stream
A Stream object where all GdPicture/XMP annotations from the currently displayed document will be saved to. 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 output stream should be open for writing and should be closed/disposed of by the user as well.

Be aware that this method handles all GdPicture/XMP annotations contained within the currently displayed document.

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.SaveAnnotationsToXMPEx")
        Else
            MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.SaveAnnotationsToXMPEx")
        End If
    Else
        MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.SaveAnnotationsToXMPEx")
    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.SaveAnnotationsToXMPEx");
        else
            MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.SaveAnnotationsToXMPEx");
    }
    else
    {
        MessageBox.Show("Error! : " + GdViewer1.GetStat().ToString(), "GdViewer.SaveAnnotationsToXMPEx");
    }
}
annotStream.Dispose();
See Also