2

Facing issue while converting HTML to PDF long one almost 3-4 pages of tables data is available. Its getting cut and distorted.

I tried most of solution which is mention related to wkhtmltopdf stackoverflow thread.enter image description here

table, tr, td, th, tbody, thead, tfoot {
    page-break-inside: avoid !important;
}

this doesnt help me

Any help in this ?

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
  • And what's the goal, to break on table row? Seems like your css is wrong, you specified not to break the page anywhere. – skobaljic Oct 15 '19 at 08:31
  • Have you tried a simple `tr {page-break-inside: avoid; }`? Also make sure you use [latest wkhtmltopdf library](https://wkhtmltopdf.org/downloads.html). – skobaljic Oct 15 '19 at 08:37
  • i tried this also its not worked @skobaljic – Avinash Dalvi Oct 15 '19 at 08:41
  • its getting cut half-half. I have to solve that issue. – Avinash Dalvi Oct 15 '19 at 08:41
  • Yeah... seems like they still haven't solved it, check [this](https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3195) and [that](https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2141)... Maybe best to divide your table before printing/converting? – skobaljic Oct 15 '19 at 08:59
  • @skobaljic this solve issue see the answer. – Avinash Dalvi Dec 20 '19 at 08:08
  • Great, you can see I googled 30 minutes and I saw all those issues, for which people said they were solved... and at the end you tell us you used old version lols :) – skobaljic Dec 20 '19 at 16:31

1 Answers1

3

Upgrading wkhtmltopdf to version 0.12.5 with qt patched resolved my issue.

Script to install wkhtmltopdf 0.12.5 with qt patched on ubuntu

If you face any issues related to zooming and extra whitespace try add these options in the wkhtmltopdf npm package

--zoom  value between 0.0 to 1.0

--disable-smart-shrinking 

Issues related to this from GitHub : Regression on upgrade from 0.12.3 to 0.12.5

Malavan
  • 789
  • 7
  • 27