I have a PDF with form elements in a table. the form elements are added in the cellEvent. I did this in order to know where the cells are on the page, which enables me to use the method described in the book "iText in Action". It actually works, the form fields are added and can be filled out, but as soon as the field looses focus, the text is not displayed anymore. It must have something to do with layers and order but I was not able to find out a solution.
Notice that the fields are added to the last PdfContentByte in the array: PdfContentByte pcb = canvas[canvas.length - 1]; But it has the same behavior if the fields are added to canvas[0] cell.setCellEvent( new PdfPCellEvent() { @Override public void cellLayout( PdfPCell pdfPCell, Rectangle rectangle, PdfContentByte[] canvas ) { PdfContentByte pcb = canvas[canvas.length - 1]; PdfWriter writer = pcb.getPdfWriter(); PdfFormField field = PdfFormField.createTextField( writer, false, false, 3 ); field.setName( "quantity " + hashCode() ); field.setFieldFlags( PdfFormField.FF_EDIT ); Rectangle rect = new Rectangle( rectangle.getLeft() + 5, rectangle.getTop() - 5, rectangle.getLeft() + rectangle.getWidth() - 5, rectangle.getTop() - rectangle.getHeight() + 5 ); rect.setBackgroundColor( BaseColor.BLUE ); field.setWidget( rect, PdfAnnotation.HIGHLIGHT_OUTLINE ); field.setFieldFlags( PdfAnnotation.FLAGS_PRINT ); writer.addAnnotation( field ); writer.flush(); pcb.rectangle( rect ); } } ); Micha Roon micha.r...@managination.com +41 78 810 02 92 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php