问题描述
如何使用正在生成的其他PDF创建新文档?
How can I create a new document using other PDFs that I'm generating?
我有创建一些文档的方法,并且我想将它们全部合并成一个大PDF,如何使用TCPDF做到这一点?
I have methods to create some documents, and I want to merge them all in a big PDF, how can I do that with TCPDF?
我不想使用其他库.
推荐答案
TCPDF具有 tcpdf_import
类,在2011年添加,但仍在开发中".如果您不想在TCPDF之外使用任何东西,那将很不幸!
TCPDF has a tcpdf_import
class, added in 2011, but it is still "under development". If you don't want to use anything outside of TCPDF, you're out of luck!
但是 FPDI 是很好的添加到TCPDF:就像一个插件.就这么简单:
But FPDI is an excellent addition to TCPDF: it's like an addon. It's as simple as this:
require_once('tcpdf/tcpdf.php');
require_once('fpdi/fpdi.php'); // the addon
// FPDI extends the TCPDF class, so you keep all TCPDF functionality
$pdf = new FPDI();
$pdf->setSourceFile("document.pdf"); // must be pdf version 1.4 or below
// FPDI's importPage returns an object that you can insert with TCPDF's useTemplate
$pdf->useTemplate($pdf->importPage(1));
完成!
另请参阅以下问题: TCPDF和FPDI多页
See also this question: TCPDF and FPDI with multiple pages
这篇关于通过使用TCPDF合并PDF文档来创建新的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!