GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldFileSelect Method
A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: AddTextFormField(Single,Single,Single,Single,String,String,Boolean,String,Single,Byte,Byte,Byte), GetFormFieldId or GetFormFieldChildID.
Example





In This Topic
GetFormFieldFileSelect Method (GdPicturePDF)
In This Topic
Returns, if the FileSelect flag of a required form field, here a text field, is set. The text field is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.

If this flag is set, then the text entered in the text field represents the pathname of a file whose content are to be submitted as the value of the text field. By submission it is meant the use of the submit-form action, unfortunately the GdPicturePDF doesn't support this feature yet. The current value of the specified text field always represents the text entered in this field, please do not confuse it with the content of the file, whose pathname represents the text field value.

Syntax
'Declaration
 
Public Function GetFormFieldFileSelect( _
   ByVal FieldId As Integer _
) As Boolean
public bool GetFormFieldFileSelect( 
   int FieldId
)
public function GetFormFieldFileSelect( 
    FieldId: Integer
): Boolean; 
public function GetFormFieldFileSelect( 
   FieldId : int
) : boolean;
public: bool GetFormFieldFileSelect( 
   int FieldId
) 
public:
bool GetFormFieldFileSelect( 
   int FieldId
) 

Parameters

FieldId
A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: AddTextFormField(Single,Single,Single,Single,String,String,Boolean,String,Single,Byte,Byte,Byte), GetFormFieldId or GetFormFieldChildID.

Return Value

true if the FileSelect flag of the specified text field is set, otherwise false. 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.

Just to remind you that this method is only meaningful for text fields, otherwise it will fail.

Likewise, be aware that the GdPicturePDF class doesn't support the submit-form action yet.

Example
How to find out if the text field is used for file selection and how to subsequently find out the name of the file to submit.
Dim caption As String = "Example: GetFormFieldFileSelect"
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
        If count > 0 Then message = message + "These text fields are set for file selection:" + vbCrLf
        Dim formID As Integer = 0
        Dim value As String = "", name As String = ""
        Dim fileSelect As Boolean = False
        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()
                type = gdpicturePDF.GetFormFieldType(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    If type = PdfFormFieldType.PdfFormFieldTypeText Then
                        fileSelect = gdpicturePDF.GetFormFieldFileSelect(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            If fileSelect Then
                                message = message + ". field named "
                                name = gdpicturePDF.GetFormFieldTitle(formID)
                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                    message = message + name
                                Else
                                    message = message + gdpicturePDF.GetStat().ToString()
                                End If
                                message = message + " - file to be submitted: "
                                value = gdpicturePDF.GetFormFieldValue(formID)
                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                    message = message + value
                                Else
                                    message = message + gdpicturePDF.GetStat().ToString()
                                End If
                            End If
                        Else
                            message = message + "GetFormFieldFileSelect failed: " + gdpicturePDF.GetStat().ToString()
                        End If
                    End If
                Else
                    message = message + "GetFormFieldType failed: " + 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: GetFormFieldFileSelect";
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";
        if (count > 0)
            message = message + "These text fields are set for file selection:\n";
        int formID = 0;
        string value = "", name = "";
        bool fileSelect = false;
        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();
                type = gdpicturePDF.GetFormFieldType(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    if (type == PdfFormFieldType.PdfFormFieldTypeText)
                    {
                        fileSelect = gdpicturePDF.GetFormFieldFileSelect(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        {
                            if (fileSelect)
                            {
                                message = message + ". field named ";
                                name = gdpicturePDF.GetFormFieldTitle(formID);
                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                    message = message + name;
                                else
                                    message = message + gdpicturePDF.GetStat().ToString();
                                message = message + " - file to be submitted: ";
                                value = gdpicturePDF.GetFormFieldValue(formID);
                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                    message = message + value;
                                else
                                    message = message + gdpicturePDF.GetStat().ToString();
                            }
                        }
                        else
                            message = message + "GetFormFieldFileSelect failed: " + gdpicturePDF.GetStat().ToString();
                    }
                }
                else
                    message = message + "GetFormFieldType failed: " + 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