Gatewood, Paul (RSIS) wrote: > I have a "template" pdf with 5 pages. > > The first 4 pages have "normal" form fields. By calling them > "normal" I mean The runtime values for all such fields are all short > enough to fit within the corresponding fields. > > Page 5 has 1 large form field, the value of which may need more > space than is available on page 5. If this happens, the final > output PDF should contain additional pages (6, 7, etc.) with > whatever "overflow" text from this long text value did not fit on > page 5. > > What I may not have made clear earlier is that page 5 of the > template, in addition the large form field, also contains some > "normal" form fields. These appear at the top of most of the pages > of the template (including page 5).
> The code below does most of what I want, except on the added pages > (6, 7, etc.) the "normal" form fields are missing. This is because > I am creating the extra pages with PdfStamper only. And, as the > last paragraph on page 63 of the book says, when adding a page > imported with PdfStamper.getImportedPage, all interactive features > (e.g. fields) are lost. OK, then maybe you should do it in two passes. First use PdfStamper to fill out and flatten all the fields EXCEPT the large one on page 5. Don't forget to retrieve the coordinates of the large field. Close the stamper. Now you have a PDF template that is almost completely filled in (as described in chapter 2: this form doesn't need to be stored on the file system; it can be stored in memory as a byte array). Use this form to create a new PdfReader and PdfStamper object. Use the coordinates retrieved earlier to add the content on page 5. The rest is similar to what you're already doing now, with as main difference that the 'normal' fields on page 5 are no longer acrofields, but real content (and part of the imported page). An alternative might be to add all the fields on page 5 the same way you're adding the large field. However I think this will take more processing time and result in a slightly larger file size. > Many of the examples with PdfCopy have the constuct > copy.addPage(copy.getImportedPage(reader,1)); > However, I see no way afterward to get the direct content for such > an added page, so that the "overflow" text of the long field value > can be added using a ColumnText object. That's a good observation: PdfCopy is for copying pages as they are. You can't add new content to a page when using PdfCopy. br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/