GetFormFieldFontProperties Method (GdPicturePDF)
In This Topic
Returns the font properties, namely font family name, font style and a standard font flag, of the font used to display text in a required form field,
that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The font related attributes are not restricted
to any form fields, even if the form field's appearance doesn't display text. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Syntax
'Declaration
Public Function GetFormFieldFontProperties( _
ByVal As Integer, _
ByRef As String, _
ByRef As TrueTypeFontStyle, _
ByRef As Boolean _
) As GdPictureStatus
public GdPictureStatus GetFormFieldFontProperties(
int ,
ref string ,
ref TrueTypeFontStyle ,
ref bool
)
public function GetFormFieldFontProperties(
: Integer;
var : String;
var : TrueTypeFontStyle;
var : Boolean
): GdPictureStatus;
public function GetFormFieldFontProperties(
: int,
: String,
: TrueTypeFontStyle,
: boolean
) : GdPictureStatus;
public: GdPictureStatus GetFormFieldFontProperties(
int ,
ref string* ,
ref TrueTypeFontStyle ,
ref bool
)
public:
GdPictureStatus GetFormFieldFontProperties(
int ,
String^% ,
TrueTypeFontStyle% ,
bool%
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GetFormFieldId, GetFormFieldChildID or methods intended to add form fields.
- FontFamily
- Output parameter. The font family name of the defined font.
- FontStyle
- Output parameter. A member of the FontStyle enumeration. The font style of the defined font.
- IsStdFont
- Output parameter. true if the defined font is a standard font, otherwise false.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontProperties"
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
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
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() + ". "
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
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.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: GetFormFieldFontProperties";
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;
string fName = "", fFamily = "";
float fSize = 0;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
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() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.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();
Example
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontProperties"
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
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
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() + ". "
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
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.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: GetFormFieldFontProperties";
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;
string fName = "", fFamily = "";
float fSize = 0;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
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() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.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