PHP library for merging multiple PDFs
Clone or download


Packagist Version Build Status Quality Score

PHP library for merging multiple PDFs using FPDI


Install using composer.

composer require iio/libmergepdf:^3.1


Append the first ten pages of bar.pdf to foo.pdf:

use iio\libmergepdf\Merger;
use iio\libmergepdf\Pages;

$merger = new Merger;
$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();

Bulk add files using symfony finder:

use iio\libmergepdf\Merger;
use Symfony\Component\Finder\Finder;

$finder = new Finder;

$merger = new Merger;

$createdPdf = $merger->merge();

Known issues

  • Links and other content outside a page content stream is removed at merge. This is due to limitations in FPDI and not possible to resolve with the current strategy. For more information see FPDI.


Unit tests requires dependencies to be installed using composer:

composer install


libmergepdf is covered under the WTFPL.

@author Hannes Forsgård (