/**
* @see com.lowagie.text.pdf.PdfPageEvent#onCloseDocument(com.lowagie.text.pdf.PdfWriter,
* com.lowagie.text.Document)
*/
public void onCloseDocument(PdfWriter writer, Document document) {
total.beginText();
total.setFontAndSize(helv, 8);
total.setTextMatrix(0, 0);
total.showText(String.valueOf(writer.getPageNumber() - 1));
total.endText();
}
/**
* @see com.lowagie.text.pdf.PdfPageEvent#onEndPage(com.lowagie.text.pdf.PdfWriter,
* com.lowagie.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
String text = "Seite " + writer.getPageNumber() + " von ";
float textBase = document.bottom() - 8;
float textSize = helv.getWidthPoint(text, 8);
float adjust = helv.getWidthPoint("0", 8);
cb.beginText();
cb.setFontAndSize(helv, 8);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.showText(text);
cb.setTextMatrix(document.left(), textBase);
cb
.showText("Text in Fußzeile");
cb.endText();
cb.addTemplate(total, document.right() - adjust, textBase);
cb.restoreState();
}
/**
* @see com.lowagie.text.pdf.PdfPageEvent#onOpenDocument(com.lowagie.text.pdf.PdfWriter,
* com.lowagie.text.Document)
*/
public void onOpenDocument(PdfWriter writer, Document document) {
total = writer.getDirectContent().createTemplate(100, 100);
total.setBoundingBox(new Rectangle(-20, -20, 100, 100));
try {
helv = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
BaseFont.NOT_EMBEDDED);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}