'We assume that GdPicture has been correctly installed and unlocked.
Dim oGdPicturePDF AsNew GdPicturePDF()
Dim status As GdPictureStatus
'Loading your PDF document into the GdPicturePDF object.
status = oGdPicturePDF.LoadFromFile("input.pdf", False)
If status = GdPictureStatus.OK Then'Enabling compression.
oGdPicturePDF.EnableCompression(True)
'Saving the compressed PDF document without packing.
status = oGdPicturePDF.SaveToFile("compressed.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("Error occurred when saving the compressed PDF document without packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndIf'Saving the compressed PDF document with packing.
status = oGdPicturePDF.SaveToFile("compressed_pack.pdf", True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("Error occurred when saving the compressed PDF document with packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndIf'Disabling compression.
oGdPicturePDF.EnableCompression(False)
'Saving the uncompressed PDF document without packing (the largest size).
status = oGdPicturePDF.SaveToFile("uncompressed.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("Error occurred when saving the uncompressed PDF document without packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndIf'Saving the uncompressed PDF document with packing.
status = oGdPicturePDF.SaveToFile("uncompressed_pack.pdf", True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("Error occurred when saving the uncompressed PDF document with packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndIf'Closing the document.
oGdPicturePDF.CloseDocument()
Else
MessageBox.Show("The document can't be loaded. Status: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
EndIf
oGdPicturePDF.Dispose()
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
GdPictureStatus status = default(GdPictureStatus);
//Loading your PDF document into the GdPicturePDF object.
status = oGdPicturePDF.LoadFromFile("input.pdf", false);
if (status == GdPictureStatus.OK)
{
//Enabling compression.
oGdPicturePDF.EnableCompression(true);
//Saving the compressed PDF document without packing.
status = oGdPicturePDF.SaveToFile("compressed.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Error occurred when saving the compressed PDF document without packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//Saving the compressed PDF document with packing.
status = oGdPicturePDF.SaveToFile("compressed_pack.pdf", true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Error occurred when saving the compressed PDF document with packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//Disabling compression.
oGdPicturePDF.EnableCompression(false);
//Saving the uncompressed PDF document without packing (the largest size).
status = oGdPicturePDF.SaveToFile("uncompressed.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Error occurred when saving the uncompressed PDF document without packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//Saving the uncompressed PDF document with packing.
status = oGdPicturePDF.SaveToFile("uncompressed_pack.pdf", true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Error occurred when saving the uncompressed PDF document with packing: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//Closing the document.
oGdPicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The document can't be loaded. Status: " + oGdPicturePDF.GetStat().ToString(), "Compress and Pack Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
oGdPicturePDF.Dispose();