oriceon / laravel-pdf-merger
Laravel Pdf Merger
Installs: 14 296
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.3.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
- setasign/fpdi: ^2.3.6
- tecnickcom/tcpdf: ^6.4.4
README
A simple Laravel service provider with some basic configuration for including the TCPDF library to allow you to merge PDF's in your Laravel application.
Installation
The Laravel PDF Merger service provider can be installed via composer by requiring the oriceon/laravel-pdf-merger
package in your project's composer.json
.
composer require oriceon/laravel-pdf-merger
for lumen, you should add the following lines:
$app->register(Oriceon\PdfMerger\PdfMergerServiceProvider::class); class_alias(Oriceon\PdfMerger\Facades\TCPDF::class, 'PDF');
That's it! You're good to go.
Here is a little example:
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');
or sending pdf's as array ...
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');
You can extend functionality for this class and for a list of all available function take a look at the TCPDF Documentation
Configuration
Laravel Pdf Merger comes with some basic configuration. If you want to override the defaults, you can publish the config, like so:
php artisan vendor:publish --provider="Oriceon\PdfMerger\PdfMergerServiceProvider"
Now access config/pdf-merger.php
to customize.
- use_original_header is to used the original
Header()
from TCPDF.- Please note that
PdfMerger::setHeaderCallback(function($pdf){})
overrides this settings.
- Please note that
- use_original_footer is to used the original
Footer()
from TCPDF.- Please note that
PdfMerger::setFooterCallback(function($pdf){})
overrides this settings.
- Please note that