Library for merging multiple PDFs

Installs: 45 718

Dependents: 1

Stars: 32

Watchers: 5

Forks: 11

Open Issues: 2

2.4.0 2014-11-17 18:03 UTC


Packagist Version Build Status Quality Score Dependency Status

PHP library for merging multiple PDFs using fpdi/FPDI


Install using composer. Exists as iio/libmergepdf in the packagist repository.

composer require iio/libmergepdf


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

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

$m = new Merger();
$m->addFromFile('bar.pdf', new Pages('1-10'));
file_put_contents('foobar.pdf', $m->merge());

Bulk add files from an iterator:

use iio\libmergepdf\Merger;
$m = new Merger();
$m->addIterator(array('A.pdf', 'B.pdf'));
file_put_contents('AB.pdf', $m->merge());

Bulk add files using symfony finder:

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

$finder = new Finder();

$m = new Merger();

file_put_contents('finder.pdf', $m->merge());


Unit tests requires dependencies to be installed using composer:

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
$ phpunit


  • 2.4.0 Added setTempDir() to Merger.
  • 2.3.1 Added addFinder() to Merger.
  • 2.3.0 Injecting FPDI is now optional. Added addIterator() to Merger.
  • 2.2.0 Pages now support addPage() and addRange().
  • 2.1.1 Now allows merging of Landscape and Portrait pages (thanks to @willoller).
  • 2.0 As of version 2.0 FPDI must be injected when creating a new libmergepdf instance.


libmergepdf is covered under the WTFPL.

@author Hannes Forsgård (hannes.forsgard@fripost.org)