A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GetFormFieldId, GetFormFieldChildID or methods intended to add form fields.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldDefaultValue Method

GetFormFieldDefaultValue Method (GdPicturePDF)

In This Topic
Returns the default 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. It is a value to which the form field reverts when it is reset, that means reset-form action is executed. The format of this value is the same as defined for the field's current value attribute.
Syntax
'Declaration
 
Public Function GetFormFieldDefaultValue( _
   ByVal FieldId As Integer _
) As String
public string GetFormFieldDefaultValue( 
   int FieldId
)
public function GetFormFieldDefaultValue( 
    FieldId: Integer
): String; 
public function GetFormFieldDefaultValue( 
   FieldId : int
) : String;
public: string* GetFormFieldDefaultValue( 
   int FieldId
) 
public:
String^ GetFormFieldDefaultValue( 
   int FieldId
) 

Parameters

FieldId
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GetFormFieldId, GetFormFieldChildID or methods intended to add form fields.

Return Value

A string representation of the default value of the specified form field. The 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 GetStat method to identify the specific reason for the method's failure, if any.

Example
How to determine the current values and the default values for all used form fields in the document.
Dim caption As String = "Example: GetFormFieldDefaultValue"
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 = "", defValue As String = ""
        For i As Integer = 0 To count - 1
            formID = gdpicturePDF.GetFormFieldId(i)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                'Getting the form fields' title (name).
                message = message + "Form field "
                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 current value.
                message = message + ":  current value = "
                value = gdpicturePDF.GetFormFieldValue(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    message = message + value
                Else
                    message = message + gdpicturePDF.GetStat().ToString()
                End If
                'Getting the form field's default value.
                message = message + "    default value = "
                defValue = gdpicturePDF.GetFormFieldDefaultValue(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    message = message + defValue
                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: GetFormFieldDefaultValue";
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 = "", defValue = "";
        for (int i = 0; i < count; i++)
        {
            formID = gdpicturePDF.GetFormFieldId(i);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                //Getting the form fields' title (name).
                message = message + "Form field ";
                name = gdpicturePDF.GetFormFieldTitle(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    message = message + name;
                else
                    message = message + gdpicturePDF.GetStat().ToString();
                //Getting the form field's current value.
                message = message + ":  current value = ";
                value = gdpicturePDF.GetFormFieldValue(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    message = message + value;
                else
                    message = message + gdpicturePDF.GetStat().ToString();
                //Getting the form field's default value.
                message = message + "    default value = ";
                defValue = gdpicturePDF.GetFormFieldDefaultValue(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    message = message + defValue;
                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