GitHub - Vsmoraes:pdf-Laravel5: DOMPDF Module For Laravel 5
GitHub - Vsmoraes:pdf-Laravel5: DOMPDF Module For Laravel 5
com/vsmoraes/pdf-laravel5
vsmoraes / pdf-laravel5
Dismiss
Join GitHub today
GitHub is home to over 31 million developers working together to host
and review code, manage projects, and build software together.
Sign up
vsmoraes Merge pull request #27 from rankovic/master … Latest commit 84805f1 on 21 Aug 2017
README.md add example for changing paper size and orientation to readme 2 years ago
README.md
pdf-laravel5
DOMPDF module for Laravel 5. Export your views as PDFs - with css support.
build passing stable 2.0 downloads 92.02 k unstable dev-master license MIT
Instalation
Add:
"vsmoraes/laravel-pdf": "^2.0"
To your composer.json
or Run:
Then add:
1 de 3 4/15/19, 3:02 p. m.
GitHub - vsmoraes/pdf-laravel5: DOMPDF module for Laravel 5 https://github.com/vsmoraes/pdf-laravel5
Vsmoraes\Pdf\PdfServiceProvider::class
And
To the aliases array on yout config/app.php in order to enable the PDF facade
Usage
Route::get('/pdf/view', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)->show();
});
Force download
Route::get('/pdf/download', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)->download();
});
Route::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)
->output();
});
Route::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
Output to a file
Route::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
PDF::load($html)
->filename('/tmp/example1.pdf')
->output();
2 de 3 4/15/19, 3:02 p. m.
GitHub - vsmoraes/pdf-laravel5: DOMPDF module for Laravel 5 https://github.com/vsmoraes/pdf-laravel5
use Vsmoraes\Pdf\Pdf;
return $this->pdf
->load($html)
->show();
}
}
Configuration
Dompdf allows you to configure a bunch of things on your PDF file. In previous versions we used to accomplish this
through environment vars, now you can change this configuration keys on the fly:
Route::get('/pdf/view', function() {
$html = view('pdfs.example')->render();
$defaultOptions = PDF::getOptions();
$defaultOptions->setDefaultFont('Courier');
return PDF::setOptions($defaultOptions)->load($html)->download();
});
3 de 3 4/15/19, 3:02 p. m.