
November 6th, 2010, 09:26 PM
|
|
Contributing User
|
|
Join Date: Jul 2005
Posts: 119

Time spent in forums: 1 Day 6 h 2 m 7 sec
Reputation Power: 8
|
|
IText PDF template help
Hey all, was just wondering if anyone would be able to help me out.
I'm currently creating a pdf document using the iText classes. All has gone fine but now I'm trying to export using a template document.
All I want the template document to be used for is a background image. So every page that is in the new document to contain the background. I have sort of got this working but I'm having a couple problems.
1. The template appears over the added content/text? I add the template first and then the content so not sure what happening there.
2. It only appears on the first page. I'm not sure how to make it appear on all the pages?
Heres what I'm doing
Code:
FileOutputStream outputStream = new FileOutputStream("file.pdf");
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfReader reader = new PdfReader("template.pdf");
PdfImportedPage page = writer.getImportedPage(reader, 1);
PdfContentByte cb = writer.getDirectContent();
cb.addTemplate(page, 0, 0);
document.add(new Paragraph("Test Text");
documnet.close();
Any idea?
|