private void addHeaderAndFooter(PdfWriter writer, Document document) { if (document.getPageNumber() == 1) { return; } String header = docInstallArgs.getDocName() + " version" + docInstallArgs.getVersion(); PdfContentByte directContent = writer.getDirectContent(); Phrase headerPhare = ItextUtil.getFontSelector(9, Font.NORMAL, Color.LIGHT_GRAY).process(header); headerPhare.add(new LineSeparator(0.5f, 2.5f, Color.LIGHT_GRAY, Element.ALIGN_LEFT, -5f)); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, headerPhare, document.left(), document.top() + 20, 0); String footer = Integer.valueOf(document.getPageNumber()).toString(); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, textbFont.process(footer), document.getPageSize().getWidth() / 2.0f - 20, document.bottom() - 20, 0); }