Dim caption As String = "Example: GetFormFieldFontColor"
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 = "", ftitle As String = ""
Dim formID As Integer = 0, kids As Integer = 0
Dim hasRB As Boolean = False
Dim fcolor As Color = Color.White
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 = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: "
Exit For
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: "
Exit For
End If
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
ftitle = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: "
Exit For
End If
fcolor = gdpicturePDF.GetFormFieldFontColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The font/text color is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font color is " + fcolor.ToString() + " - same for all children." + vbCrLf
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The font/text color is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: "
Exit For
End If
message = message + ftitle + " radio button - font/text color is different for child buttons." + vbCrLf
For j As Integer = 0 To kids - 1
fcolor = gdpicturePDF.GetFormFieldFontColor(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontColor() finished with the status: "
Exit For
End If
message = message + " " + (j + 1).ToString() + ".child - font color: " + fsize.ToString() + vbCrLf
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Else
'This is an error in getting the font/text color.
message = "The radio button " + ftitle + " - GetFormFieldFontColor() finished with the status: " + gdpicturePDF.GetStat()
Exit For
End If
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
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: GetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", ftitle = "";
int formID = 0, kids = 0;
bool hasRB = false;
Color fcolor = Color.White;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: ";
break;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: ";
break;
}
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
ftitle = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: ";
break;
}
fcolor = gdpicturePDF.GetFormFieldFontColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The font/text color is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font color is " + fcolor.ToString() + " - same for all children.\n";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The font/text color is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: ";
break;
}
message = message + ftitle + " radio button - font color is different for child buttons.\n";
for (int j = 0; j < kids; j++)
{
fcolor = gdpicturePDF.GetFormFieldFontColor(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontColor() finished with the status: ";
break;
}
message = message + " " + (j + 1).ToString() + ".child - font color: " + fsize.ToString() + "\n";
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
else
{
//This is an error in getting the font/text color.
message = "The radio button " + ftitle + " - GetFormFieldFontColor() finished with the status: " + gdpicturePDF.GetStat();
break;
}
}
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
}
else message = message + gdpicturePDF.GetStat().ToString();
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();