【问题标题】:TCPDF manual page breakTCPDF 手册分页符
【发布时间】: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>';

【问题讨论】:

    标签: php tcpdf


    【解决方案1】:

    我记得这是表格的真正问题。所以我们计算是否要设置分页符。如果是这样,我们关闭表格,添加一个新站点并重新打开表格并将表格的其余部分放入其中。

    为了强制分页,我们使用了&lt;br pagebreak="true"/&gt;

    如果不关闭表格会导致其他问题。

    一个很好的威胁也在这里:Manual Page Break in TCPDF

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多