SaveToFile(String,Boolean) Method
Packs and saves the currently loaded PDF document to a file according to a file path you have specified.
Please note that you can highly reduce the file size of the PDF document by enabling the use of the standard compression mechanism during saving.
'Declaration
Public Overloads Function SaveToFile( _
ByVal As String, _
ByVal As Boolean _
) As GdPictureStatus
Parameters
- FilePath
- The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter to true in the previously called GdPicturePDF.LoadFromFile method.
- 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.
How to save the PDF document with enabled pack mode.
Dim caption As String = "Example: SaveToFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("Input.pdf", False) = GdPictureStatus.OK Then
'The file will save without being compressed.
gdpicturePDF.EnableCompression(False)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SaveToFile("uncompressed.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
If gdpicturePDF.SaveToFile("uncompressed_pack.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and with packing has been successful.", caption)
End If
'The file will save using the compression mechanism.
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SaveToFile("compressed.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
If gdpicturePDF.SaveToFile("compressed_pack.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SaveToFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("Input.pdf", false) == GdPictureStatus.OK)
{
//The file will save without being compressed.
gdpicturePDF.EnableCompression(false);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SaveToFile("uncompressed.pdf", false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
if (gdpicturePDF.SaveToFile("uncompressed_pack.pdf", true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and with packing has been successful.", caption);
}
//The file will save using the compression mechanism.
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SaveToFile("compressed.pdf", false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
if (gdpicturePDF.SaveToFile("compressed_pack.pdf", true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
error:
gdpicturePDF.Dispose();