SaveToStream(Stream,Boolean) Method
In This Topic
Packs and saves the currently loaded PDF document to an instantiated Stream object according to what you have specified.
Syntax
Parameters
- Stream
- A Stream object where the currently loaded PDF 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.
- PackDocument
- Specifies if the toolkit has to pack the current document before the save process to reduce its size.
Set this parameter to true if you want to pack the PDF document before saving. Please note that the whole saving process can be as a result slower with some documents.
If you set this parameter to false, the PDF document will remain unpacked after the save process.
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 save the PDF document to a stream with enabled compression and packing.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create)
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToStream(oFileStream, True)
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream")
End If
oFileStream.Dispose()
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create);
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToStream(oFileStream, true);
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream");
}
oFileStream.Dispose();
}
gdpicturePDF.Dispose();
Example
How to save the PDF document to a stream with enabled compression and packing.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create)
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToStream(oFileStream, True)
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream")
End If
oFileStream.Dispose()
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create);
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToStream(oFileStream, true);
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream");
}
oFileStream.Dispose();
}
gdpicturePDF.Dispose();
See Also