2

I am trying to set BorderColor to an AcroField of my PDF. We are using an iText version that is at least 5 years old. I dont see any class named BaseColor in that version, whereas I've seen the following code being used in more recent versions of the iText library:

AcroFields form = New AcroFields (); form.setFieldProperty("text_2", "bordercolor", BaseColor.RED, null);

Is there are anyway I can successfully use BaseColor in the obsolete versions of iText?

I also have a follow-up question: Can I find bordercolor of a field in PDF using iText?

Community
  • 1
  • 1
javaAndBeyond
  • 520
  • 1
  • 9
  • 26
  • `BaseColor` does not exist in obsolete versions of iText. Please don't call those versions Lowagie. Lowagie is how people call *me* (it's my *name*!), not the software I wrote. The software has always been named iText! – Bruno Lowagie Feb 02 '15 at 23:56
  • *The software has always been named iText!* ... And the best way to indicate its development state is by giving its version number. – mkl Feb 03 '15 at 05:14
  • I am sorry @Bruno Lowagie. The import appeared on that name(lowagie) instead of iText, so I used that way. `import com.lowagie.text.pdf.AcroFields;` I realize its an older version and needs to be upgraded. Thanks. – javaAndBeyond Feb 03 '15 at 20:55
  • @Bruno Lowagie Could you please let me know if there is a way of finding bordercolor using iText latest version? I updated my question as well. Thanks. – javaAndBeyond Feb 03 '15 at 23:03
  • You'll find my answer here: http://stackoverflow.com/questions/28312620/can-i-find-bordercolor-of-a-field-in-pdf-using-itext – Bruno Lowagie Feb 04 '15 at 07:39

1 Answers1

4

Just use:

//import java.awt.Color;
fields.setFieldProperty("text_2", "bordercolor", Color.BLUE, null);
fields.setFieldProperty("text_2", "bordercolor", Color.RED, null);
fields.setFieldProperty("text_2", "bordercolor", Color.GREEN, null);

If you need a custom color, define it like this:

Color custom = new Color(228,102,0);
fields.setFieldProperty("text_2", "bordercolor", custom, null);
Lonzak
  • 9,334
  • 5
  • 57
  • 88