Reputation: 21
I'm using verison 0.12.5 of wkhtmltopdf on Debian Buster. I cannot get it to do any of the following behaviors that control table display and pagination with CSS declarations:
The production table I am working with is very tall (100s of rows) and I need the table header to print at the top of each page. I would also like to avoid breaking in the middle of a row.
I have successfully gotten it to add a page break at the end of a table and I can specify the page orientation on the command line, but I need to control all of these behaviors using CSS (stylesheet or inline is fine) on the actual document.
Sample code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page</title>
<style type="text/css">
thead { display: table-header-group }
tfoot { display: table-row-group }
tr { page-break-inside: avoid }
</style>
</head>
<body>
<h1>Title Here</h1>
<div>
<span id="filterModeLabel" class="FilterMode">Show all</span>
<table>
<thead>
<tr><th>FirstName</th><th>LastName</th></tr>
</thead>
<tbody>
<tr><td>John</td><td>Smith</td></tr>
<tr><td>John</td><td>Smith</td></tr>
<!-- Enough lines to push it onto two pages -->
<tr><td>John</td><td>Smith</td></tr>
<tr><td>John</td><td>Smith</td></tr>
</tbody>
</table>
</div>
</body>
</html>
I have also tried the following stylesheet variations with no luck:
@page {
size: letter;
size: landscape;
margin-top: .40in;
margin-left: .40in;
margin-right: .40in;
margin-bottom: .25in;
font-size: 10px;
@bottom-right { content: "Page " counter(page) " of " counter(pages)};
}
thead{
display: table-header-group
}
tfoot {
display: table-row-group
}
tr {
page-break-inside: avoid
}
table {
page-break-inside:auto;
word-wrap: break-word;
page-break-after: always;
border-collapse:collapse;
}
table tbody tr{
page-break-inside:avoid;
}
table.standard thead {
display:table-header-group;
font-size: 12px;
}
table tfoot { display: table-row-group; }
table tbody tr td
,table thead tr th {
font-size: 12px;
line-height: 10pt;
border: 1px solid black;
}
This is the call I am running on the command line:
wkhtmltopdf p1.html p1a.pdf
Here are screenshots of the result I get (top of pages 1 and 2): Top of page 1 Split between pages 1 and 2
Upvotes: 1
Views: 1333
Reputation: 21
debian buster installs without patched QT this resolved my issue.
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb apt install ./wkhtmltox_0.12.6-1.buster_amd64.deb
Upvotes: 1