Have you tried the JS solution? This is actually not so difficult. I just did a test with a long html file that contained a table divided into several different pages, and I was able to remove the headers from pages 1 and 3 using this header file:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script> function subst() { var vars={}; var x=document.location.search.substring(1).split('&'); for (var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);} var x=['frompage','topage','page','webpage','section','subsection','subsubsection']; for (var i in x) { var y = document.getElementsByClassName(x[i]); for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]]; if(vars['page'] == 1){ </script> </head> <body style="border:0;margin:0;" onload="subst()"> <table style="border-bottom: 1px solid pink; width: 100%; margin-bottom:5px;" id="FakeHeaders"> <tr> <th>Your awesome table column header 1</th> <th>Column 2</th> <th style="text-align:right"> Page <span class="page"></span>/<span class="topage"></span> </th> </tr> </table> </body> </html>
They indicate that the header tables are not contained in the table with the identifier FakeHeaders. The javascript subst () function is run when the body is loaded, and during the function it checks whether the current page is 1, or if the current page is 3, and if so, FakeHeaders is set invisible. You will need to play with the fields and CSS to make them look the way you want, but this should work.
This is a known issue with wkhtmltopdf and most likely it will not be fixed in the near future, see question 566 in the tracker release . I see the JavaScript option as the only workaround, but you can try playing with a div or manually breaking tables if your input html, style and page / margin sizes are very predictable - but be careful, this will be very unpleasant.
source share