// step 3: we open the document
document.open();
// step 4:
TextField tf = new TextField(writer, new LwgRectangle(100, 300, 100 + 100, 300 + 50), "Dickens");
tf.setBackgroundColor(Color.RED);
tf.setBorderColor(Color.BLUE);
tf.setBorderWidth(2);
tf.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
tf.setText("It was the best of times, it was the worst of times, it was the age of wisdom...");
tf.setAlignment(LwgElement.ALIGN_CENTER);
tf.setOptions(TextField.MULTILINE | TextField.REQUIRED);
tf.setRotation(90);
PdfFormField field = tf.getTextField();
writer.addAnnotation(field);
tf = new TextField(writer, new LwgRectangle(250, 300, 250 + 100, 300 + 20), "Combos");
tf.setBackgroundColor(Color.RED);
tf.setBorderColor(Color.BLUE);
tf.setBorderWidth(2);
tf.setFontSize(10);
tf.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
tf.setVisibility(TextField.VISIBLE_BUT_DOES_NOT_PRINT);
tf.setChoices(new String[]{"First", "Second"});
tf.setChoiceExports(new String[]{"value1", "value2"});
tf.setRotation(90);
field = tf.getComboField();
writer.addAnnotation(field);
tf = new TextField(writer, new LwgRectangle(400, 300, 400 + 100, 300 + 50), "Lists");
tf.setBackgroundColor(Color.YELLOW);
tf.setBorderColor(Color.RED);
tf.setBorderWidth(2);
tf.setBorderStyle(PdfBorderDictionary.STYLE_DASHED);
tf.setFontSize(10);
tf.setChoices(new String[]{"a", "b", "c", "d", "e", "f", "g", "h"});
tf.setRotation(90);
tf.setChoiceSelection(4);
field = tf.getListField();
writer.addAnnotation(field);
}
catch(DocumentException de) {
System.err.println(de.getMessage());