Hi Bruno, I still stuck with that thing and I need your help again. I have the following code that in principle does want I need:
... //reading the PDF that contains the text PdfReader original = new PdfReader("MyOriginalLetter.pdf"); //reading the letterhead PDF PdfReader letterhead = new PdfReader("MyLetterhead.pdf"); Document document = new Document(); // making new PDF Document PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("MyNewLetter.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); // shall I first import the letterhead? PdfImportedPage letterheadImport=writer.getImportedPage(letterhead, 1); cb.addTemplate(letterheadImport, ?,?); // and then the text PDF? PdfImportedPage originalImport=writer.getImportedPage(original, 1); cb.addTemplate(originalImport, ?,?); ... - I'm not certain about in what order I must add the templates to the PdfContentByte. First the letterhead and then the text? Or vice versa? - I'm not certain about the parameters of the addTemplate() method. Both documents are DIN A4 sized. What parameters must I use? - When I add the letterhead first and then the text, the letterhead is hidden by the text. When I first add the text and then the letterhead, the watermark of the letterhead is in front of the text and thus hiding the text. Thank you Thomas Bruno Lowagie (iText) wrote: > Thomas Kuechenthal wrote: >> I have an existing PDF that contains pure text information. >> >> I have a second PDF that I use as a letterhead.(It contains a header, a >> footer, and a watermark in the middle of the document) >> >> With Acrobat 6.0, I can insert the PDF-Letterhead as a background onto >> the existing Text-PDF. >> >> Can I do this with iText also? > > Yes. > >> I have tried to add images as watermarks, that works very well. But how >> about adding PDFs as background? > > Look for PdfImportedPage. > It extends PdfTemplate. > PdfTemplate can be wrapped in an Image, > but it's not necessary to do so. > > Have a look at this example from chapter 14 of > 'iText in Action' (available as eBook tomorrow): > http://itext.ugent.be/itext-in-action/examples/chapter14/SimpleLetter.java > > Note that in this example, the background > is added to a layer that is shown on the screen, > but not printed on paper. > > Just remove everything with not_printed > (don't forget to remove beginLayer and endLayer too) > > br, > Bruno > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------------------------- 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/