Dim caption As String = "Example: SetCompressionForBitonalImage"
Dim oImage As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("input.tif")
If oImage.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = oImage.GetPageCount(imageID)
If oImage.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
'Secondly, set the required compression.
gdpicturePDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Process your document.
For i As Integer = 1 To count
status = oImage.SelectPage(imageID, i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
'Check, if all is done without errors.
If status = GdPictureStatus.OK Then
'At the end, save the file with the previously selected compression.
If gdpicturePDF.SaveToFile("output.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The SetCompressionForBitonalImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + oImage.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
End If
string caption = "Example: SetCompressionForBitonalImage";
GdPictureImaging oImage = new GdPictureImaging();
int imageID = oImage.CreateGdPictureImageFromFile("input.tif");
if (oImage.GetStat() == GdPictureStatus.OK)
{
int count = oImage.GetPageCount(imageID);
if (oImage.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
//Secondly, set the required compression.
gdpicturePDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Process your document.
for (int i = 1; i <= count; i++)
{
status = oImage.SelectPage(imageID, i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
//Check, if all is done without errors.
if (status == GdPictureStatus.OK)
{
//At the end, save the file with the previously selected compression.
if (gdpicturePDF.SaveToFile("output.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The SetCompressionForBitonalImage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + oImage.GetStat().ToString(), caption);
}
else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);