PHP code example of kadudutra / libmergepdf

1. Go to this page and download the library: Download kadudutra/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/ */

    

kadudutra / libmergepdf example snippets


use kadudutra\libmergepdf\Merger;
use kadudutra\libmergepdf\Pages;

$merger = new Merger;
$merger->addFile('foo.pdf');
$merger->addFile('bar.pdf', new Pages('1-10'));
$createdPdf = $merger->merge();

use kadudutra\libmergepdf\Merger;

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

use kadudutra\libmergepdf\Merger;
use kadudutra\libmergepdf\Driver\TcpdiDriver;

$merger = new Merger(new TcpdiDriver);

use kadudutra\libmergepdf\Driver\Fpdi2Driver;
use kadudutra\libmergepdf\Source\FileSource;
use kadudutra\libmergepdf\Pages;

$merger = new Fpdi2Driver;

$createdPdf = $merger->merge(
    new FileSource('foo.pdf'),
    new FileSource('bar.pdf', new Pages('1-10'))
);