GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / DisplayFromStream Method / DisplayFromStream(Stream,DocumentFormat,String) 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.
A member of the DocumentFormat enumeration. The format of the source document, that is stored in the Stream parameter. The toolkit will automatically recognize the type of the document based on the format to be able to display the required file.

Optional parameter. If provided, specifies the password to be used to decrypt the specified PDF document allowing the control to read its content.

Example





In This Topic
DisplayFromStream(Stream,DocumentFormat,String) 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.

This method is useful for files, that have no header information in their internal structure, like text files or .svg files, as you can specify their document format to allow the toolkit with certainty to recognize the file for display.

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, _
   ByVal DocumentFormat As DocumentFormat, _
   Optional ByVal Password As String _
) As GdPictureStatus
public GdPictureStatus DisplayFromStream( 
   Stream Stream,
   DocumentFormat DocumentFormat,
   string Password
)
public function DisplayFromStream( 
    Stream: Stream;
    DocumentFormat: DocumentFormat;
    Password: String
): GdPictureStatus; 
public function DisplayFromStream( 
   Stream : Stream,
   DocumentFormat : DocumentFormat,
   Password : String
) : GdPictureStatus;
public: GdPictureStatus DisplayFromStream( 
   Stream* Stream,
   DocumentFormat DocumentFormat,
   string* Password
) 
public:
GdPictureStatus DisplayFromStream( 
   Stream^ Stream,
   DocumentFormat DocumentFormat,
   String^ Password
) 

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.
DocumentFormat
A member of the DocumentFormat enumeration. The format of the source document, that is stored in the Stream parameter. The toolkit will automatically recognize the type of the document based on the format to be able to display the required file.
Password

Optional parameter. If provided, specifies the password to be used to decrypt the specified PDF document allowing the control to read its content.

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
Just to remind you that both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.
Example
How to display a simple textfile from a stream.
'We assume that the GdViewer1 control has been properly integrated.
Dim file As System.IO.Stream = New System.IO.FileStream("text.txt", System.IO.FileMode.Open)
If GdViewer1.DisplayFromStream(file, GdPicture14.DocumentFormat.DocumentFormatTXT) = 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("text.txt", System.IO.FileMode.Open);
if (GdViewer1.DisplayFromStream(file, GdPicture14.DocumentFormat.DocumentFormatTXT) == 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