I\'m using iText to generate a PDF. I created a custom PdfPageEventHelper to add a header (and footer) to each page.
My problem is I don\'t know how to add the imag
I've set abolute positions and alignment to the image (in this case I placed my image in the header)
try {
Image img = Image.getInstance("url/logo.png");
img.scaleToFit(100,100);
img.setAbsolutePosition((rect.getLeft() + rect.getRight()) / 2 - 45, rect.getTop() - 50);
img.setAlignment(Element.ALIGN_CENTER);
writer.getDirectContent().addImage(img);
} catch (Exception x) {
x.printStackTrace();
}
I've also adjusted the the document margins in order to have delimited space in the header and footer of the document.
document.setMargins(20, 20, 100, 100);