PdfAnnotation.setPlaceInPage() > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Peter Soelter > Sent: Thursday, September 09, 2004 9:53 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: RE: [iText-questions] Same form-field names on > different pages > > Hi Paulo, > i've tried to implement your tip with the form field on one page and > kids in the next pages, but i have serious problems. > > If you create the field on page 1 (and maybe the first kid) you > can't create a kid on page 2, as the field seems to be > written out, if a newPage() occurs. > Have a look at the code below. > > If you create the second kid while the PdfWriter is on page 1, > it is added on the first page. > > Do you have any idea how to add kids to fields on different pages? > > Regards, > Peter > > BTW: In Version 137 you didn't change anything about the > fields, did you? > > Here's the code for the naiv approach. In the resulting PDF only > the first kid appears. > > public static void main(String[] args) > { > String strOutPDF = "D:/temp/with_fields_1.pdf"; > > System.out.println("Testing fields on different pages"); > Document doc = new Document(); > try > { > PdfFormField aFormField = null; > PdfFormField aSecondKid = null; > PdfFormField aFirstKid = null; > float fontSize = 12; > Color textColor = new GrayColor(0f); > > BaseFont helv = > BaseFont.createFont("Helvetica", "winansi", false); > PdfWriter aWriter = PdfWriter.getInstance(doc, > > new FileOutputStream(strOutPDF)); > doc.open(); > PdfContentByte cb = aWriter.getDirectContent(); > doc.add(new Paragraph("Page 1")); > > aFormField = > PdfFormField.createTextField(aWriter, false, false, 100); > aFormField.setFieldName("ATextField"); > > aFirstKid = > PdfFormField.createTextField(aWriter, false, false, 100); > aFirstKid.setWidget(new Rectangle(171, > 750, 342, 769), > PdfAnnotation.HIGHLIGHT_INVERT); > aFormField.addKid(aFirstKid); > > aWriter.addAnnotation(aFormField); > > doc.newPage(); > > doc.add(new Paragraph("Page 2")); > > aSecondKid = > PdfFormField.createTextField(aWriter, false, false, 100); > aSecondKid.setWidget(new Rectangle(171, > 450, 342, 469), > PdfAnnotation.HIGHLIGHT_INVERT); > aFormField.addKid(aSecondKid); > > aWriter.addAnnotation(aSecondKid); > > doc.close(); > } catch (FileNotFoundException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (DocumentException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > System.out.println("finished."); > } > > > > > By the way, the next version will take care of this and > other problems > > both in PdfWriter and PdfStamper. > > > > Best Regards, > > Paulo Soares > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On > > > Behalf Of Paulo Soares > > > Sent: Friday, September 03, 2004 12:44 PM > > > To: Peter Soelter; [EMAIL PROTECTED] > > > Subject: RE: [iText-questions] Same form-field names on > > > different pages > > > > > > You've managed to create an invalid pdf. Field support in > > > iText is not very good, you have everything that is needed to > > > create the fields but it's a bit low level and you have to > > > pay attention to details. > > > In this case you need to create a field with the value that > > > will be the parent and you'll have a kid in each page with > > > the widget. > > > > > > Best Regards, > > > Paulo Soares > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > > [mailto:[EMAIL PROTECTED] On > > > > Behalf Of Peter Soelter > > > > Sent: Thursday, September 02, 2004 4:19 PM > > > > To: [EMAIL PROTECTED] > > > > Subject: [iText-questions] Same form-field names on > different pages > > > > > > > > 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 >
------------------------------------------------------- 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_idP47&alloc_id808&op=click _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
