GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldPage Method
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.
Example





In This Topic
GetFormFieldPage Method (GdPicturePDF)
In This Topic
Returns the number of that page, where the required form field is located. The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The page is strictly given when adding the form field, it is the currently selected page. Already added form fields can't be moved between pages.
Syntax
'Declaration
 
Public Function GetFormFieldPage( _
   ByVal FieldId As Integer _
) As Integer
public int GetFormFieldPage( 
   int FieldId
)
public function GetFormFieldPage( 
    FieldId: Integer
): Integer; 
public function GetFormFieldPage( 
   FieldId : int
) : int;
public: int GetFormFieldPage( 
   int FieldId
) 
public:
int GetFormFieldPage( 
   int FieldId
) 

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

The page number, where the specified form field is located. 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 inform you, that already added form fields can't be moved between pages.

Example
How to determine the pages, where all form fields in the current document are located.
Dim caption As String = "Example: GetFormFieldPage"
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, pagenr As Integer = 0
        Dim name As String = ""
        Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
        For i As Integer = 0 To count - 1
            'Getting the form field unique identifier.
            formID = gdpicturePDF.GetFormFieldId(i)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                message = message + (i + 1).ToString() + ". "
                'Getting the form fields' title (name).
                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 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 field's page.
                message = message + "  page nr."
                pagenr = gdpicturePDF.GetFormFieldPage(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    message = message + pagenr.ToString()
                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: GetFormFieldPage";
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, pagenr = 0;
        string name = "";
        PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
        for (int i = 0; i < count; i++)
        {
            //Getting the form field unique identifier.
            formID = gdpicturePDF.GetFormFieldId(i);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                message = message + (i + 1).ToString() + ". ";
                //Getting the form fields' title (name).
                name = gdpicturePDF.GetFormFieldTitle(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    message = message + name;
                else
                    message = message + gdpicturePDF.GetStat().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 field's page.
                message = message + "  page nr.";
                pagenr = gdpicturePDF.GetFormFieldPage(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    message = message + pagenr.ToString();
                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