GetFormFieldOnStateName(Int32) Method
In This Topic
Returns the string representation of the normal appearance (the On state) of a required form field, here a check box, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a check box and it is used when a check box is not interacting with the user and for printing. As said, this method is only applicable to check boxes.
If this attribute is not defined for the specified check box, then the resulting value for the On state is "On" by default.
Syntax
'Declaration
Public Overloads Function GetFormFieldOnStateName( _
ByVal As Integer _
) As String
public string GetFormFieldOnStateName(
int
)
public function GetFormFieldOnStateName(
: Integer
): String;
public function GetFormFieldOnStateName(
: int
) : String;
public: string* GetFormFieldOnStateName(
int
)
public:
String^ GetFormFieldOnStateName(
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: GdPicturePDF.AddCheckBoxFormField, GdPicturePDF.GetFormFieldId or GdPicturePDF.GetFormFieldChildID.
Return Value
A string representation of the On state of the specified check box. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to utilize the value representing the On state attribute of check boxes.
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();
Example
How to utilize the value representing the On state attribute of check boxes.
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();
See Also
Reference
GdPicturePDF Class
GdPicturePDF Members
Overload List
AddCheckBoxFormField(Single,Single,Single,Single,String,PdfCheckBoxStyle,Boolean,Byte,Byte,Byte) Method
GetFormFieldId Method
GetFormFieldChildID Method
GetStat Method
GetStat Method
SetFormFieldOnStateName(Int32,String) Method
GetFormFieldsCount Method
GetFormFieldId Method
GetFormFieldChildID Method
GetFormFieldType Method
AddCheckBoxFormField(Single,Single,Single,Single,String,PdfCheckBoxStyle,Boolean,Byte,Byte,Byte) Method