Dim caption As String = "Example: GetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
If gdpicturePDF.LoadFromFile("forms_checkbox.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim isChecked As Boolean = False, hasCheckBoxes As Boolean = False
Dim onName As String = "", userSelection As String = ""
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
hasCheckBoxes = True
isChecked = gdpicturePDF.GetFormFieldChecked(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
onName = gdpicturePDF.GetFormFieldOnStateName(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If isChecked Then
userSelection = userSelection + "They " + onName + " our product." + vbCrLf
Else
userSelection = userSelection + "They do not " + onName + " our product." + vbCrLf
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If Not hasCheckBoxes Then userSelection = "This file doesn't include check boxes." + vbCrLf
Else
userSelection = userSelection + "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(userSelection, 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
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
if (gdpicturePDF.LoadFromFile("forms_checkbox.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool isChecked = false, hasCheckBoxes = false;
string onName = "", userSelection = "";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
hasCheckBoxes = true;
isChecked = gdpicturePDF.GetFormFieldChecked(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
onName = gdpicturePDF.GetFormFieldOnStateName(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isChecked)
userSelection = userSelection + "They " + onName + " our product.\n";
else
userSelection = userSelection + "They do not " + onName + " our product.\n";
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (!hasCheckBoxes)
userSelection = "This file doesn't include check boxes.\n";
}
else
userSelection = userSelection + "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(userSelection,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);
gdpicturePDF.Dispose();