Shreekanth wrote:
I am new to iText. So can you please provide me with a
sample code so that I know how this can be done. How
can this pageEvent be triggered.
public class PageWithRectangle extends PdfPageEventHelper {
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
Rectangle pageSize = writer.getPageSize();
cb.rectangle(pageSize.left() + 3, pageSize.bottom() + 3,
pageSize.width() - 6, pageSize.height() - 6);
cb.stroke();
}
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer =
PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
writer.setPageEvent(new PageWithRectangle());
document.open();
document.add(new Paragraph("test1"));
document.newPage();
document.add(new Paragraph("test2"));
document.newPage();
document.add(new Paragraph("test3"));
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions