0
我有一個由多個記錄組成的大型單個pdf文檔。我需要使用laravel將表格記錄拆分或分割成pdf中的第二個頁面。如何使用laravel將表格內容分成thujohn pdf的第二頁
在控制器中使用以下編碼時,表格記錄沒有完全顯示。該pdf文件中缺少一些表格記錄,因此我需要將缺少的表格記錄顯示爲pdf文件的第二個pafe。
private function generatePdf($customerstatement, $content) {
if (!is_dir(RECEIPTS_DIR)){
mkdir(RECEIPTS_DIR, 0755, true);
}
$outputName = $customerstatement->card_id . '-' . strtoupper(date("MY")) .'.pdf';
$pdfFileName = RECEIPTS_DIR.'/' . $outputName;
$view = View::make("admin.document.statement", compact('customerstatement', 'content'))->render();
$pdf = new \Thujohn\Pdf\Pdf();
$bytes_written = File::put($pdfFileName, $pdf->load($view, 'A4', 'portrait')->output());
if ($bytes_written === false) {
throw new \Exception("Unable to produce pdf statement");
}
$customerstatement->pdffile = $outputName;
$customerstatement->save();
return $outputName;
}
下面的編碼寫在刀片文件中用於顯示pdf中的記錄。
<tbody>
<tr>
<td colspan="7"><b>{{ $customerstatement->customer->card_id }} - {{ $customerstatement->customer->fullName }} </b>
</td>
</tr>
<tr>
<td colspan="7"><b>Beginning Balance : {{ $customerstatement->beginning_balance }}</b>
</td>
</tr>
@foreach ($customerstatement->statements as $statement)
<tr>
<td width="7em">{{{ $statement->date }}}</td>
<td width="15em">{{{ $statement->memo }}}</td>
<td width="6em" align="center">{{{ $statement->debit }}}</td>
<td width="6em" align="center">{{{ $statement->credit}}}</td>
<td width="6em" align="center">{{{ $statement->closing_balance}}}</td>
</tr>
@endforeach
</tbody>