Dilan wrote:
Hello,
** All I'm trying to do is open a PDF template file,
InputStream input = new BufferedInputStream(new
FileInputStream("/template-buyer.pdf"));
PdfReader reader = null;
reader = new PdfReader(input);
** create an output stream
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader,bout);
AcroFields aform = stamper.getAcroFields();
** Then do some changes to the fields of the template PDF file,
..
..
** And out put it to the binary stream for output,
stamper.close();
bytes = bout.toByteArray();
bout.close();
bout.close() is not necessary.
As soon as you do stamper.close(), the underlying output stream is
closed too.
** above bit work fine, now I want to do is, insert a another page to this
above pdf file that I open and send the combined PDF into the bitestream,
how can I do that?
The bytes variable you have created contains a complete, valid PDF file.
So you can use it to create a new PdfReader and PdfStamper object:
reader = new PdfReader(bytes);
stamper = new PdfStamper(reader, new FileOutputStream("end_result.pdf"));
// do stuff
int pagenumber = 5;
Rectangle pagesize = PageSize.A4;
stamper.insertPage(pagenumber, pagesize);
// do stuff
stamper.close();
br,
Bruno
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions