【发布时间】:2016-05-01 13:49:32
【问题描述】:
我的 pdf 文件太多,我无法更改 pdf 版本或购买 FPDI 插件。 有没有办法免费将 pdf 文件合并在一起? 我用这个:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
class ConcatPdf extends FPDI
{
public $files = array();
public function setFiles($files)
{
$this->files = $files;
}
public function concat()
{
foreach($this->files AS $file) {
$pageCount = $this->setSourceFile($file);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$tplIdx = $this->ImportPage($pageNo);
$s = $this->getTemplatesize($tplIdx);
$this->AddPage($s['w'] > $s['h'] ? 'L' : 'P', array($s['w'], $s['h']));
$this->useTemplate($tplIdx);
}
}
}
}
$pdf = new ConcatPdf();
$pdf->setFiles(array("Boombastic-Box.pdf", "Fantastic-Speaker.pdf", "Noisy-Tube.pdf"));
$pdf->concat();
$pdf->Output('concat.pdf', 'I');
感谢您的帮助。
【问题讨论】: