Dim caption As String = "Example: GetFormFieldItemText"
Dim message As String = ""
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) <> GdPictureStatus.OK Then
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If count = 0 Then
message = "This document includes no form fields."
GoTo [error]
End If
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If type = PdfFormFieldType.PdfFormFieldTypeList Then
Dim title As String = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "listbox: " + title
Dim itemsCount As Integer = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " items: " + itemsCount + vbCrLf
Dim text As String = "", value As String = ""
For j As Integer = 0 To itemsCount - 1
text = gdpicturePDF.GetFormFieldItemText(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "text: " + text
Else
message = message + "text: " + gdpicturePDF.GetStat().ToString()
End If
value = gdpicturePDF.GetFormFieldItemValue(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " value: " + value
Else
message = message + " value: " + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Next
Else
message = message + vbCrLf + "The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Else
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
End If
Next
[error]:
If message.Equals("") Then message = "This document includes no list boxes."
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemText";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) != GdPictureStatus.OK)
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (count == 0)
{
message = "This document includes no form fields.";
goto error;
}
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
string title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "listbox: " + title;
int itemsCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + " items: " + itemsCount + "\n";
string text = "", value = "";
for (int j = 0; j < itemsCount; j++)
{
text = gdpicturePDF.GetFormFieldItemText(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + "text: " + text;
else
message = message + "text: " + gdpicturePDF.GetStat().ToString();
value = gdpicturePDF.GetFormFieldItemValue(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " value: " + value;
else
message = message + " value: " + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "\nThe GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
else
{
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
}
error:
if (message.Equals(""))
message = "This document includes no list boxes.";
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();