在 PHP 中合并 PDF 文件

Aspose.PDF - 合并 PDF 文件

要使用 Aspose.PDF Java for PHP 合并 PDF 文件,只需调用 ConcatenatePdfFiles 类。

PHP 代码


# Open the target document
$pdf1 = new Document($dataDir . 'input1.pdf');

# Open the source document
$pdf2 = new Document($dataDir . 'input2.pdf');

# Add the pages of the source document to the target document
$pdf1->getPages()->add($pdf2->getPages());

# Save the concatenated output file (the target document)
$pdf1->save($dataDir . "Concatenate_output.pdf");

print "New document has been saved, please check the output file" . PHP_EOL;

下载运行代码

下载 Concatenate PDF Files (Aspose.PDF) 来自以下任意提及的社交编码网站: