Skip to content

Commit daf20a4

Browse files
committed
Add getter for color prop of the form field
DEVSIX-2741
1 parent c580f61 commit daf20a4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,15 @@ public PdfFont getFont() {
17671767
return font;
17681768
}
17691769

1770+
/**
1771+
* Gets the current color of the form field.
1772+
*
1773+
* @return the current {@link Color color}
1774+
*/
1775+
public Color getColor() {
1776+
return color;
1777+
}
1778+
17701779
/**
17711780
* Basic setter for the <code>font</code> property. Regenerates the field
17721781
* appearance after setting the new value.
@@ -3482,8 +3491,8 @@ private void retrieveStyles() {
34823491
if (subType != null && subType.equals(PdfName.Widget)) {
34833492
PdfDictionary appearanceCharacteristics = getPdfObject().getAsDictionary(PdfName.MK);
34843493
if (appearanceCharacteristics != null) {
3485-
backgroundColor = getColor(appearanceCharacteristics, PdfName.BG);
3486-
Color extractedBorderColor = getColor(appearanceCharacteristics, PdfName.BC);
3494+
backgroundColor = appearancePropToColor(appearanceCharacteristics, PdfName.BG);
3495+
Color extractedBorderColor = appearancePropToColor(appearanceCharacteristics, PdfName.BC);
34873496
if (extractedBorderColor != null)
34883497
borderColor = extractedBorderColor;
34893498
}
@@ -3498,7 +3507,7 @@ private void retrieveStyles() {
34983507
}
34993508
}
35003509

3501-
private Color getColor(PdfDictionary appearanceCharacteristics, PdfName property) {
3510+
private Color appearancePropToColor(PdfDictionary appearanceCharacteristics, PdfName property) {
35023511
PdfArray colorData = appearanceCharacteristics.getAsArray(property);
35033512
if (colorData != null) {
35043513
float[] backgroundFloat = new float[colorData.size()];

0 commit comments

Comments
 (0)