GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SaveToStream Method / SaveToStream(Stream,Boolean) Method
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.
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.

Example





In This Topic
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
'Declaration
 
Public Overloads Function SaveToStream( _
   ByVal Stream As Stream, _
   ByVal PackDocument As Boolean _
) As GdPictureStatus
public GdPictureStatus SaveToStream( 
   Stream Stream,
   bool PackDocument
)
public function SaveToStream( 
    Stream: Stream;
    PackDocument: Boolean
): GdPictureStatus; 
public function SaveToStream( 
   Stream : Stream,
   PackDocument : boolean
) : GdPictureStatus;
public: GdPictureStatus SaveToStream( 
   Stream* Stream,
   bool PackDocument
) 
public:
GdPictureStatus SaveToStream( 
   Stream^ Stream,
   bool PackDocument
) 

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.

Remarks
The output stream should be open for writing and should be closed/disposed of by the user as well.

The pack mode is an option allowing the removal of any unused PDF objects and to better compress some other objects before saving the PDF document. Using this option leads to recreation of a brand new PDF document by cloning all existing pages of the current document onto a brand new document.

You can also combine this parameter with the standard compression mechanism as well as you can benefit from using the RemoveUnusedResources method to eliminate all unused resources from your saved PDF document.

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