Dim caption As String = "Example: GetFormFieldsNeedAppearances"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim formsCount As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If formsCount > 0 Then
If (gdpicturePDF.GetFormFieldsNeedAppearances() = False) AndAlso
(gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
'Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(True)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = 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
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
If gdpictureImaging.SaveAsPNG(image_index, filename) = 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: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldsNeedAppearances";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int formsCount = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (formsCount > 0)
{
if ((gdpicturePDF.GetFormFieldsNeedAppearances() == false) &&
(gdpicturePDF.GetStat() == GdPictureStatus.OK))
//Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(true);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
if (gdpictureImaging.SaveAsPNG(image_index, filename) == 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: " + gdpicturePDF.GetStat().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: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();