Images, Headers and Footers
Harry
· 24 Sep 2026
· 1 views
Log in to track your progress and mark lessons complete.
Sponsored
Adding an Image
import com.itextpdf.layout.element.Image;
import com.itextpdf.io.image.ImageDataFactory;
Image logo = new Image(ImageDataFactory.create("logo.png"));
logo.setWidth(120);
document.add(logo);Page Headers and Footers
int pages = pdf.getNumberOfPages();
for (int i = 1; i <= pages; i++) {
Document d = new Document(pdf);
d.showTextAligned(new Paragraph("Page " + i + " of " + pages),
550, 20, i, TextAlignment.RIGHT, VerticalAlignment.BOTTOM, 0);
}Add footers after the main content is written, once the page count is known.