尝试使用barryvdh的laravel dompdf包装器创建PDF发票。我希望在达到一定数量的行时,在新页面上开始发票。但是我不确定如何做到这一点,因为我没有得到预期的结果。这是我的控制器:
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>
问题是如果从echo中删除所有结束标记,则网页会超时。
答案 0 :(得分:0)
问题是主要div的固定位置。删除后,页面确实破坏了。