Merge PDF files using PHP

High-speed, powerful, and secure API for merging PDF documents in PHP


PDF merge API allows you to combine and merge multiple PDF files. Using PDF Merge API, you can retain the numbering of the pages, remove duplicate fonts to increase performance, and even create a table of contents for the merged documents.

Merge PDF documents programmatically

ConvertAPI provides a PDF Merge tool available as a REST API service. We crafted a PHP wrapper library for simple and convenient integration into your project. It is accessible via composer, and the source code can be found on GitHub. Simply sign up for a free account, grab your API secret key, install our PHP library, and you are good to go!

Install the ConvertAPI library into the PHP project

If you are using Composer, execute the following command in your project root to install this library:

composer require convertapi/convertapi-php

If you do not wish to use the Composer, you must require ConvertApi autoloader:


Please note that if installing manually without Composer, the library requires the following dependencies in order to work properly:

Merge PDF files using PHP

Once you have the library installed, you can use this code example showing how to join multiple PDF files using PHP programming language:

require __DIR__ . '/../lib/ConvertApi/autoload.php';

use \ConvertApi\ConvertApi;

# Code snippet is using the ConvertAPI PHP Client:
# Read more about PDF Merge API:

$result = ConvertApi::convert('merge', [
        'Files' => [
    ], 'pdf'

That's all it takes to implement a PDF merge functionality into the PHP project. You can combine local PDF files together with the files hosted on a server accessible via the URL, or the files uploaded to our server accessible by FileId.

Advanced techniques

You can find a complete list of conversion parameters on our interactive demo tool page. More advanced techniques and examples can be found in our GitHub examples folder. Happy coding!