Use PdfStamper.
Paulo
----- Original Message -----
From: Carlos Heitmann
To: [email protected]
Sent: Wednesday, August 18, 2010 7:37 PM
Subject: [iText-questions] PDF Landscape (Problem)
I was reading the maillist and i couldn't found something to help me...
So, i Have one PDF and this PDF is in landscape mode! Is a certificate...
So...i need to read this PDF and to write in the PDF...a name!
So...i'm reading the PDF as well and i'm trying to "create" another one to
write the name of my Customer.
I tried somethings without success...I'm posting my source...Could you help
me?
Thanx a lot
Carlos Heitmann
IBM - Brazil
public static void writeName(String name){
try{
PdfReader reader = new PdfReader("c://tempPDF.pdf");
Rectangle psize = reader.getPageSize(1);
Document document = new Document(psize, 75, 75, 75, 75);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("c://iEAi CEA Certificate.pdf"));
BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA,
BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
document.open();
PdfContentByte content = writer.getDirectContent();
document.newPage();
PdfImportedPage page1 = writer.getImportedPage(reader,1);
content.addTemplate(page1,0, 0);
content.beginText();
content.setFontAndSize(baseFont, 14);
//------------------------------------------------------------------
// Writing the voucher on voucher
//------------------------------------------------------------------
content.setTextMatrix(260, 638);
content.showText(name);
content.endText();
//document.setPageSize(PageSize.A4);
document.setPageSize(psize.rotate());
//------------------------------------------------------------------
// CLOSURE BLOCK :
// 1. Closes the document
// 2. Closes the writer
//------------------------------------------------------------------
if(document!=null && document.isOpen()){
document.close();
}
if(writer!=null){
writer.flush();
writer.close();
}
}
catch(Exception x){
x.printStackTrace();
}
}
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/