首页 文章

TCP内容的TCPDF页数

提问于
浏览
0

我正在使用TCPDF从动态html内容生成PDF文档,该文档存储为$ html字符串 . 然后我使用以下代码制作PDF:

$pdf->writeHTML($html, true, false, true, false, '');

如果我在输出文件之前添加以下行

$totalPageCount = $pdf->getNumPages();

它可以为我提供该PDF文档中的总页数 . 但是,在此之前使用以下代码输出它:

$pdf->Output('info.pdf', 'I');

如果我的页码符合以下条件,有没有办法可以添加更多的html内容:

if (($totalPageCount>=1) && ($totalPageCount % 2 != 0)) {

1 回答

  • 1

    没有回复,但似乎$ pdf的实例允许您使用writeHTML添加更多内容 . 所以我做的是这样的:

    $pdf->writeHTML($html, true, false, true, false, '');
    $totalPageCount = $pdf->getNumPages();
    if (($totalPageCount>=1) && ($totalPageCount % 2 != 0)) {
        $pdf->writeHTML('<div><tcpdf method="AddPage" /></div>This page is intentionally blank.', true, false, true, false, '');
    }
    $pdf->Output('info.pdf', 'I');
    

相关问题