GetFormFieldItemValue Method (GdPicturePDF)
In This Topic
Returns the (export) value of a specific item of a choice form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The item is identified by its index, that simply represents its position in the item's list.
The item's value is an export value assigned to the specified option, it can be different than the item's text.
Syntax
'Declaration
Public Function GetFormFieldItemValue( _
ByVal As Integer, _
ByVal As Integer _
) As String
public string GetFormFieldItemValue(
int ,
int
)
public function GetFormFieldItemValue(
: Integer;
: Integer
): String;
public function GetFormFieldItemValue(
: int,
: int
) : String;
public: string* GetFormFieldItemValue(
int ,
int
)
public:
String^ GetFormFieldItemValue(
int ,
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: GdPicturePDF.AddComboFormField, GdPicturePDF.AddListFormField, GdPicturePDF.GetFormFieldId or GdPicturePDF.GetFormFieldChildID.
- ItemIdx
- The index of the required item. It must be a value from 0 to GdPicturePDF.GetFormFieldItemCount-1.
Return Value
A string representing the value of the selected item. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to retrieve all items and their values in all list boxes in the current document.
Dim caption As String = "Example: GetFormFieldItemValue"
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: GetFormFieldItemValue";
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();
See Also
Reference
GdPicturePDF Class
GdPicturePDF Members
GetFormFieldItemText Method
GetFormFieldsCount Method
GetFormFieldId Method
GetFormFieldChildID Method
GetFormFieldType Method
AddComboFormField(Single,Single,Single,Single,String,String,Single,Byte,Byte,Byte,Boolean) Method
AddListFormField(Single,Single,Single,Single,String,String,Single,Byte,Byte,Byte,Boolean,Boolean) Method