Hello!

I am trying to copy an existing PDF document into a new document and then
add some text to the document. Everyting works fine except for one thing.
The document created has a larger pagesize than the template document. The
template document is inserted in the center of the new document with white
borders surrounding it. Why? My code looks like this.

PdfReader reader = new PdfReader("DocIn.pdf");
Rectangle psize = reader.getPageSize(1);

Document document = new Document(psize);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("DocOut.pdf"));
document.open();

PdfContentByte cb = writer.getDirectContent();
document.newPage();
PdfImportedPage page = writer.getImportedPage(reader, 1);
cb.addTemplate(page,  0, 0);

BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "Testing Testing",
psize.left()+130, psize.bottom()+270, 0);
cb.endText();
document.close();


/Erik Turesson



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to