code: @Override
  	public void onEndPage(final PdfWriter writer, final Document document) {
  		final int pageN = writer.getPageNumber();
  		final String text = pageN + " / ";
  		final float len = bf.getWidthPoint(text, 8);
  		cb.beginText();
  		cb.setFontAndSize(bf, 8);
  		final float width = document.getPageSize().getWidth();
  		cb.setTextMatrix(width / 2, 30);
  		cb.showText(text);
  		cb.endText();
  		cb.addTemplate(template, width / 2 + len, 30);
  	}
docs: we override the onEndPage method.
  
  @param writer
  PdfWriter
  @param document
  Document