2016-11-07 68 views
0

嘗試使用barryvdh的laravel dompdf包裝創建PDF發票。當達到一定數量的行時,我希望發票在新頁面上開始。但是我不確定如何去做,因爲我沒有得到預期的結果。這裏是我的控制器:Laravel&laravel-dompdf分頁僅顯示第1頁

function invoice() { 

     $resellerId = Input::get('resellerId'); 
     $startdate = Input::get('invoiceStartDate'); 
     $enddate = Input::get('invoiceEndDate'); 

     $orders = \App\order::where('reseller',1)->orderBy('date', 'desc')->where('customer_id' , $resellerId)->where('date', '>=',$startdate)->where('date', '<=',$enddate)->get(); 

      $pdf = PDF::loadView('pdf.invoicePrint',['orders' => $orders]);      
      // $PDFOutput = $pdf->output(); 
      return $pdf->stream("trestaki.pdf"); 
} 

,這裏是葉片的相關部分:

<table style="border:1px solid #000;width: 100%;"> 
     <tr> 
     <td> 
      <span style="font-size: 14px;font-weight: 900;">Art. Nr.</span> 
    </td><td> 
      <span style="font-size: 14px;font-weight: 900;">Benämning</span> 
     </td><td> 
      <span style="font-size: 14px;font-weight: 900;">Antal</span> 
    </td><td> 
      <span style="font-size: 14px;font-weight: 900;">Pris</span> 
     </td><td> 
      <span style="font-size: 14px;font-weight: 900;">Summa</span> 
     </td></tr> 
    <?php $i=0; ?> 
    @foreach($orders as $order) 
    <tr> 
     <td>{{ $order->order_id }}</td> 
     <td>{{ $order->getProduct->mobile }} {{ $order->getProduct->model }}</td> 
     <td>1</td> 
     <td>{{ $order->price }}</td> 
     <td>{{ $order->price }}</td> 
    </tr> 
    <?php 

    $i++; 
    if($i % 25 == 0) 
     echo "<div style='page-break-after: always;'></div>"; 

    ?> 

    @endforeach 
    <tr> 
     <td colspan=5 style="padding-top: 20px;"> 
      <table style="width: 45%;"> 
      <tr> 
       <td> 
        <span style="font-size: 14px;font-weight: 900;">Moms %</span> 
       </td> 
       <td> 
        <span style="font-size: 14px;font-weight: 900;">Netto</span> 
       </td> 
       <td> 
        <span style="font-size: 14px;font-weight: 900;">Moms</span> 
       </td> 
       <td> 
        <span style="font-size: 14px;font-weight: 900;">Summa</span> 
       </td>     
      </tr>  
      <tr> 
       <td>25%</td> 
       <td>639,20</td> 
       <td>159,80</td> 
       <td>799,00</td> 
      </tr> 
      </table> 
     </td> 
    </tr> 
    </table> 

的事情是,如果我從回聲,網頁超時刪除所有關閉標籤。

回答

0

問題在於主div的固定位置。刪除後,頁面確實正確地斷開。