【问题标题】:FPDF: Mergin 2 PDF files into 1 PDF with 1 pageFPDF:将 2 个 PDF 文件合并为 1 个 1 页的 PDF
【发布时间】:2015-02-26 13:55:06
【问题描述】:

我正在尝试将 2 个 PDF 合并为 1 个只有一页的 PDF。每个 PDF 有 1 页。

感谢这篇文章 http://www.setasign.com/products/fpdi/about/ 我能够将第一个 PDF 作为模板。现在唯一的问题是我如何导入另一个并将其设置为内容,而不会获得具有多个页面的 PDF。

希望有人能帮忙。

提前致谢。

【问题讨论】:

    标签: php pdf fpdf fpdi


    【解决方案1】:

    在您为此行为编写代码之前,导入的页面并不意味着它会在您的文档中生成一个新页面。以链接页面为例,您可以通过这种方式导入另一个文档页面:

    <?php
    require_once('fpdf.php');
    require_once('fpdi.php');
    
    $pdf = new FPDI();
    
    $pdf->setSourceFile("Fantastic-Speaker.pdf");
    $tplIdxA = $pdf->importPage(1, '/MediaBox');
    
    $pdf->setSourceFile("Another-Fantastic-Speaker.pdf");
    $tplIdxB = $pdf->importPage(1, '/MediaBox');
    
    $pdf->addPage();
    // place the imported page of the first document:
    $pdf->useTemplate($tplIdxA, 10, 10, 90);
    // place the imported page of the snd document:
    $pdf->useTemplate($tplIdxB, 100, 10, 90);
    
    $pdf->Output();
    

    【讨论】:

    • 效果很好。我唯一改变的是 $pdf->useTemplate($tplIdxA, 10, 10, 200); $pdf->useTemplate($tplIdxB, 10, 10, 200);
    猜你喜欢
    • 2013-01-22
    • 1970-01-01
    • 2022-06-29
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多