code: @Override
  	public void onCloseDocument(final PdfWriter writer, final Document document) {
  		template.beginText();
  		template.setFontAndSize(bf, 8);
  		template.showText(String.valueOf(writer.getPageNumber() - 1));
  		template.endText();
  	}
docs: we override the onCloseDocument method.
  
  @param writer
  PdfWriter
  @param document
  Document