39 lines
948 B
PHP
39 lines
948 B
PHP
<?php
|
|
if (false === class_exists('FPDF')) {
|
|
require_once('fpdf/fpdf.php');
|
|
}
|
|
|
|
if (false === class_exists('FPDI')) {
|
|
require_once('fpdi/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("samplepdfs/three.pdf", "samplepdfs/three.pdf", "samplepdfs/three.pdf"));
|
|
$pdf->concat();
|
|
|
|
$pdf->Output('concat.pdf', 'I');
|
|
*/ |