* Adds the header and the footer.
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
* com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
String textPageOfPage = String.format(pageOfPage, writer.getPageNumber());
float textBase = 18;
float textSize = helv.getWidthPoint(textPageOfPage, fontSize);
float adjust = helv.getWidthPoint("0", fontSize);
cb.addTemplate(total, document.right() - adjust, textBase);
cb.saveState();
cb.beginText();
cb.setFontAndSize(helv, fontSize);
cb.setTextMatrix(document.right() - textSize - adjust*2 , textBase);
cb.showText(textPageOfPage);
if (editTextAlign == Chunk.ALIGN_LEFT) {
cb.setTextMatrix(document.left(), textBase);
} else {
float editDateTextSize = helv.getWidthPoint(footerText, fontSize);
cb.setTextMatrix((document.right() - document.left()- editDateTextSize)/2, textBase);
}
cb.showText(footerText);
cb.endText();
if (headerLogo != null) {
try {
cb.addImage(headerLogo);
} catch (DocumentException e) {
// TODO Auto-generated catch block
}
}
if (recHeader != null) {
cb.rectangle(recHeader.getLeft(), recHeader.getBottom(), recHeader.getWidth(), recHeader.getHeight());
cb.setLineWidth(/*0.5f*/0f);
//cb.stroke();
}
if (footerLogo != null) {
try {
cb.addImage(footerLogo);
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (recFooter != null) {
cb.rectangle(recFooter.getLeft(), recFooter.getBottom(), recFooter.getWidth(), recFooter.getHeight());
cb.setLineWidth(/*0.5f*/0f);
//cb.stroke();
}
cb.restoreState();
}