First of all, I found no duplicate of this, since the problem is not trying to avoid the break inside a row (this already works well) and I am not allowed to repeat headers on the next page.
Misc. threads that did not help with the problem but are related :
- How to prevent line breaks in list items using CSS
- Applying "page-break-before" to a table row (tr)
- Google Chrome Printing Page Breaks
- Printing a Gridview - how to print n rows on each page using page break
I am printing a table on a PDF, and I want my table to print on the first page if and only if it has at least two rows displayed. If there is not enough space for 2 rows, I want the whole table to move to the next page.
In order to achieve that, I tried to apply a :
page-break-after: avoid;
to my first <tr>
tag. The idea being to forbid breaks between first and second row so they are always together. But this does not seem to work.
How can I achieve this behavior ? Is this the right approach and/or are there others ?
update: Also tried to declare the <tr>
as a block in CSS, but still no dice. Then tried to insert a "linker" <tr>
, displayed as a block, between row 1 and row 2 with :
page-break-after: avoid;
page-break-before: avoid;
but still not working.