Libmergepdf PHP Code for merge or concatenate multiple pdf files into single pdf

PHP composer library / SDK for merging or Concatenate multiples PDf(.pdf) files.


Install libmerge pdf sdk by Packagist composer.

Open your folder with CMD for installation of the composer package and run below command.


composer require iio/libmergepdf

Library for merging multiple PDFs


Add bulk .pdf files using PHP array.

require 'vendor/autoload.php'; 

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

$merger = new Merger;
$merger->addIterator(['pdf/A.pdf', 'pdf/B.pdf']);
$createdPdf = $merger->merge();

$myfile = fopen("newfile.pdf", "w") or die("Unable to open file!");
$txt = $createdPdf;
fwrite($myfile, $txt);


Check your new merge pdf file in the root directory.

if need to upload multiple files easily, can browser below blog help to achieve the best solution for uploading multiple pdf files.

Upload multiple files with Ajax and Move to upload by PHP with create different folder