GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / DisplayFromStream Method / DisplayFromStream(Stream) Method
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
Example





In This Topic
DisplayFromStream(Stream) Method
In This Topic
Loads a document from an instantiated Stream object according to what you have specified and subsequently displays it in the GdViewer control. The document previously displayed in the control will automatically close.

All document formats currently supported by the toolkit are listed here.

The BeforeDocumentChange and the AfterDocumentChange events are raised just before and right after the document is displayed in the GdViewer control. Both events are only raised if the document has been successfully loaded.

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

Parameters

Stream
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.

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
Be aware that files with no header information in their internal structure, like text files or .svg files, will not display using this method. Please use the %DisplayFromStream(Stream, DocumentFormat)% or the DisplayFromStream(Stream,String) methods instead.

Just to remind you that both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.

Example
How to display your PDF document from a stream.
'We assume that the GdViewer1 control has been properly integrated.
Dim file As System.IO.Stream = New System.IO.FileStream("image.tif", System.IO.FileMode.Open)
If GdViewer1.DisplayFromStream(file) = GdPictureStatus.OK Then
    'Do your stuff here.
Else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromStream")
End If
file.Dispose()
//We assume that the GdViewer1 control has been properly integrated.
System.IO.Stream file = new System.IO.FileStream("image.tif", System.IO.FileMode.Open);
if (GdViewer1.DisplayFromStream(file) == GdPictureStatus.OK)
{
    //Do your stuff here.
}
else
{
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromStream");
}
file.Dispose();
See Also