I am using iText to create a PDF file. I created a custom PdfPageEventHelper to add a header (and footer) to each page.
My problem: I do not know how to add an image so that it appears in the "title bar". I only know how to add an image to the document itself (if that makes sense).
Here are some code snippets ...
public static void main(String[] args) { Rectangle headerBox = new Rectangle(36, 54, 559, 788); Document document = new Document(PageSize.A4, 36, 36, 154, 54); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILENAME)); HeaderFooter event = new HeaderFooter(); writer.setBoxSize("headerBox", headerBox); writer.setPageEvent(event); document.open(); addContent(); document.close(); } static class HeaderFooter extends PdfPageEventHelper { public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("headerBox");
Any suggestions on an appropriate way to add an image to the title are welcome.
Rob
source share