Search code examples
headeritextfooter

iTextSharp Header Footer help


I am using iTextSharp to generate pdf in my .net application. Now I want to add Header and Footer in my pdf document. I got code from a site something like given below but it doesn't work. [ //we Add a Header that will show up on PAGE 1 HeaderFooter header = new HeaderFooter(new Phrase("This is a header"), false); document.Header = header; ] I create document object like:- Dim document As text.Document = New text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25) But it doesn't have property of Header as mention in the above code. Can anyone suggest me how to do it.


Solution

  • Unfortunately I cannot help you regarding your iTextSharp issue as we have stopped using it when we found out, that it cannot automatically break the content for multi-page PDFs, and it forces the programmer to hardcode critical values leading to bad coding.

    In the same time, if it's not a problem to change the PDF generator library for your project then you may check out PDFSharp and Migradoc which we're using succesfully for over 1 year now. Much simpler to integrate then iTextSharp, requires less code, it has great charting tools, a much more intuitive object oriented model and the best part is that it has a great documentation with a dozen of working example projects.

    Happy coding!