GetFormFieldValue(Int32) Method
In This Topic
Returns the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The value's format varies depending on the type of the form field. This method returns the string representation of the field's current value.
Syntax
'Declaration
Public Overloads Function GetFormFieldValue( _
ByVal As Integer _
) As String
public string GetFormFieldValue(
int
)
public function GetFormFieldValue(
: Integer
): String;
public function GetFormFieldValue(
: int
) : String;
public: string* GetFormFieldValue(
int
)
public:
String^ GetFormFieldValue(
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GdPicturePDF.GetFormFieldId, GdPicturePDF.GetFormFieldChildID or methods intended to add form fields.
Return Value
A string representation of the current value of the specified form field. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to determine all used form fields in the document, their types, names and values.
Dim caption As String = "Example: GetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim name As String = "", value As String = ""
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 = message + (i + 1).ToString() + ". "
'Getting the form field's type.
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form fields' title (name).
message = message + " title: "
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's value.
message = message + " value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
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: GetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string name = "", value = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form field's type.
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form fields' title (name).
message = message + " title: ";
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's value.
message = message + " value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, 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();
Example
How to determine all used form fields in the document, their types, names and values.
Dim caption As String = "Example: GetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim name As String = "", value As String = ""
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 = message + (i + 1).ToString() + ". "
'Getting the form field's type.
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form fields' title (name).
message = message + " title: "
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's value.
message = message + " value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
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: GetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string name = "", value = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form field's type.
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form fields' title (name).
message = message + " title: ";
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's value.
message = message + " value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, 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();
See Also