GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / LoadFromStream Method
A Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Specifies whether the instance is in charge of disposing the input stream when it is not needed anymore. Default value is false.
Example





In This Topic
LoadFromStream Method (GdPicturePDF)
In This Topic
Loads the PDF document from a previously instantiated Stream object according to what you have specified. The only supported file format for the input stream is the PDF format.
Syntax
'Declaration
 
Public Function LoadFromStream( _
   ByVal Stream As Stream, _
   Optional ByVal OwnStream As Boolean _
) As GdPictureStatus
public GdPictureStatus LoadFromStream( 
   Stream Stream,
   bool OwnStream
)
public function LoadFromStream( 
    Stream: Stream;
    OwnStream: Boolean
): GdPictureStatus; 
public function LoadFromStream( 
   Stream : Stream,
   OwnStream : boolean
) : GdPictureStatus;
public: GdPictureStatus LoadFromStream( 
   Stream* Stream,
   bool OwnStream
) 
public:
GdPictureStatus LoadFromStream( 
   Stream^ Stream,
   bool OwnStream
) 

Parameters

Stream
A Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
OwnStream
Specifies whether the instance is in charge of disposing the input stream when it is not needed anymore. Default value is false.

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 origin's location and the measurement unit for any loaded document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.

The document's first page is automatically set as the current page after loading.

Sometimes a PDF document can be password protected. You can use the IsEncrypted method to determine if a PDF is encrypted or not. If it is encrypted, you should use the SetPassword method to decrypt it with the user or owner password.

Please note that the input stream should remain open and can only be closed/disposed of by the user after a call to the CloseDocument is made.

This method requires the PDF Processing component to run.

Example
How to find out the number of pages in a PDF document loaded from a stream.
Dim PdfDoc As System.IO.Stream = New System.IO.FileStream("test.pdf", System.IO.FileMode.Open)
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromStream(PdfDoc)
If status = GdPictureStatus.OK Then
    MessageBox.Show("This PDF document contains " + gdpicturePDF.GetPageCount().ToString() + " pages.", "Example: LoadFromStream")
Else
    MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: LoadFromStream")
End If
gdpicturePDF.Dispose()
PdfDoc.Dispose()
System.IO.Stream PdfDoc = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open);
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromStream(PdfDoc);
if (status == GdPictureStatus.OK)
{
    MessageBox.Show("This PDF document contains " + gdpicturePDF.GetPageCount().ToString() + " pages.", "Example: LoadFromStream");
}
else
{
    MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: LoadFromStream");
}
gdpicturePDF.Dispose();
PdfDoc.Dispose();
See Also