PHP code example of cideale / libmergepdf

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

    

cideale / libmergepdf example snippets


use Cideale\Libmergepdf\Merger;
use Cideale\Libmergepdf\Pages;

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

use Cideale\Libmergepdf\Merger;

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

use Cideale\Libmergepdf\Merger;
use Cideale\Libmergepdf\Driver\TcpdiDriver;

$merger = new Merger(new TcpdiDriver);

use Cideale\Libmergepdf\Driver\Fpdi2Driver;
use Cideale\Libmergepdf\Source\FileSource;
use Cideale\Libmergepdf\Pages;

$merger = new Fpdi2Driver;

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