public static void main(String[] args) {
System.out.println("StudentCard as a form");
// step 1: creation of a document-object
LwgRectangle rect = new LwgRectangle(243, 153);
rect.setBackgroundColor(new Color(0xFF, 0xFF, 0xCC));
LwgDocument document = new LwgDocument(rect, 10, 10, 10, 10);
try {
// step 2:
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("studentcardform.pdf"));
// step 3: we open the document
document.open();
// step 4:
LwgFont font = FontFactory.getFont(FontFactory.HELVETICA, 14, LwgFont.BOLD, Color.BLUE);
Paragraph p = new Paragraph("Ghent University", font);
p.setAlignment(LwgElement.ALIGN_CENTER);
document.add(p);
LwgFont f = FontFactory.getFont(FontFactory.HELVETICA, 8);
LwgPdfPTable outertable = new LwgPdfPTable(3);
outertable.setTotalWidth(200);
outertable.getDefaultCell().setBorder(LwgRectangle.NO_BORDER);
float[] outer = { 60, 25, 15 };
outertable.setWidths(outer);
LwgPdfPTable innertable = new LwgPdfPTable(2);
float[] inner = {35, 65};
innertable.setWidths(inner);
LwgPdfPCell cell;
TextField text;
innertable.add(new Paragraph("name:", f));
cell = new LwgPdfPCell();
text = new TextField(writer, new LwgRectangle(0, 0), "name");
text.setOptions(TextField.MULTILINE);
text.setFontSize(8);
PdfFormField name = text.getTextField();
cell.setCellEvent(new StudentCardForm(name));
innertable.add(cell);
innertable.add(new Paragraph("date of birth:", f));
cell = new LwgPdfPCell();
text = new TextField(writer, new LwgRectangle(0, 0), "birthday");
text.setOptions(TextField.MULTILINE);
text.setFontSize(8);
PdfFormField birthdate = text.getTextField();
cell.setCellEvent(new StudentCardForm(birthdate));
innertable.add(cell);
innertable.add(new Paragraph("Study Program:", f));
cell = new LwgPdfPCell();
text = new TextField(writer, new LwgRectangle(0, 0), "studyprogram");
text.setOptions(TextField.MULTILINE);
text.setFontSize(8);
PdfFormField studyprogram = text.getTextField();
studyprogram.setFieldName("studyprogram");
cell.setCellEvent(new StudentCardForm(studyprogram));
innertable.add(cell);
innertable.add(new Paragraph("option:", f));
cell = new LwgPdfPCell();
text = new TextField(writer, new LwgRectangle(0, 0), "option");
text.setOptions(TextField.MULTILINE);
text.setFontSize(8);
PdfFormField option = text.getTextField();
option.setFieldName("option");
cell.setCellEvent(new StudentCardForm(option));