PHP code example of akemys / laravel-pdf-merger

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

    

akemys / laravel-pdf-merger example snippets


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

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

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

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

$merger->merge();
$merger->inline();

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