Here is the code. I copy some content from an existing PDF, add a logo to it, and write it out to a new PDF. @ things are wrong though. Signature fields are lost and the content is not centered in the new PDF?
I really appreciate your help on this! Rick. Document document = new Document(); PdfReader reader = new PdfReader("C:\\originalPDF.pdf"); int pageCount = reader.getNumberOfPages(); System.out.println("There are " + pageCount + " pages in the original file."); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\newPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfImportedPage page = null; for(int x = 1; x <= pageCount; x++){ page = writer.getImportedPage(reader, x); cb.addTemplate(page, 0, 0); <--- TODO: center the new page content Image img = Image.getInstance("C:\\_projects\\GPO\\Final_PKI_logo.jpg"); img.scaleToFit(img.width() / 2, img.height() / 2); img.setAbsolutePosition(470, 780); cb.addImage(img); cb.stroke(); document.newPage(); } >From: Bruno Lowagie <[EMAIL PROTECTED]> >Reply-To: Post all your questions about iText here ><itext-questions@lists.sourceforge.net> >To: Post all your questions about iText here ><itext-questions@lists.sourceforge.net> >Subject: Re: [iText-questions] Signature fields lost when >usingPdfContentByte >Date: Fri, 09 Mar 2007 18:26:00 +0100 > >Rick DeFazio wrote: > > I copy a document that has 2 signature fields on it using >PdfContentByte. > >Saying you copy a document 'using PdfContentByte' is ambiguous. >Define 'I copy'; choose one of the following answers: >- with PdfWriter >- with PdfCopy >- with PdfStamper - NOTE THAT THIS IS THE ONLY GOOD ANSWER! - > > > The newly created document ends up losing these 2 signature fields? > >Of course the signature fields are lost. >What did you expect? That anybody could just go on >and forge signed documents? > > > Does anyone know of some example code to get around this? > > I have searched but found none... > >Maybe you should read the book (more specifically chapter 16). >br, >Bruno > >------------------------------------------------------------------------- >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 >iText-questions@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/itext-questions >Buy the iText book: http://itext.ugent.be/itext-in-action/ _________________________________________________________________ Buy what you want when you want it on Sympatico / MSN Shopping http://shopping.sympatico.msn.ca/content/shp/?ctId=2,ptnrid=176,ptnrdata=081805 ------------------------------------------------------------------------- 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 iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/