iText PDF form field values are "not appearing"

1.7k Views Asked by At

I'm using iText to create pdf forms with some fields from generated by Java. The PDF form should be filled out and by clicking a send button, the values of the fields should be sent to the server in order to save them in the database. My problem is that the form fields aren't shown while filling them out. It seems like the font is transparent, even when I select the text which I typed in those fields, the text doesn't appear. But by sending the from back to the server all data is save properly. Here is the part of cpde which I'm using to set font parameters while the creating form:

PdfWriter writer = stamper.getWriter();

String fieldName = df.getFofdName();
String value = formfieldValues.get(fieldName);

TextField tf = new TextField(writer, fieldName);
tf.setBackgroundColor(Color.WHITE);
if (showBorders) {
    tf.setBorderColor(Color.BLACK);
}
if (isMultiline) {
    tf.setOptions(BaseField.MULTILINE);
}

BaseFont bf = BaseFont.createFont("C:/Windows/Fonts/Arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
tf.setExtensionFont(BaseFont.createFont());
ArrayList<BaseFont> list = new ArrayList<BaseFont>();
list.add(bf);
tf.setSubstitutionFonts(list);
tf.setText(value);
stamper.addAnnotation(tf.getTextField(), 1);

Any suggestions?

0

There are 0 best solutions below