在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):barryvdh/laravel-dompdf开源软件地址(OpenSource Url):https://github.com/barryvdh/laravel-dompdf开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):DOMPDF Wrapper for LaravelDompdf HTML to PDF ConverterLaravel wrapper forInstallationLaravelRequire this package in your composer.json and update composer. This will download the package and the dompdf + fontlib libraries also.
LumenAfter updating composer add the following lines to register provider in
To change the configuration, copy the config file to your config folder and enable it in
UsingYou can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download. use Barryvdh\DomPDF\Facade\Pdf;
$pdf = Pdf::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf'); or use the App container: $pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream(); Or use the facade: You can chain the methods: return Pdf::loadFile(public_path().'/myfile.html')->save('/path-to/my_stored_file.pdf')->stream('download.pdf'); You can change the orientation and paper size, and hide or show errors (by default, errors are shown when debug is on) Pdf::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('myfile.pdf') If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself. Use ConfigurationThe defaults configuration settings are set in php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider" You can still alter the dompdf options in your code before generating the pdf using this command: Pdf::setOption(['dpi' => 150, 'defaultFont' => 'sans-serif']); Available options and their defaults:
Tip: UTF-8 supportIn your templates, set the UTF-8 Metatag:
Tip: Page breaksYou can use the CSS
LicenseThis DOMPDF Wrapper for Laravel is open-sourced software licensed under the MIT license |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论