Adding Header and Footer in PDF using iText in Java

You may also like...

Leave a Reply

5 Comments on "Adding Header and Footer in PDF using iText in Java"

avatar
  Subscribe  
newest oldest
Notify of
rozya
Guest
rozya

to get the right number of pages you need to replace String.valueOf(writer.getPageNumber()) by String.valueOf(writer.getPageNumber()-1) in public void onCloseDocument(PdfWriter writer, Document document)
thanks, the code was helpful

Rafa
Guest
Rafa

Thanks!

Jakob Schade
Guest
Jakob Schade

I get an error with:
total = Image.getInstance(t);
total.setRole(PdfName.ARTIFACT);
//He doesn´t know total.setRole AND doesn´t know PdfName.ARTIFACT

AND
PdfContentByte canvas = writer.getDirectContent();
canvas.beginMarkedContentSequence(PdfName.ARTIFACT);
footer.writeSelectedRows(0, -1, 34, 50, canvas);
canvas.endMarkedContentSequence();
//He doesn´t know PdfName.ARTIFACT and tells me there are unsychronize things or something similar

Rafa
Guest
Rafa

I have a problem with the footer, because it overlaps the text that I put in the body of the document. Do you know how I fix it so they do not overlap?