Dim caption As String = "Example: ExtractPageImage"
Dim gdpicturePDFSrc As New GdPicturePDF()
If gdpicturePDFSrc.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDFSrc.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDFSrc.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
'The first page is automatically selected as the current page.
Dim imageCount As Integer = gdpicturePDFSrc.GetPageImageCount()
status = gdpicturePDFSrc.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim gdpicturePDFDest As New GdPicturePDF()
If gdpicturePDFDest.NewPDF() = GdPictureStatus.OK Then
Dim message As String = ""
Dim imageID As Integer = 0
For i As Integer = 1 To imageCount
imageID = gdpicturePDFSrc.ExtractPageImage(i)
status = gdpicturePDFSrc.GetStat()
If status = GdPictureStatus.OK Then
Dim res_name As String = gdpicturePDFDest.AddImageFromGdPictureImage(imageID, False, True)
status = gdpicturePDFSrc.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The image nr. " + i.ToString() + " has been successfully drawn." + vbCrLf
Else
message = message + "The AddImageFromGdPictureImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
If GdPictureDocumentUtilities.DisposeImage(imageID) <> GdPictureStatus.OK Then
message = message + "The DisposeImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The ExtractPageImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDFDest.SaveToFile("test_ExtractPageImage.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDFDest.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDFDest.GetStat().ToString(), caption)
End If
gdpicturePDFDest.Dispose()
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any image.", caption)
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDFSrc.Dispose()
string caption = "Example: ExtractPageImage";
GdPicturePDF gdpicturePDFSrc = new GdPicturePDF();
if (gdpicturePDFSrc.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDFSrc.GetPageCount();
GdPictureStatus status = gdpicturePDFSrc.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
//The first page is automatically selected as the current page.
int imageCount = gdpicturePDFSrc.GetPageImageCount();
status = gdpicturePDFSrc.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
GdPicturePDF gdpicturePDFDest = new GdPicturePDF();
if (gdpicturePDFDest.NewPDF() == GdPictureStatus.OK)
{
string message = "";
int imageID = 0;
for (int i = 1; i <= imageCount; i++)
{
imageID = gdpicturePDFSrc.ExtractPageImage(i);
status = gdpicturePDFSrc.GetStat();
if (status == GdPictureStatus.OK)
{
string res_name = gdpicturePDFDest.AddImageFromGdPictureImage(imageID, false, true);
status = gdpicturePDFSrc.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The image nr. " + i.ToString() + " has been successfully drawn.\n";
else
message = message + "The AddImageFromGdPictureImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
if (GdPictureDocumentUtilities.DisposeImage(imageID) != GdPictureStatus.OK)
message = message + "The DisposeImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The ExtractPageImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDFDest.SaveToFile("test_ExtractPageImage.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDFDest.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDFDest.GetStat().ToString(), caption);
gdpicturePDFDest.Dispose();
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", caption);
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDFSrc.Dispose();