GetFormFieldChildID Method (GdPicturePDF)
In This Topic
Returns the unique form field identifier of an immediate child, specified by its index related to the required parent form field.
This parent form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Syntax
'Declaration
Public Function GetFormFieldChildID( _
ByVal As Integer, _
ByVal As Integer _
) As Integer
public int GetFormFieldChildID(
int ,
int
)
public function GetFormFieldChildID(
: Integer;
: Integer
): Integer;
public function GetFormFieldChildID(
: int,
: int
) : int;
public: int GetFormFieldChildID(
int ,
int
)
public:
int GetFormFieldChildID(
int ,
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required parent form field object. You can obtain this identifier using the GetFormFieldId method and all methods intended to add form fields.
- FieldIdx
- The 0-based index of the required form field child of the specified parent form field. It must be a value from 0 to GetFormFieldChildCount-1.
Return Value
A unique form field identifier of the specified child form field. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to find out the number of kids and their types of all form fields in the current document.
Dim caption As String = "Example: GetFormFieldChildID"
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 status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0, chCount As Integer = 0, kidsID As Integer = 0
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() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString() + " number of kids: "
chCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + chCount.ToString()
For j As Integer = 0 To chCount - 1
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + vbCrLf + " " + (j + 1).ToString() + ".kid's type: "
type = gdpicturePDF.GetFormFieldType(kidsID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + "The GetFormFieldChildID() method has failed with the status: " + status.ToString()
Exit For
End If
Next
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
If status <> GdPictureStatus.OK Then Exit For
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
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: GetFormFieldChildID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0, chCount = 0, kidsID = 0 ;
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() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type.ToString() + " number of kids: ";
chCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + chCount.ToString();
for (int j = 0; j < chCount; j++)
{
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "\n " + (j + 1).ToString() + ".kid's type: ";
type = gdpicturePDF.GetFormFieldType(kidsID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "\nThe GetFormFieldChildID() method has failed with the status: " + status.ToString();
break;
}
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
if (status != GdPictureStatus.OK)
break;
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
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();
Example
How to find out the number of kids and their types of all form fields in the current document.
Dim caption As String = "Example: GetFormFieldChildID"
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 status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0, chCount As Integer = 0, kidsID As Integer = 0
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() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString() + " number of kids: "
chCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + chCount.ToString()
For j As Integer = 0 To chCount - 1
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + vbCrLf + " " + (j + 1).ToString() + ".kid's type: "
type = gdpicturePDF.GetFormFieldType(kidsID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + "The GetFormFieldChildID() method has failed with the status: " + status.ToString()
Exit For
End If
Next
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
If status <> GdPictureStatus.OK Then Exit For
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
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: GetFormFieldChildID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0, chCount = 0, kidsID = 0 ;
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() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type.ToString() + " number of kids: ";
chCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + chCount.ToString();
for (int j = 0; j < chCount; j++)
{
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "\n " + (j + 1).ToString() + ".kid's type: ";
type = gdpicturePDF.GetFormFieldType(kidsID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "\nThe GetFormFieldChildID() method has failed with the status: " + status.ToString();
break;
}
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
if (status != GdPictureStatus.OK)
break;
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
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