FormFieldHasBorderColor(Int32) Method
In This Topic
Returns, if the border color attribute is defined for 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 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 FormFieldHasBorderColor(Int32,Int32) method instead to find out, if the border color attribute is defined for each child radio button in a group.
Syntax
'Declaration
Public Overloads Function FormFieldHasBorderColor( _
ByVal As Integer _
) As Boolean
public bool FormFieldHasBorderColor(
int
)
public function FormFieldHasBorderColor(
: Integer
): Boolean;
public function FormFieldHasBorderColor(
: int
) : boolean;
public: bool FormFieldHasBorderColor(
int
)
public:
bool FormFieldHasBorderColor(
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
true if the border color attribute is defined for the specified form field object, otherwise false. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to set the border color to only those form fields, which don't have any defined.
Dim caption As String = "Example: FormFieldHasBorderColor"
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: FormFieldHasBorderColor";
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