GetFormFieldFontSize(Int32,Int32) Method
In This Topic
Returns the size, in points, used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The font size attribute is not restricted to any form fields, meaning that this value also defines the size of the checkmark in the radio button field. Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Syntax
'Declaration
Public Overloads Function GetFormFieldFontSize( _
ByVal As Integer, _
ByVal As Integer _
) As Single
public float GetFormFieldFontSize(
int ,
int
)
public function GetFormFieldFontSize(
: Integer;
: Integer
): Single;
public function GetFormFieldFontSize(
: int,
: int
) : float;
public: float GetFormFieldFontSize(
int ,
int
)
public:
float GetFormFieldFontSize(
int ,
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: AddRadioButtonFormField(Single,Single,Single,Single,String,String,PdfCheckBoxStyle,Byte,Byte,Byte), GetFormFieldId or GetFormFieldChildID.
- ChildIdx
- The index of the required child radio button in a group. It must be a value from 0 to GetFormFieldChildCount-1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
Return Value
The size of the displayed checkmark, in points, of the specified child radio button. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to find out the correct font size defined for radio button fields.
Dim caption As String = "Example: GetFormFieldFontSize"
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 fsize As Single = 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 = (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
fsize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The font size is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font size is " + fsize.ToString() + " - same for all children." + vbCrLf
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The font size 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 size is different for child buttons." + vbCrLf
For j As Integer = 0 To kids - 1
fsize = gdpicturePDF.GetFormFieldFontSize(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontSize() finished with the status: "
Exit For
End If
message = message + " " + (j + 1).ToString() + ".child - font size: " + fsize.ToString() + vbCrLf
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Else
'This is an error in getting the font size.
message = "The radio button " + ftitle + " - GetFormFieldFontSize() 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: GetFormFieldFontSize";
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;
float fsize = 0;
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;
}
fsize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The font size is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font size is " + fsize.ToString() + " - same for all children.\n";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The font size 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 size is different for child buttons.\n";
for (int j = 0; j < kids; j++)
{
fsize = gdpicturePDF.GetFormFieldFontSize(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontSize() finished with the status: ";
break;
}
message = message + " " + (j + 1).ToString() + ".child - font size: " + fsize.ToString() + "\n";
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
else
{
//This is an error in getting the font size.
message = "The radio button " + ftitle + " - GetFormFieldFontSize() 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();
See Also