donnykurnia / l5mpdf
mPDF wrapper for Laravel 5
Installs: 68
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 10
pkg:composer/donnykurnia/l5mpdf
Requires
- php: >=5.4.0
- illuminate/support: 5.x
- mpdf/mpdf: ^6.1.3
This package is auto-updated.
Last update: 2025-10-26 03:40:11 UTC
README
In development.
License
Instalation
Add:
"donnykurnia/l5mpdf": "dev-master@dev",
To your composer.json
or Run:
composer require donnykurnia/l5mpdf
Then add:
'Servit\Mpdf\ServiceProvider',
To the providers array on your config/app.php
And
'PDF' => 'Servit\Mpdf\Facades\Pdf',
To the aliases array on yout config/app.php in order to enable the PDF facade
Usage
$router->get('/pdf/view', function() { $pdf = \App::make('mpdf.wrapper', [ 'mode' => 'id+aCJK', 'format' => 'A4-L', ]); $pdf->WriteHTML('<h1>Page 1</h1>'); $pdf->AddPage('P'); $pdf->WriteHTML('<h1>Page 2</h1>'); $pdf->stream(); });
Force download
$router->get('/pdf/download', function() { $html = view('pdfs.example')->render(); return PDF::load($html)->download(); });
Output to a file
$router->get('/pdf/output', function() { $html = view('pdfs.example')->render(); PDF::load($html) ->filename('/tmp/example1.pdf') ->output(); return 'PDF saved'; });
This mPDF Wrapper for Laravel5 is open-sourced software licensed under the MIT license
Default config
These default config can be overridden when creating the mpdf.wrapper.
[
'mode' => '',
'format' => 'A4',
'defaultFontSize' => '',
'defaultFont' => '',
'marginLeft' => 10,
'marginRight' => 10,
'marginTop' => 10,
'marginBottom' => 10,
'marginHeader' => 10,
'marginFooter' => 5,
'orientation' => 'P',
]