Hi everybody, I'm trying to import a PDF File, populate it with form fields and save the result. This works fine so far.
But if there are fields with the same name on different pages of the document, iText seems to get difficulties with the fields on the following pages. If you open the resulting PDF with Acrobat (Reader) 5 and try to TAB through the fields, Acrobat crashes with a GPF. Acrobat 6 is a little smarter, but doens't display the fields correctly. You can produce such a PDF with same named fields on different pages with Acrobat 5 full version and it works fine. In Acrobat (Reader) 6 they even implemented a new feature: all fields with the same name are filled automatically with the value of the changed field. Is this a kind of bug in iText? I'm using the latest version (iText-paulo-136) from http://itextpdf.sourceforge.net Any comments? Best regards, Peter Here's some sample code. You need any PDF without AcroForm or Fields as an input. public class FieldsonPages { public static void main(String[] args) { String strInPDF = "D:/temp/without_fields.pdf"; String strOutPDF = "D:/temp/with_fields.pdf"; System.out.println("Testing fields on different pages"); PdfReader reader; try { String strFeldName; reader = new PdfReader(strInPDF); FileOutputStream out = new FileOutputStream(strOutPDF); Document document = new Document(reader.getPageSize(1)); PdfWriter aWriter = PdfWriter.getInstance(document, out); document.open(); int iPage; for (iPage = 1; iPage <= reader.getNumberOfPages(); ++iPage) { int iField = 0; if (iPage != 1) { document.setPageSize(reader.getPageSize(1)); document.newPage(); } PdfContentByte cb = aWriter.getDirectContent(); cb.addTemplate(aWriter.getImportedPage(reader, iPage), 0, 0); strFeldName = "Field_" + iField; Rectangle aRect = new Rectangle(100, 100, 350, 150); TextField aTextField = new TextField(aWriter, aRect, strFeldName); aTextField.setBorderWidth(1); aTextField.setBorderColor(Color.black); aWriter.addAnnotation(aTextField.getTextField()); iField++; strFeldName = "Field_" + iField; aRect = new Rectangle(100, 300, 350, 350); aTextField = new TextField(aWriter, aRect, strFeldName); aTextField.setBorderWidth(1); aTextField.setBorderColor(Color.black); aWriter.addAnnotation(aTextField.getTextField()); iField++; } document.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } System.out.println("done"); } } -- NEU: Bis zu 10 GB Speicher f�r e-mails & Dateien! 1 GB bereits bei GMX FreeMail http://www.gmx.net/de/go/mail ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
