[英]codeigniter dompdf page break issue during maximum table records
對於有限的表格記錄 pdf 看起來不錯。
所有表格記錄在“echo $html”中看起來都不錯,但在創建 pdf 后,當表格記錄最大時,分頁符不起作用。 它在最大記錄期間創建前 4-5 頁為空。
最大表記錄期間的 codeigniter dompdf 分頁問題:
我的代碼片段:
//控制器代碼
function pdf_create($html, $filename='', $stream=TRUE)
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
if ($stream) {
$dompdf->stream($filename.".pdf");
} else {
return $dompdf->output();
}
}
//查看文件代碼
......
......
<tr>
<td>
<table width="100%" border="0" style="border:solid 1px #BFBFBF; page-break-inside: auto;" cellspacing="0" cellpadding="10">
<tr bgcolor="#BFBFBF">
<td><p style="font-size:14px; margin:0px;">Product Name</p></td>
<td><p style="font-size:14px; margin:0px;">Product Quantity</p></td>
<td><p style="font-size:14px; margin:0px;">Product Price</p></td>
<td><p style="font-size:14px; margin:0px;">Total Price</p></td>
</tr>
<?php
$product_title = $product_details['product_titles'];
$prod_quantity = $product_details['product_qty'];
$price = $product_details['product_price'];
$total_price = $product_details['product_cal_price'];
$i = 1;
$j = 0;
$productwisetotal = 0;
foreach ($product_title as $value) { $productwisetotal += $value; ?>
<tr style="font-size:12px;" valign="top">
<td style="border-right:solid 1px #BFBFBF"><?php echo $i.'. '.$value; ?></td>
<td style="border-right:solid 1px #BFBFBF"><?php echo $prod_quantity[$j]; ?></td>
<td style="border-right:solid 1px #BFBFBF"></td>
<td style="border-right:solid 1px #BFBFBF"></td>
</tr>
<?php $i++;
$j++;
} ?>
</table>
</td>
</tr>
.....
.....
請告訴我當表格包含最大記錄時如何在 pdf 中添加分頁符?
為父表添加page-break-inside: auto
如下所示
<table style="page-break-inside: auto">
<tr>
<td>
<table width="100%" border="0" style="border:solid 1px #BFBFBF;" cellspacing="0" cellpadding="10">
<tr bgcolor="#BFBFBF">
-------
</table>
$mpdf = new \Mpdf\Mpdf();
$html = $this->load->view('client_tid_pdf', $data,true);
$mpdf->autoPageBreak = true;
$mpdf->setAutoTopMargin='stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.