Thanks again for the thoughtful response, Mark. On May 27, 2010, at 9:04 AM, Mark Storer wrote: > Pretty much, yeah. You /can/ make changes within a PdfReader, but > those > changes won't be reflected anywhere in a file until you write them out > through a PdfWriter somewhere.
I will be eventually writing them out with a PdfWriter (to an HttpResponse back to the user via their browser, to be specific) so it's not a *huge* deal to pass the PdfWriter I'll eventually use down the function call chain to where I create a PdfStamper and fill out the form fields. It just seemed strange to need that object at that time. > PS: The recommended way of doing what you're doing (combining files > with > form fields) goes something like this: > > Create a PdfWriter with a blank Document > > For each form: > Fill and flatten into a ByteAarryOutputStream > Get a reader from the byte[] from the baos > Get an ImportedPage from the reader into the PdfWriter you whipped up > earlier. > Draw said ImportedPage in the place[s] you want. Actually I've managed to come up with that exact solution fragment independently after I extended your previous solution to handle forms. So it's good to see confirmation from another source that what I was doing made sense! > It's rather inefficient to write your forms out then read them back > in, > but that's the way you have to do it in iText. I call this the "walk > and chew gum" problem. iText can't... within the same class. You can > Stamp, Copy, CopyFields, and whip up PDFs from scratch in a Writer, > but > you can't do all those things at once in the same file. > > Ah, Organic Growth. For the record, I think iText is really neat-o. But it's not until you start using a library for real that you start discovering its dark corners. :) -- Thomas Hauk Shaggy Frog Software www.shaggyfrog.com ------------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
