locked
ItextSharp Footer and Header Problem RRS feed

  • Question

  • User-1535678595 posted

    I have a problem with my pdf tables header and footer.

    PdfPTable Headtable = new PdfPTable(7);
    Headtable.TotalWidth = 525f;
    Headtable.LockedWidth = true;
    Headtable.HeaderRows = 3;

    When i add the HeaderRows and test it, It works perfect. I get a header on each side.

    But if i Add a FooterRows.

    PdfPTable Headtable = new PdfPTable(7);
    Headtable.TotalWidth = 525f;
    Headtable.LockedWidth = true;
    Headtable.HeaderRows = 3;
    Headtable.FooterRows = 3;

    My header disappears and the content that should have been in the header now is down in the footer.

    How can I solve this so i can select the correct row for my footer?

    Tuesday, November 4, 2014 8:23 AM

Answers

  • User1508394307 posted

    The number of footer rows are subtracted from the header rows. For example, for a table with two header rows and one footer row the code should be:

    table.setHeaderRows(3);
    table.setFooterRows(1);

    Row 0 and 1 will be the header rows and row 2 will be the footer row.

    In your case, if you want to have 3 rows in header and 3 in footer you should do

    Headtable.HeaderRows = 6;
    Headtable.FooterRows = 3;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 4, 2014 9:08 AM