6

I am trying to fix an issue where the table header in my HTML is not rendering correctly on subsequent pages. Any ideas on how to fix this issue?

The header

 <thead>
                <tr>
                    <th></th>
                    <th>@Index.LastName</th>
                    <th>@Index.FirstName</th>
                    <th>@Index.Contact</th>
                    <th>@Index.Division</th>
                    <th>@Index.ClubName</th>
                    <th>@Index.Position</th>
                </tr>
            </thead>

The action:

public ActionResult PrintResults(UserMemberSearchViewModel model)
{
    model.Results = UserMemberSearchTasks.Search(model);
    return new PartialViewAsPdf("ResultsPDF", model)
    {
        FileName = Resources.UserMemberSearch.Index.MemberDetails + ".pdf",

    };
}

The result

enter image description here

Slinky
  • 5,662
  • 14
  • 76
  • 130

1 Answers1

14

This solved the issue, which is caused by a bug in wktohtml, apparently.

<style>
      tr { page-break-inside: avoid;}
</style>

See this for more...

Slinky
  • 5,662
  • 14
  • 76
  • 130
  • 2
    The correct solution is to use `thead, tfoot { display: table-row-group }` – ashkulz Jul 13 '15 at 10:36
  • 1
    @ashkulz: That does prevent the problem as well, only because it removes the header from all pages except the first page. If you want to keep the header on each page, then Slinky's answer is actually what works. – mellamokb Nov 16 '16 at 16:48