6

Please excuse my English.

I am printing a large report in pdf format including some tables (table after table). To do this, I first generated the report in html, then passed it on to pdf using dompdf

This is the way I print one table after another:

<div>
  <table>
  -----
  </table>
</div>

<div>
  <table>
  -----
  </table>
</div>

This is the way in which printed tables when there is a page break

The problem is that when there is a page break, the table rows are split. I want to avoid it.

I tried using the CSS Print Properties, but it does not work, in other cases as page-break-before: always; print each table of my report on a different page.

<style type="text/css">
table { page-break-inside:auto }
tr    { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>

As I can force page breaks in all tables in my report only if necessary.

Please help.

peak
  • 105,803
  • 17
  • 152
  • 177
sebastianpe93
  • 71
  • 1
  • 1
  • 6
  • dompdf does not currently recognize paging directives on table elements. But you'll need to clarify the issue because dompdf also doesn't really support breaking cell content across pages. By default if a table cell is unable to fit on a page the entire row is moved to the next page. – BrianS Feb 01 '16 at 03:31

2 Answers2

4

Check this links: Link1
Link2
Link3

There is lot of answer related to your question so try this answers first. You might try this with CSS:

<table class="print-friendly">
 <!-- The rest of your table here -->
</table>

<style>
    table.print-friendly tr td, table.print-friendly tr th {
        page-break-inside: avoid;
    }
</style>

Most CSS rules don't apply to <tr> tags directly, because of exactly what you pointed out above - they have a unique display style, which doesn't allow for these CSS rules. However, the <td> and <th> tags within them usually do allow this kind of specification - and you can easily apply such rules to ALL child-<tr>'s and <td>'s using CSS as shown above.

Community
  • 1
  • 1
Amitesh Kumar
  • 3,051
  • 1
  • 26
  • 42
0

@sebastianpe93 Try adding your styles in print media query. That should work