mpdf从另一个pdf文档导入所有页面 [英] mpdf import all pages from another pdf document

查看:889
本文介绍了mpdf从另一个pdf文档导入所有页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我使用mpdf创建的文档中附加整个pdf文档。

I want to be able to append an entire pdf document in the document I am creating with mpdf.

我可以使用以下代码导入一个页面:

I can import one page using the following code:

$mpdf->SetImportUse(); 

$pagecount = $mpdf->SetSourceFile('testfile.pdf');

$tplId = $mpdf->ImportPage($pagecount, 50, 50, 100, 100);

$mpdf->UseTemplate($tplId, '', '', 100, 100);

$mpdf->Output();

但有没有办法导入所有页面而不仅仅是最后一页?

but is there a way to import all pages rather than just the last page?

推荐答案

使用页面计数在循环中获取表单设置源文件(如下所示)

Use page count you get form setting source file in a loop (like below)

$pdf = new mPDF();
$pdf->SetImportUse();
$pagecount = $pdf->SetSourceFile($dashboard_pdf_file);
    for ($i=1; $i<=$pagecount; $i++) {
        $import_page = $pdf->ImportPage();
        $pdf->UseTemplate($import_page);

        if ($i < $pagecount)
            $pdf->AddPage();
    }
$pdf->Output();

这篇关于mpdf从另一个pdf文档导入所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆