Abhijeet Gupta
Abhijeet Gupta

Reputation: 57

Creating a PDF with PDFkit and Wkhtmltopdf, but encountering an issue where the entire table is being pushed to the next page. How can I resolve this

I'm facing an issue while generating PDFs in Python Django using PdKit and Wkhtmltopdf. Specifically, when the table has more than 10 items, it gets pushed to the next page. I've attempted the following solutions:

  1. Added the following CSS styles:
    page-break-inside: avoid !important;
}
table { page-break-inside:auto }
tr    { page-break-inside:avoid  !important; page-break-after:auto !important }
thead { display:table-header-group   !important}
tfoot { display:table-footer-group   !important} ```


 2. Tried using the JavaScript solution provided - https://github.com/AAverin/JSUtils/blob/master/wkhtmltopdfTableSplitHack/wkhtmltopdf_tableSplitHack.js

[![Image 1 ][1]][1]
[![Image 2][2]][2]


  [1]: https://i.sstatic.net/TO2Hb.png
  [2]: https://i.sstatic.net/Dt3Wl.png

Upvotes: 0

Views: 95

Answers (1)

Antonio Rocca
Antonio Rocca

Reputation: 1

I don't know the specifics of your html, but I was experiencing this exact behaviour and found that the overflow property of the parent div of my table was a contributing factor. In particular, I had to set overflow to visible on the div.

Upvotes: 0

Related Questions