-none- 2007-08-24 - By dreamboy
Back
pls help
dreamboy wrote: > > how to combine all bytearrayoutputstream after manipulating the pdf. I > want to get the whole baos that represents the pdf. I need help on this > coz I am getting blank page or corrupted pdf if I use one baos for the > whole passes. In the example in the book, if I used different baos, how to > combine them in order to have one pdf? I need to get the baos.toByteArray > which represents the pdf. Please help. > > > > from the example in the book: > > /* chapter02/HelloWorldStampCopy.java */ > RandomAccessFileOrArray letter = > new RandomAccessFileOrArray("HelloLetter.pdf"); > reader = new PdfReader(letter, null); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > stamper = new PdfStamper(reader, baos); > form = stamper.getAcroFields(); > form.setField("field", "World,"); > stamper.setFormFlattening(true); > stamper.close(); > > /* chapter02/HelloWorldStampCopy.java */ > reader = new PdfReader(baos.toByteArray()); > Document document = > new Document(reader.getPageSizeWithRotation(1)); > PdfCopy writer = new PdfCopy(document, > new FileOutputStream("HelloWorldStampCopy.pdf")); > document.open(); > writer.addPage(writer.getImportedPage(reader, 1)); > > /* chapter02/HelloWorldStampCopy.java */ > reader = new PdfReader(letter, null); > baos = new ByteArrayOutputStream(); > stamper = new PdfStamper(reader, baos); > form = stamper.getAcroFields(); > form.setField("field", "People,"); > stamper.setFormFlattening(true); > stamper.close(); > reader = new PdfReader(baos.toByteArray()); > writer.addPage(writer.getImportedPage(reader, 1)); > > > If I get the baos.toByteArray() here, I will only get the last page coz > there multiple instance of baos. >
-- View this message in context: http://www.nabble.com/Combining -bytearrayoutputstream-in-IText-tf4320790.html#a12307231 Sent from the iText - General mailing list archive at Nabble.com.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|