I need to render an invoice PDF with puppeteer that contains a table with items. These items can contain description/comments/etc. The table overflows onto the next div beneath it. In case it overflows the behaviour should break into the next page.
I've tried many css break-* and @page with no luck, max height but then the table isn't fully visible and many other things. Should I jump ship of the table and just use divs?
.pdf {
background-color: #FFF;
overflow: hidden !important;
display: grid;
grid-template-rows: 190px minmax(10px, 246px) 786px 212px 1fr;
grid-row-gap: 1em;
}
.table-container {
table { page-break-inside: auto }
tr { page-break-inside: avoid; page-break-after: auto }
thead { display: table-header-group }
tfoot { display: table-footer-group }
}
table {
width: 100%;
border-spacing: 0;
border-collapse: collapse;
}
// ... other elms ...
<div class="pdf">
<header>
... company header logo and other details ...
</header>
<div class="details">
... invoice details ...
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th class="text-left">PRODUCT</th>
<th class="text-left">DESCRIPTION</th>
<th class="text-right">PRICE</th>
<th class="text-right">UNIT</th>
<th class="text-right">QUANTITY</th>
<th class="text-right">TOTAL</th>
</tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</div>
<div class="details">
this div gets overflowed
</div>
</div>