Laravel + mpdf implements automatic paging function
P粉164942791
P粉164942791 2024-03-27 17:16:31
0
1
331

If the data exceeds 10, I try to auto-paginate, I use mpdf laravel vue

This is my CSS code

<style>
div.breakNow { page-break-inside:avoid; page-break-after:always; }
</style>

This is my sale_pdf.blade.php

$i=0;
         @foreach ($details as $detail)
         $i++;
         if( $i % 10 == 0 ){

<div class="breakNow">
             <div id="details_inv">
                <table  class="table-sm">
                   <thead>
                      <tr>
                         <th>PRODUCT</th>
                         <th>UNIT PRICE</th>
                         <th>QUANTITY</th>
                         <th>DISCOUNT</th>
                         <th>TAX</th>
                         <th>TOTAL</th>
                      </tr>
                   </thead>
                   <tbody>
    
                
                      <tr>
                         <td>{{$detail['code']}} ({{$detail['name']}})</td>
                         <td>{{$detail['price']}} </td>
                         <td>{{$detail['quantity']}}/{{$detail['unitSale']}}</td>
                         <td>{{$detail['DiscountNet']}} </td>
                         <td>{{$detail['taxe']}} </td>
                         <td>{{$detail['total']}} </td>
                      </tr>
                   }  @endforeach
                   </tbody>
                </table>
             </div>
           </div>

This is the current output.

Did I miss something? Thank you in advance

P粉164942791
P粉164942791

reply all(1)
P粉489081732

There are two ways to solve this problem.

Option 1






Page 1

Page 2

Option 2 Add class

between table rows
$i=0;
@foreach ($details as $detail)
  $i++;

@endforeach
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template