PHP library for merging multiple PDFs.
composer require iio/libmergepdf
Append the first ten pages of bar.pdf to foo.pdf:
use iio\libmergepdf\Merger;
use iio\libmergepdf\Pages;
$merger = new Merger;
$merger->addFile('foo.pdf');
$merger->addFile('bar.pdf', new Pages('1-10'));
$createdPdf = $merger->merge();
Bulk add files from an iterator:
use iio\libmergepdf\Merger;
$merger = new Merger;
$merger->addIterator(['A.pdf', 'B.pdf']);
$createdPdf = $merger->merge();
The default FPDI
driver is not able handle compressed pdfs of version 1.5 or later.
Circumvent this limitation by using the slightly more experimental TCPDI
driver.
use iio\libmergepdf\Merger;
use iio\libmergepdf\Driver\TcpdiDriver;
$merger = new Merger(new TcpdiDriver);
Immutability may be achieved by using a driver
directly.
use iio\libmergepdf\Driver\Fpdi2Driver;
use iio\libmergepdf\Source\FileSource;
use iio\libmergepdf\Pages;
$merger = new Fpdi2Driver;
$createdPdf = $merger->merge(
new FileSource('foo.pdf'),
new FileSource('bar.pdf', new Pages('1-10'))
);