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.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldOnStateName Method / GetFormFieldOnStateName(Int32) Method

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 FieldId As Integer _
) As String
public string GetFormFieldOnStateName( 
   int FieldId
)
public function GetFormFieldOnStateName( 
    FieldId: Integer
): String; 
public function GetFormFieldOnStateName( 
   FieldId : int
) : String;
public: string* GetFormFieldOnStateName( 
   int FieldId
) 
public:
String^ GetFormFieldOnStateName( 
   int FieldId
) 

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.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Just to remind you that this method is only meaningful for check boxes, otherwise it will fail. If this attribute is undefined for the specified check box, then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".

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