Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 721947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:55:56+00:00 2026-05-14T05:55:56+00:00

This is weird, I am currently using iTextSharp and I want to add a

  • 0

This is weird, I am currently using iTextSharp and I want to add a Header & Footer to my PDFs. In all the examples they simply create a new HeaderFooter() object. However, I have iTextSharp libraries all imported but the HeaderFooter is not defined. I’ve used Reflector to see if I can find out whereabouts the class is and its missing?!

Does anyone know what has happened to this class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:55:56+00:00Added an answer on May 14, 2026 at 5:55 am

    Most of the examples refer to an earlier version of iTextSharp. For version 5+ of iTextSharp (which I assume you are using) the HeaderFooter property/object has been removed.

    See
    http://itextpdf.com/history/?branch=50&node=500 (last line)

    To add Headers/Footers now you must use PageEvents. The following code demonstrates how to do this in VB. You basically have to inherit the PageEventsHelper class and watch for the OnStartPage event – then add your code as necessary.

    Imports iTextSharp.text.pdf
    Imports iTextSharp.text
    Imports System.IO
    Module Module1
        Sub Main()
            Dim pdfDoc As New Document()
            Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(pdfDoc, New FileStream("tryme2.pdf", FileMode.Create))
            Dim ev As New itsEvents
            pdfWrite.PageEvent = ev
            pdfDoc.Open()
            pdfDoc.Add(New Paragraph("Hello World"))
            pdfDoc.NewPage()
            pdfDoc.Add(New Paragraph("Hello World Again"))
            pdfDoc.Close()
        End Sub
    End Module
    
    Public Class itsEvents
        Inherits PdfPageEventHelper
        Public Overrides Sub OnStartPage(ByVal writer As iTextSharp.text.pdf.PdfWriter, ByVal document As iTextSharp.text.Document)
            Dim ch As New Chunk("This is my Stack Overflow Header on page " & writer.PageNumber)
            document.Add(ch)
        End Sub
    End Class
    

    It initially looks like more work but has the upside that you can add more to your header/footer than just plain text. You can now for example easily add anything that Document will support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please explain this weird phenomenon: http://jsfiddle.net/sPA2V/ For some reason, the box footer
Currently I'm using <pre><code> code here </code><pre> to display code. I'm pulling this information
This might be a weird question. Currently, I have a table with a bunch
I'm currently working with a library and noticed something weird when using functions I
I know this question sounds weird, but please, let me explain myself. I'm using
Possible Duplicate: Core Data not saving NSString. Hey all! Currently experiencing a weird issue
something weird is happening to my program. I am currently using lots of threads
this weird thing is happening with my uitableview cell selection style, Instead of changing
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
I'm getting this weird issue. Basically I'm animating a view with translate animation. (Translate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.