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
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.
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();
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