ek1975 wrote: > I have to read a database file and fill in a PDF template form which has > fields defined and upload this completed PDF into a table.
Can the PDF be flattened, or do you still need the form after filling? (This is important, see later.) > And using PDFStamper and Acrofield classes, I am able to populate the fields > in the form and upload the out1 object using ByteArrayInputStream class. > > Now my problem: Sometimes I have read another template "two.pdf" pdf file, > fill in the fields and then concatenate both one.pdf and two.pdf and upload > it to the database as one "ByteArrayInputStream" or one pdf file. > > Initially I thought I would just concatenate both ByteArrayOutputStream > streams and upload it. That's not going to work. > But on second thoughts, I am not sure if this method > will work? I would appreciate any suggestions that you may have to offer. > Thanks in advance. Use the two byte arrays to create two PdfReader instances. Then use either Pdf(Smart)Copy or PdfCopyFields to concatenate the two documents. How to choose the correct class: - PdfCopy: only the first document contains a form. the following documents are flat. - PdfSmartCopy: uses more memory and CPU, but is results in smaller PDF files because it is able to detect stream that can be reused. - PdfCopyFields: uses more memory, but is able to concatenate PDFs that contain forms. There are examples for each class on http://1t3xt.info/examples/ -- This answer is provided by 1T3XT BVBA ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
