public void HandleEvent(iText.Kernel.Events.Event @event) { PdfDocumentEvent docEvent = (PdfDocumentEvent)@event; PdfPage page = docEvent.GetPage(); PdfCanvas pdfCanvas = new PdfCanvas(page); Rectangle pageSize = page.GetPageSize(); iText.Layout.Canvas canvas = new iText.Layout.Canvas(pdfCanvas, pageSize); Paragraph headerP = new Paragraph(); foreach (IElement elem in elements) { if (elem is IBlockElement) { headerP.Add((IBlockElement)elem); } else { if (elem is Image) { headerP.Add((Image)elem); } } } Paragraph footerP = new Paragraph(); foreach (IElement elem in footer) { if (elem is IBlockElement) { footerP.Add((IBlockElement)elem); } else { if (elem is Image) { footerP.Add((Image)elem); } } } canvas.ShowTextAligned(headerP, pageSize.GetWidth() / 2, pageSize.GetTop() - 30, TextAlignment.LEFT); canvas.ShowTextAligned(footerP, 0, 0, TextAlignment.LEFT); }