Wkhtmltopdf randomly adds an extra padding to the last line

I am trying to make a PDF code of a QR code, but wkhtmltopdf adds a random addition to the last line of the page, even if it should be fine. It is displayed perfectly in the browser.

Full code here: https://jsfiddle.net/pxga201s/2/

The command I use to render it:

/usr/local/bin/wkhtmltopdf --margin-bottom 0 --margin-left 0 --margin-right 0 --margin-top 0 'file:///path/to/qrcodes-5-6.pdf.html' '/path/to/qrcodes-5-6.pdf' 

I am using wkhtmltopdf 0.12.3 (with patched qt) on Mac 10.10.5.

enter image description here When i use:

 tr { page-break-inside: avoid; page-break-after: auto; } 

he still adds the add-on, but just clicks it on the following page:

enter image description here

+6
source share
1 answer

If you always have 4 <tr> in the table, you can just do page-break-after: always; on <table> without page break on <tr> elements.

And if you have everything in one table, you can do something like this (without breaking the <table> page):

 tr:nth-child(4n+5){ page-break-inside: avoid; page-break-after: always; } 

I tested both and it works great. Even with a lot more pages.

Update

Full example here https://jsfiddle.net/pxga201s/4/

+1
source

Source: https://habr.com/ru/post/1012086/


All Articles