Adding Header and Footer in PDF using iText in Java

You may also like...

6
Leave a Reply

avatar
3 Comment threads
3 Thread replies
4 Followers
 
Most reacted comment
Hottest comment thread
5 Comment authors
alexMemoryNotFoundRafaJakob Schaderozya Recent comment authors
  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

alex
Guest
alex

add only found in 5.5.9 itext

com.itextpdf
itextpdf
5.5.9

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?