$files, 'useLegacy' => !$useLegacy]) . '">';
if ($useLegacy) {
echo 'NORMAL MODE';
} else {
echo 'LEGACY MODE';
}
echo '
';
if ($useLegacy && !file_exists($fpdiLegacy)) {
echo 'FPDI is not installed in ' . $fpdiLegacy . '
';
die();
}
if ($useLegacy) {
require_once $fpdiLegacy;
}
$start = microtime(true);
if ($useLegacy) {
$pdf = new \FPDI('P', 'pt', 'A3');
} else {
$pdf = new setasign\Fpdi\Fpdi('P', 'pt', 'A3');
}
foreach ($files as $file) {
$pageCount = $pdf->setSourceFile($file);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$pdf->AddPage();
$pageId = $pdf->importPage($pageNo, 'ArtBox');
if ($useLegacy) {
$pdf->useTemplate($pageId, null, null, 0, 0, true);
} else {
$pdf->useTemplate($pageId, 0, 0, null, null, true);
}
}
}
$pdf->Output('F', 'concatenate.pdf');
echo microtime(true) - $start;
echo "
";
var_dump(memory_get_peak_usage());
echo "
";
unset($pdf);
gc_collect_cycles();
var_dump(memory_get_usage());
echo "
";
echo filesize('concatenate.pdf');
echo "
";
?>