You need to read the PDF again and use PdfStamper to add more content. You can't add content with PdfCopy.
Paulo ________________________________ From: [EMAIL PROTECTED] on behalf of John Pedersen Sent: Fri 15-Dec-06 15:22 To: [email protected] Subject: [iText-questions] adding further content after using PDFCopy(newbie) Hi, I have read a PDF page, filled in the form, flattened it, added two more pages using PDFCopy - and now I am unable to add more content. Can someone tell me what I am doing wrong? Here is what I have: RandomAccessFileOrArray frontPage = new RandomAccessFileOrArray( pdfFolder + "\\frontPage.pdf"); reader = new PdfReader(frontPage, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); stamper = new PdfStamper(reader, baos); AcroFields form; form = stamper.getAcroFields(); form.setField("userName1", userName1); form.setField("userName2", userName2); stamper.setFormFlattening (true); stamper.close(); // got the first page, and filled the form reader = new PdfReader(baos.toByteArray()); Document document = new Document(reader.getPageSizeWithRotation(1)); PdfCopy writer = new PdfCopy(document, baos); document.open(); writer.addPage(writer.getImportedPage(reader, 1)); RandomAccessFileOrArray intro = new RandomAccessFileOrArray( pdfFolder + "\\intro.pdf"); reader = new PdfReader(intro, null); writer.addPage(writer.getImportedPage(reader, 1)); writer.addPage(writer.getImportedPage(reader, 2)); // added the next two pages... Just doing document.add(new Paragraph("blah")); doesn't add any content at this stage. I have tried using a PDFWriter, using the document as a parameter: PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream( outputFileName)); but that seems to start again, losing the first three pages. I got the book, but I am still struggling ( I have a cold, that's my only excuse!). Can someone show me what I need to do just to add more paragraphs to what I have created so far? Thanks, John Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.
<<winmail.dat>>
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
