Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim imageID As Integer = 0
For i As Integer = 1 To imageCount
imageID = gdpicturePDF.ExtractPageImage(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Do your stuff with the extracted image here.
' ...
'Dispose of the image after you have used it.
If GdPictureDocumentUtilities.DisposeImage(imageID) <> GdPictureStatus.OK Then
MessageBox.Show("The disposal of the image has failed. Status: " + status.ToString(), "GdPicture")
End If
End If
Next
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any image.", "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
End If
Else
MessageBox.Show("The file can't be loaded.", "GdPicture")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
int imageID = 0;
for (int i = 1; i <= imageCount; i++)
{
imageID = gdpicturePDF.ExtractPageImage(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Do your stuff with the extracted image here.
//...
//Dispose of the image after you have used it.
if (GdPictureDocumentUtilities.DisposeImage(imageID) != GdPictureStatus.OK)
MessageBox.Show("The disposal of the image has failed. Status: " + status.ToString(), "GdPicture");
}
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
}
}
else
MessageBox.Show("The file can't be loaded.", "GdPicture");
gdpicturePDF.Dispose();