On 9/10/2013 5:43 AM, Eric Chow wrote:
> It is a company paper with some pre-printed information on it.
> How can I add the page as the background? Would you please to show me 
> a simple example?

See http://itextpdf.com/examples/iia.php?id=114

Create a helper class that extends PdfPageEventHelper.
Add a member variable:
     protected PdfImportedPage page;
Initialize this member variable in the constructor of your helper class:
     PdfReader reader = new PdfReader(STATIONERY);
     page = writer.getImportedPage(reader, 1);
Implement a single method of the page event interface:
     public void onEndPage(PdfWriter writer, Document document) {
         writer.getDirectContentUnder().addTemplate(page, 0, 0);
     }
Note that this assumes that your newly created file and your existing
file (of which STATIONERY is the path) have the same page size.

Now that you have this separate class, add it as a page event to
the writer you already have using the setPageEvent() method.

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to