通过使用TCPDF合并PDF文档来创建新PDF

LuR*_*RsT 11 php pdf tcpdf

如何使用我正在生成的其他PDF创建新文档?

我有创建一些文档的方法,我想将它们全部合并到一个大的PDF中,我怎么能用TCPDF呢?

我不想使用其他库.

Syg*_*ral 8

TCPDF有一个tcpdf_import类,在2011年添加,但它仍处于"开发中".如果你不想使用TCPDF以外的任何东西,那你就不走运了!

但是FPDI是TCPDF的一个很好的补充:它就像一个插件.这很简单:

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)); 
Run Code Online (Sandbox Code Playgroud)

完成!

另请参阅此问题: 具有多个页面的TCPDF和FPDI

  • FPDI 本身仅支持 pdf 到 1.4 版。如果您的 pdf 高于 1.4,则必须购买解析器许可证 (2认同)

opH*_*AME 3

您好,我认为 TCPDF 无法合并 pdf 文件。

您可以使用 shell 命令尝试一下

PDFTK工具包

所以你不必使用其他 pdf 库。