PHP code example of votong / laravel-pdf-merger

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

    

votong / laravel-pdf-merger example snippets


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

'aliases' => [
   ...
   'PDFMerger' => VoTong\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/votong/laravel-pdf-merger/examples/one.pdf'), [2], 'P');
$merger->addPDFString(file_get_contents(base_path('/vendor/votong/laravel-pdf-merger/examples/two.pdf')), 'all', 'L');
$merger->merge();
$merger->save(base_path('/public/pdfs/merged.pdf'));