Hi guys i have a java class which is used to show header and footer in iText PDF.
the page number is showing in top of the page and footer is coming correctly in footer section.. now i want to display the page number in footer place...
following code im using
public HeaderAndFooter() {
header = new Phrase("**** Header ****");
footer = new PdfPTable(1);
footer.setTotalWidth(130);
footer.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
footer.addCell(new Phrase(new Chunk(
"**** Footer summary****")
.setAction(new PdfAction(PdfAction.FIRSTPAGE))));
}
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, new Phrase(String.format("%d", writer.getPageNumber()),
PDFUtil.getNormalFont()), (document
.right() - document.left())
/ 2 + document.leftMargin(), document.top() + 10, 0);
footer.writeSelectedRows(0, -1,
(document.right() - document.left() - 300) / 2
+ document.leftMargin(), document.bottom() - 10, cb);
}
}
im getting output like this
1 (header)
26-Aug-2011 Rentaldetails August ---- 5500 month
miscellaneous----500 total ---5500
**** Footer summary (footer)
****
kindly suggest me how to show pagenumber in footer section...Thankxxx in Advance