PHP code example of jorrenh / laravel-pdf-merger

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

    

jorrenh / laravel-pdf-merger example snippets


'providers' => [
   ...
   JorrenH\LaravelPDFMerger\Providers\PDFMergerServiceProvider::class
],

'aliases' => [
   ...
   'PDFMerger' => JorrenH\LaravelPDFMerger\Facades\PDFMergerFacade::class
]

$merger = PDFMerger::init();

$merger->addPDF('/path/to/pdf', 'all', 'P');
$merger->addString(file_get_contents('path/to/pdf'), ['1', '2'], 'L')

$merger->setFileName('merger.pdf');

$merger->merge();
$merger->inline(); /* output option */

$merger = \PDFMerger::init();
$merger->addPDF(base_path('/vendor/jorrenh/laravel-pdf-merger/examples/one.pdf'), [2], 'P');
$merger->addString(file_get_contents(base_path('/vendor/jorrenh/laravel-pdf-merger/examples/two.pdf')), 'all', 'L');
$merger->merge();
$merger->save(base_path('/public/pdfs/merged.pdf'));

// Default configuration
'temp' => storage_path('app/temp/'),
'compatibility' => [
    'enabled' => true,
    'binary' => env('GS_BINARY', '/usr/local/bin/gs'),
]
bash
$ php artisan vendor:publish --provider="JorrenH\LaravelPDFMerger\Providers\PDFMergerServiceProvider"