PHP code example of oriceon / laravel-pdf-merger

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

    

oriceon / laravel-pdf-merger example snippets


$app->register(Oriceon\PdfMerger\PdfMergerServiceProvider::class);
class_alias(Oriceon\PdfMerger\Facades\TCPDF::class, 'PDF');

use Oriceon\PdfMerger\Facades\PdfMerger;

PdfMerger::addPDF('path/to/pdf1.pdf', 1)
->addPDF('path/to/pdf2.pdf', 'all')
->merge()
->save('new_file_name.pdf', 'browser');

use Oriceon\PdfMerger\Facades\PdfMerger;

PdfMerger::addPDF([
    [
        'filePath' => 'path/to/pdf1.pdf',
        'pages'    => 1,
    ],
    [
        'filePath' => 'path/to/pdf2.pdf',
    ],
])
->merge()
->save('new_file_name.pdf', 'browser');