FPDF:将2个PDF文件合并为1个PDF文件,共1页


FPDF: Mergin 2 PDF files into 1 PDF with 1 page

我正试图用一个页面将2个PDF合并为1个PDF。每个PDF都有1页。

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

我希望有人能帮忙。

提前谢谢。

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

<?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();