I am generating a PDF invoice report using OpenPDF. On the PDF, I have to set a rectangular block for header/footer on every page. I have used the HeaderFooter class to add header/footer on every page but this works only for a Phrase.
HeaderFooter header = new HeaderFooter(new Phrase("This is a Header."), false);
Is there any way to set a rectangular block with height and width for header/footer using HeaderFooter class?
This is what I am expecting on every page:

You can do this by creating your custom
PdfPageEventwhere you add the elements whenever a new page is finished (onEndPage-event). The simplest way of doing this is by extendingPdfPageEventHelperin a standalone class or in an anonymous class. First, define and style your rectangles. Second, add them to the page using thePdfWriterinside the callback.Here is a demo showing how to do it:
The result looks like this: