wkhtmltopdf repeated table headers overlap rows when rows contain long, multi-line text [closed]

14 hours ago 1
ARTICLE AD BOX

I am using wkhtmltopdf 0.12.6.1 (patched Qt) to convert HTML tables to PDF.
The HTML renders correctly in all browsers, but the generated PDF has layout issues.

Problem

When a table:

spans multiple pages

uses <thead> for repeating headers

has many columns (15+ in the real case)

contains long, multi-line text that increases row height

the repeated table header overlaps the first data row on the new page, and sometimes the first row is partially truncated.

This issue does not occur when:

rows are short (single-line text), or

the table fits on a single page.

wkhtmltopdf command used

wkhtmltopdf \ --orientation Landscape \ --footer-center "name of the template" \ --footer-font-size 10 \ --footer-spacing 5 \ input.html output.pdf

Minimal reproducible example

The following HTML renders correctly in browsers, but produces header overlap in wkhtmltopdf when the table breaks across pages:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> body { font-family: Arial; font-size: 10pt; line-height: 1.4; } table { width: 100%; border-collapse: collapse; } table, th, td { border: 1px solid black; } td { padding: 10px; white-space: normal; word-wrap: break-word; } </style> </head> <body> <table> <thead> <tr> <th>ID</th> <th>Description</th> <th>Date</th> </tr> </thead> <tbody> <!-- duplicate this row multiple times to force a page break --> <tr> <td>1</td> <td> <!-- Add very long text to force a page break --> NOTE:Add very long text so that the row data should fall in to next page This is a long text value that wraps into multiple lines and increases the row height. When the table breaks across pages, the repeated header overlaps this row in wkhtmltopdf. </td> <td>23/01/2026</td> </tr> </tbody> </table> </body> </html>

Question

How can table headers be repeated correctly in wkhtmltopdf when table rows contain long, multi-line text, without header overlap or row truncation?
Are there known CSS workarounds or wkhtmltopdf-specific limitations for this case?

Read Entire Article