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

  • Home
  • SEARCH
  • 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 7785781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:18:38+00:00 2026-06-01T20:18:38+00:00

I am using MVC2, header and footer worked well with iTextSharp 4.1.6, however it

  • 0

I am using MVC2, header and footer worked well with iTextSharp 4.1.6, however it didn’t with 5.2. Here is my code:

    public FileStreamResult GridPDF()
            {
                MemoryStream workStream = new MemoryStream();

                //the document
                Document document = new Document();


                PdfWriter.GetInstance(document, workStream);//fs);


                document.Open();


                iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont("Arial", 10);
                iTextSharp.text.Font font6 = iTextSharp.text.FontFactory.GetFont("Arial", 18);
                             //HeaderFooter header = new HeaderFooter(new Phrase(BPheader, FontFactory.GetFont("Arial", 8, Font.BOLD)), false);
            //header.Border = Rectangle.BOTTOM_BORDER;
            ////header.GrayFill=(Color.GRAY);
            //document.Header = header;

            //HeaderFooter footer = new HeaderFooter(new Phrase("Page: ", FontFactory.GetFont("Arial", 8, Font.ITALIC)), true);
            //footer.Border = Rectangle.TOP_BORDER;
            //document.Footer = footer;
                PdfPTable tableh = new PdfPTable(1);
                PdfPCell cellh = new PdfPCell(new Phrase("", FontFactory.GetFont("Arial", 10)));
                cellh.Colspan = 1;
                tableh.HorizontalAlignment = 0;
                tableh.WidthPercentage = 100;
                cellh.BorderWidth = 3;
                cellh.Padding = 0;
                Image image = Image.GetInstance(Server.MapPath("~/Content/images/logo_small.png"));
                //  image.Alignment = 6; // iTextSharp.text.Image.ALIGN_RIGHT;
                image.ScalePercent(40f); // change it's size
                image.SetAbsolutePosition(500, 750);
                document.Add(image);

                Paragraph p = new Paragraph("Certificate", font6);
                p.Alignment = 1;
                document.Add(p);
                tableh.DefaultCell.Border = Rectangle.TOP_BORDER;
                tableh.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
                tableh.AddCell(cellh);

                //close the document
                document.Close();
                //prepare output stream
                byte[] byteInfo = workStream.ToArray();
                SendPdfToBrowser(byteInfo);
                r

eturn null;
        }

Any suggestions!! Thanks in advance.

  • 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-06-01T20:18:39+00:00Added an answer on June 1, 2026 at 8:18 pm

    I think I know your issue, the HeaderFooter property in iTextSharp was removed in version 5+. This answer should help get you on your way. Basically, you will need to use the PageEvents class to add your header and footer.

    Create a class that inherits from PdfPageEventHelper and implement its members. You only really need OnStartPage for your header and OnEndPage for your footer. During PDF creation, iTextSharp will fire each of those methods for every page in your PDF.

    Additionally, here is a more thorough example (in C#).

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

Sidebar

Related Questions

I'm using MVC2, mono 2.10.5, mod-mono-server4. ELMAH is configured as per here , but
does anyone know any tool for 'code generation' using MVC2? I know that ASP
Asmx web service is called using Visual Studio generated code from MVC2 controller using
I'm using MVC2, Preview 2. Why is it that when I use: <%= Html.LabelFor(x
I'm using MVC2 with VS2010 I have a view that has two partial views
I am just trying to populate a html.dropdown list using mvc2 in VS2008. But
I am using ASP.NET MVC2 and Entity Framework. I am going to simplify the
I'm using asp.net mvc2 and trying to send a list of json objects with
I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My

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.