【发布时间】:2017-04-27 03:12:14
【问题描述】:
我正在打印发票。
我在打印发票时遇到问题。假设有一张发票包含正好在一页中的项目。问题是在所有项目之后都有小计、税收和总计。
在这种情况下,这 3 个将在第二页(新页面)上,而项目在第一页。
我已经检查了 tcpdf 中一页可以容纳的行(毕竟我的布局格式等),发现一页将包含 28 个项目。如果所有项目都由 1 行组成,这将很有效。但是,如果某些项目包含 2 行或更多行,则计算将面临问题,整个结构将变得一团糟。
如果项目总数为 28 项,我如何自动将一些项目移动到第二页,这样第二页将不仅包含小计、税收和总计?
这是我的代码
$count = 0;
$i = 0;
if(count($finalProduct)>0){
foreach($finalProduct as $product){
foreach($product['product'] as $prod){
if($prod['qty'] > 0){
/* check the row */
if($count >= 27){
$PDFCONTENT .= '<tr style="page-break-after:initial"><td colspan="6"></td></tr>';
$PDFCONTENT .= '<tr><td colspan="6"></td></tr>';
$count = 0;
}
$PDFCONTENT .= '
<tr nobr="true">';
$PDFCONTENT .= '<td align="center" width="7%">'.$prod['index_number'].'</td>';
</tr>';
}
$count++;
}
$PDFCONTENT .= '<tr><td></td></tr>';
}
}
$PDFCONTENT .= '<tfoot>
<tr> <td> </td> </tr>
<tr>
<th align="right" colspan="6">SUB TOTAL $:-</th>
<th style="border-top: 1px solid black;border-bottom: 1px solid black;" align="center">'.number_format($data['total'],2).'</th>
</tr>
<tr>
<th align="right" colspan="6">ADD '.number_format($data['transaction_tax_percentage']).'% $:-</th>
<th style="border-top: 1px solid black;border-bottom: 1px solid black;" align="center">'.number_format($data['transaction_tax_amount'],2).'</th>
</tr>
<tr>
<th align="right" colspan="6">TOTAL $:-</th>
<th style="border-top: 1px solid black;border-bottom: 1px solid black;" align="center">'.number_format($data['grand_total'],2).'</th>
</tr>
</tfoot>';
【问题讨论】: