how i can add header to each PDF page using iText 5.0.5.
This is covered in chapter 5 of iText In Action, 2nd ed. The code examples are all freely available online. In particular MovieCountries1 and MovieHistory2 both deal with page headers and footers.
It boils down to using a PdfPageEvent
implementation (usually derived from PdfPageEventHelper
to cut down on boilerplate) to draw into the page's Direct Content during an EndPage (or BeginPage I suppose) event.
You have to know where you want them, and you have to draw using a PdfContentByte
instance, so you can't use the high-level Paragraph/Chapter/Chunk/Image/etc classes. You have to draw-this-there, draw-that-here. ColumnText
can help a bit... but only for Plain Text. Anything even remotely fancy and you're on your own.
See the below link having video to show you.
http://itextpdf.com/book/chapter.php?id=4
For Header-Footer: http://kuujinbo.info/cs/itext.aspx
http://www.codeproject.com/KB/graphics/ITextSharpHelperClass.aspx
Please Vote if this helps to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With