You need to do something like this...
PdfCopyFields pdfCopyFields = new PdfCopyFields(new
FileOutputStream("my_document.pdf"));
PdfReader reader = new PdfReader(myByteArrayOutputStream1.toByteArray());
pdfCopyFields.addDocument(reader);
reader = new PdfReader(myByteArrayOutputStream2.toByteArray());
pdfCopyFields.addDocument(reader);
pdfCopyFields.close();
----- Original Message -----
From: Steve Weston
To: iText PDF generator
Sent: Thursday, December 18, 2008 11:44 AM
Subject: [iText-questions] Merging PDF files
Hi,
I'm trying to merge two PDF files and I'm having trouble getting this figured
out. I've been reading the tutorial and been through the mailing list, looked
through the tool concat_pdf.java, but everything seems to be based on the
documents already existing on disc.
Basically I have two payloads, each as a ByteArrayOutputStream. I want to
combine those two payloads into a single document and then write the PDF to
disc. I've written a fairly simple method that I passed both payloads to as
byte arrays and then just moved the contents of each of those byte arrays into
a single new byte array, however, the end result was that I ended up with just
the contents from the second payload, losing the first payload along the way.
Anyone have any advice for merging these two output streams into a single
stream so I can get one combined PDF document?
Thanks
steve
------------------------------------------------------------------------------
Send e-mail faster without improving your typing skills. Get your HotmailĀ®
account.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
------------------------------------------------------------------------------
_______________________________________________
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
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
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