GetFormFieldRichText Method (GdPicturePDF)
In This Topic
Returns, if the RichText flag of a required form field, here a text field, is set. The text field is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the value of this text field should be represented as a rich text string. For further assistance, please refer to the PDF Reference, Section "Rich Text Strings".
Syntax
'Declaration
Public Function GetFormFieldRichText( _
ByVal As Integer _
) As Boolean
public bool GetFormFieldRichText(
int
)
public function GetFormFieldRichText(
: Integer
): Boolean;
public function GetFormFieldRichText(
: int
) : boolean;
public: bool GetFormFieldRichText(
int
)
public:
bool GetFormFieldRichText(
int
)
Parameters
- FieldId
- A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: GdPicturePDF.AddTextFormField, GdPicturePDF.GetFormFieldId or GdPicturePDF.GetFormFieldChildID.
Return Value
true if the RichText flag of the specified text field is set, otherwise false. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to utilize the RichText flag when saving the formatted string value of the text form field.
Dim caption As String = "Example: GetFormFieldRichText"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldRichText() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", value As String = "", name As String = "code"
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, j As Integer = 0
Dim rich As Boolean = False
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
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
message = message + j.ToString() + ".text field: RichText: "
rich = gdpicturePDF.GetFormFieldRichText(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + rich.ToString() + " Value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
name = name + j.ToString()
If rich Then name = name + ".rtf" Else name = name + ".txt"
Using writer As StreamWriter = New StreamWriter(name)
writer.Write(value)
message = message + name
End Using
Else
message = gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
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: GetFormFieldRichText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldRichText() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", value = "", name = "code";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, j = 0;
bool rich = false;
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)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
message = message + j.ToString() + ".text field: RichText: ";
rich = gdpicturePDF.GetFormFieldRichText(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + rich.ToString() + " Value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
name = name + j.ToString();
if (rich)
name = name + ".rtf";
else
name = name + ".txt";
using (StreamWriter writer = new StreamWriter(name))
{
writer.Write(value);
message = message + name;
}
}
else
message = gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
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
Reference
GdPicturePDF Class
GdPicturePDF Members
SetFormFieldRichText Method
GetFormFieldsCount Method
GetFormFieldId Method
GetFormFieldChildID Method
GetFormFieldType Method
GetFormFieldValue(Int32) Method
AddTextFormField(Single,Single,Single,Single,String,String,Boolean,String,Single,Byte,Byte,Byte) Method