GetFormFieldBorderColor(Int32) Method
In This Topic
Returns the border color of 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 method only returns the correct form field's border color if this attribute is specified in the form field object itself, otherwise the method will fail.
The form field's border color attribute is not assigned automatically when creating the form field, however, you can specify the border color using the SetFormFieldBorderColor(Int32,Byte,Byte,Byte) method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Be aware that if the border color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail. Please use the GetFormFieldBorderColor(Int32,Int32) method to determine the individual border color for each child radio button in a group instead.
Syntax
'Declaration
Public Overloads Function GetFormFieldBorderColor( _
ByVal As Integer _
) As Color
public Color GetFormFieldBorderColor(
int
)
public function GetFormFieldBorderColor(
: Integer
): Color;
public function GetFormFieldBorderColor(
: int
) : Color;
public: Color GetFormFieldBorderColor(
int
)
public:
Color GetFormFieldBorderColor(
int
)
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.
Return Value
The border color of the specified form field, if defined. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to determine the border color of those form fields, which do have some defined.
Dim caption As String = "Example: GetFormFieldBorderColor"
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 = ""
Dim formID As Integer = 0
Dim borderColor As Color = Color.Black
Dim hasColor As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
message = message + i.ToString() + ".field: "
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "has borderColor: " + hasColor.ToString()
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " borderColor: " + borderColor.ToString()
Else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString()
End If
Else
If gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) = GdPictureStatus.OK Then
message = message + " color set to: " + Color.Fuchsia.ToString()
Else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
status = GdPictureStatus.OK
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
status = GdPictureStatus.Aborted
Exit For
End If
message += vbCrLf
Next
If status = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
End If
End If
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: GetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
Color borderColor = Color.Black;
bool hasColor = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
message = message + i.ToString() + ".field: ";
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "has borderColor: " + hasColor.ToString();
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " borderColor: " + borderColor.ToString();
else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString();
}
else
{
if (gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) == GdPictureStatus.OK)
message = message + " color set to: " + Color.Fuchsia.ToString();
else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
status = GdPictureStatus.OK;
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
status = GdPictureStatus.Aborted;
break;
}
message += "\n";
}
if (status == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The file can't be saved.";
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
Overload List
SetFormFieldBorderColor(Int32,Byte,Byte,Byte) Method
GetFormFieldsCount Method
GetFormFieldId Method
GetFormFieldChildID Method
GetFormFieldType Method
AddTextFormField(Single,Single,Single,Single,String,String,Boolean,String,Single,Byte,Byte,Byte) Method
AddPushButtonFormField(Single,Single,Single,Single,String,String,String,Single,Byte,Byte,Byte) Method
GetFormFieldBackgroundColor(Int32) Method
SetFormFieldBackgroundColor(Int32,Byte,Byte,Byte) Method