PdfPageEvent
PdfPageEventHelper
Note: do not use Document.add() inside a page event. @author Paulo Soares
158159160161162163164165166167168
// Initialize the Document and register it with PdfWriter listener and the OutputStream Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40); document.addCreationDate(); PdfWriter writer = PdfWriter.getInstance(document, out); writer.setPageEvent(new PdfPageEventHelper() { @Override public void onEndPage(PdfWriter writer, Document document) {