Repeat HTML Table Header on Each PDF Page |
When an HTML table spans several PDF pages, the converter repeats the head of the table at the top of each page the table continues on. This works for any table whose head is in a thead element, the way the Chrome browser repeats it when it prints a page; the tfoot element of a table is repeated at the bottom of each page in the same way.
The repetition comes from the display: table-header-group style, which is the default style of a thead element. If the page gives its table heads another display style, restore it:
thead { display: table-header-group; }
tfoot { display: table-footer-group; }This is useful for long tables, so the reader of the document always knows which column the data on a page belongs to. The repeated head can contain anything a table head can - text, images or any other HTML. Combine it with page-break-inside: avoid on the rows (see Page Breaks) so that no row is split between two pages.