Rotativa - Strange Header Output
Asked Answered
P

1

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

Pronounce answered 6/7, 2015 at 14:46 Comment(0)
P
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...

Pronounce answered 6/7, 2015 at 15:26 Comment(2)
The correct solution is to use thead, tfoot { display: table-row-group }Peggy
@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.Pikeman

© 2022 - 2024 — McMap. All rights reserved.