Dompdf page break with codeigniter and foreach loop

I use codeigniter and dompdf to create a PDF document.

The document is created using the foreach loop. each loop creates several rows of the table. I want to have a page break between the lines of each loop.

My relevant codeigniter view syntax:

<table width=100%>
<?php foreach($summary as $summary){  ?>
<tr class="firstrow">
<td colspan="10">
<?php echo  "<b>Customer</b>: <font color='blue'>".$summary->caccountname; ?>

<?php echo  "</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Order Number</b>: <font color='blue'>".$summary->OrderNum; ?>

<?php echo  "</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Sales rep</b>: <font color='blue'>".$summary->RepName; ?>

<?php echo  "</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Due Date</b>: <font color='blue'>".substr($summary->DueDate,0,10); ?>
</td>
</tr>
<tr>
<td colspan="10"><hr>
</td>
</tr>
<tr>
<td colspan="10">

  <table class="sortable" width="90%">
  <tr><td ><b>Product</td><td ><b>Ordered</td><td ><b>Processed</td><td ><b>Outstanding</td><td ><b>Dispatched</td><td ><b>Available (incl FJ)</td><td ><b>Available FJ</td></tr>
  <?php foreach($$linedetails as $linedetails){  ?>
  <tr>
  <td><?php echo $linedetails->Product;  ?></td>
  <td><?php echo $linedetails->cubicvolume;  ?></td>
  <td><?php echo $linedetails->Processed;  ?></td>
  <td><?php echo $linedetails->Outstanding;  ?></td>
  <td><?php echo $linedetails->Dispatched;  ?></td>
  <td><?php echo $linedetails->TotalVolume;  ?></td>
  <td><?php echo $linedetails->FJVolume;  ?></td>
  </tr>
  <?php } ?>
  </table>
</td>
</tr>


<?php } ?>
</table>

I gave the first tr class firstrow, I would like the page break to appear in front of this line every time.

As such, I applied the following stylesheet in my page title:

<style>
 @media print
 {
 .firstrow {page-break-before:always}
 }
</style>

This does not work.

How can I get the desired result of placing a page break before each firstrowTR loop ?

Thanks as always

+4
2

,

<?php 
$nbsp5 =  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

foreach($summary as $summary) {  ?>
    <table width="100%" style="page-break-after:always;">
        <tr>
            <td colspan="10">
                <?php echo  "<b>Customer</b>: <font color='blue'>".$summary->caccountname; ?>
                <?php echo  "</font>".$nbsp5 ." <b>Order Number</b>: <font color='blue'>".$summary->OrderNum; ?>
                <?php echo  "</font>".$nbsp5 ." <b>Sales rep</b>: <font color='blue'>".$summary->RepName; ?>
                <?php echo  "</font>".$nbsp5 ." <b>Due Date</b>: <font color='blue'>".substr($summary->DueDate,0,10); ?>
            </td>
        </tr>
        <tr>
            <td colspan="10"><hr></td>
        </tr>
        <tr>
            <td colspan="10">
              <table class="sortable" width="90%">
                <tr>
                    <td><b>Product</b></td>
                    <td><b>Ordered</b></td>
                    <td><b>Processed</b></td>
                    <td><b>Outstanding</b></td>
                    <td><b>Dispatched</b></td>
                    <td><b>Available (incl FJ)</b></td>
                    <td><b>Available FJ</b></td>
                </tr>
              <?php foreach($$linedetails as $linedetails){  ?>
              <tr>
                  <td><?php echo $linedetails->Product;  ?></td>
                  <td><?php echo $linedetails->cubicvolume;  ?></td>
                  <td><?php echo $linedetails->Processed;  ?></td>
                  <td><?php echo $linedetails->Outstanding;  ?></td>
                  <td><?php echo $linedetails->Dispatched;  ?></td>
                  <td><?php echo $linedetails->TotalVolume;  ?></td>
                  <td><?php echo $linedetails->FJVolume;  ?></td>
              </tr>
              <?php } ?>
              </table>
            </td>
        </tr>

    </table>
<?php } ?>

( <table>, )

.

+3

pagebreak tr, css tr

 tr    { page-break-inside:avoid; page-break-after:auto }

.

,

table { page-break-inside:auto }
+4

All Articles