I am trying to make a PDF of QR codes, but wkhtmltopdf is adding random padding on the last row of the page even though it should fit fine. It renders fine in the browser.
Full code is here: https://jsfiddle.net/pxga201s/2/
The command I use to render it is:
/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.
When I use:
tr {
page-break-inside: avoid;
page-break-after: auto;
}
it still adds the padding, but just pushes it to the next page:
If you'll always have 4 <tr>
in table you could just do page-break-after: always;
on <table>
without page break on <tr>
elements.
And if you'll have all in one table then you could do something like this (without page break on <table>
):
tr:nth-child(4n+5){
page-break-inside: avoid;
page-break-after: always;
}
I tested both and it works fine. Even with much more pages.
Update
Full example here https://jsfiddle.net/pxga201s/4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With