I have html like
<table>
<tbody></tbody>
</table>
This template is getting converting to PDF with puppeteer where my tabular data is splitting across two pages however i dont want tabular data to split across the pages
I have tried all the solutions of SO for this issue https://github.com/puppeteer/puppeteer/issues/6366 but still I am not able to find the solution I have tried page-break-inside :avoid in tbody/tr its not working I know this css works on block level element so I have tried with wrapping the table in div and applied that css on div still table is breaking in pages Please help if you have any solution
First of all, you need to generate your pdf for
print
. To do it, use this method :This will allow you to control the presentation of content for print with css like
break-before
, see more here : https://developer.mozilla.org/en-US/docs/Web/CSS/Paged_MediaAnswer
You have multiple solutions so :
style="page-break-before: always"
, to ensure that it start on a new page.It could be an hard work to obtain precise render with puppeteer, but puppeteer is probably the best to do it for now. Be brave.