Here is the code I'm using. I get a table with 2 rows, not 3, at the bottom of the page.
public void onEndPage(PdfWriter writer, Document document)
{
Rectangle page = document.getPageSize();
PdfPTable head = new PdfPTable(1);
PdfPTable foot = new PdfPTable(1);
PdfPCell cell;
PdfContentByte cb = writer.getDirectContent();
// compose the footer
String text = "Page " + writer.getPageNumber() + " of ";
float textSize = helv.getWidthPoint(text, 12);
float textBase = document.bottom() - 20;
cb.beginText();
cb.setFontAndSize(helv, 12);
// for odd pagenumbers, show the footer at the left
if ((writer.getPageNumber() & 1) == 1)
{
cb.setTextMatrix(document.left(), textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.left() + textSize, textBase);
}
// for even numbers, show the footer at the right
else
{
float adjust =
helv.getWidthPoint("0", 12);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.right() - adjust, textBase);
}
if (sensitivity != null)
{
cell = cellFromParagraph(sensitivity.toUpperCase(),
tnr12boldItalic, Paragraph.ALIGN_CENTER);
}
else
{
cell = cellFromParagraph("UNRESTRICTED", tnr12boldItalic,
Paragraph.ALIGN_CENTER);
}
head.addCell(cell);
if (exportControl == null)
{
foot.addCell(cell);
foot.addCell(cellFromParagraph(SecurityUtilities.getExportControlWarningLabel1().getText(),
tnr12boldItalic, Paragraph.ALIGN_CENTER));
foot.addCell(cellFromParagraph(SecurityUtilities.getExportControlWarningLabel2().getText(),
tnr12boldItalic, Paragraph.ALIGN_CENTER));
}
else
{
foot.addCell(cell);
foot.addCell(cellFromParagraph("jkjljlkjljklkjlk",
tnr12boldItalic, Paragraph.ALIGN_CENTER));
foot.addCell(cellFromParagraph("jkjldddddddddddddddddddjlkjljklkjlk",
tnr12boldItalic, Paragraph.ALIGN_CENTER));
}
head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.height() -
document.topMargin() + head.getTotalHeight(),
writer.getDirectContent());
foot.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
writer.getDirectContent());
}
Yahoo! Messenger with Voice.
Make PC-to-Phone Calls to the US (and 30+ countries) for 2?/min or less.