Dim caption As String = "Example: RenderPageToGdPictureImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True, PixelFormat.Format32bppArgb)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true, PixelFormat.Format32bppArgb);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index)
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, 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);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();