PHP code example of orbis / libmergepdf

1. Go to this page and download the library: Download orbis/libmergepdf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

orbis / libmergepdf example snippets


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();

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

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

$finder = new Finder;
$finder->files()->in(__DIR__)->name('*.pdf')->sortByName();

$merger = new Merger;
$merger->addFinder($finder);

$createdPdf = $merger->merge();