GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldCloneNumber 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
GetFormFieldCloneNumber Method (GdPicturePDF)
In This Topic
Returns the clone number 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. These clone numbers distinguish kids form fields belonging to one parent form field, if they have the same partial name (it is the feature supported by Acrobat when creating identically named form fields).
Syntax
'Declaration
 
Public Function GetFormFieldCloneNumber( _
   ByVal FieldId As Integer _
) As Integer
public int GetFormFieldCloneNumber( 
   int FieldId
)
public function GetFormFieldCloneNumber( 
    FieldId: Integer
): Integer; 
public function GetFormFieldCloneNumber( 
   FieldId : int
) : int;
public: int GetFormFieldCloneNumber( 
   int FieldId
) 
public:
int GetFormFieldCloneNumber( 
   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 clone number of the specified form field. 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 kids form fields, otherwise it will fail.

Example
How to retrieve full titles and clone numbers of the form fields in the current document.
Dim caption As String = "Example: GetFormFieldCloneNumber"
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 formID As Integer = 0, cloneNr As Integer = 0
        Dim message As String = "", fullTitle As String = "", withCloneNr As String = ""
        Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
        For i As Integer = 0 To count - 1
            formID = gdpicturePDF.GetFormFieldId(i)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                type = gdpicturePDF.GetFormFieldType(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + vbCrLf
                    fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID)
                    message = message + "    fullTitle="
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        message = message + fullTitle
                    Else
                        message = message + gdpicturePDF.GetStat().ToString()
                    End If
                    cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID)
                    message = message + ";  cloneNr="
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        message = message + cloneNr.ToString()
                    Else
                        message = message + gdpicturePDF.GetStat().ToString()
                    End If
                    withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID)
                    message = message + ";  titleWithCloneNr="
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        message = message + withCloneNr
                    Else
                        message = message + gdpicturePDF.GetStat().ToString()
                    End If
                Else
                    message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                End If
            Else
                message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                Exit For
            End If
            message += vbCrLf
        Next
        If count = 0 Then MessageBox.Show("This file doesn't include forms.", caption) Else 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: GetFormFieldCloneNumber";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        int formID = 0, cloneNr = 0;
        string message = "", fullTitle = "", withCloneNr = "";
        PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
        for (int i = 0; i < count; i++)
        {
            formID = gdpicturePDF.GetFormFieldId(i);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                type = gdpicturePDF.GetFormFieldType(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + "\n";
            
                    fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID);
                    message = message + "    fullTitle=";
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        message = message + fullTitle;
                    else
                        message = message + gdpicturePDF.GetStat().ToString();
            
                    cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID);
                    message = message + ";  cloneNr=";
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        message = message + cloneNr.ToString();
                    else
                        message = message + gdpicturePDF.GetStat().ToString();
            
                    withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID);
                    message = message + ";  titleWithCloneNr=";
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        message = message + withCloneNr;
                    else
                        message = message + gdpicturePDF.GetStat().ToString();
                }
                else
                    message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
            }
            else
            {
                message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
                break;
            }
            message += "\n";
        }
        if (count == 0)
            MessageBox.Show("This file doesn't include forms.", caption);
        else
            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