Download the PHP package carlos-meneses/laravel-mpdf without Composer
On this page you can find all versions of the php package carlos-meneses/laravel-mpdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download carlos-meneses/laravel-mpdf
More information about carlos-meneses/laravel-mpdf
Files in carlos-meneses/laravel-mpdf
Package laravel-mpdf
Short Description Laravel Mpdf: Using Mpdf in Laravel to generate Pdfs.
License MIT
Rated 5.00 based on 1 reviews
Informations about the package laravel-mpdf
Laravel Mpdf: Generate PDF Files with ease.
Easily generate PDF files using Laravel's Blade templates and the MPDF library. This package has been tested since Laravel 5.4.
Installation
Run this composer command in your laravel application:
Important Notes:
-
Always check the official MPDF documentation
- mPDF will timeout on fetching external HTTP resources when using single-threaded servers such as
php -S
orartisan serve
. Use a proper webserver for full functionality.
To start using Laravel, add the Service Provider and the Facade to your config/app.php
:
Note: This package supports auto-discovery features of Laravel 5.5+, You only need to manually add the service provider and alias if working on Laravel version lower then 5.5.
Basic Usage
To use Laravel Mpdf add something like this to one of your controllers. You can pass data to a view in /resources/views
.
Config
You can use a custom file to overwrite the default configuration. Just execute php artisan vendor:publish --tag=mpdf-config
or create config/pdf.php
and add this:
To override this configuration on a per-file basis use the fourth parameter of the initializing call like this:
Get instance your Mpdf
You can access all mpdf methods through the mpdf instance with getMpdf
method.
Headers and Footers
If you want to have headers and footers that appear on every page, add them to your <body>
tag like this:
Now you just need to define them with the name attribute in your CSS:
Inside of headers and footers {PAGENO}
can be used to display the page number.
Included Fonts
By default you can use all the fonts shipped with Mpdf.
Custom Fonts
You can use your own fonts in the generated PDFs. The TTF files have to be located in one folder, e.g. resources/fonts/
. Add this to your configuration file (/config/pdf.php
):
Now you can use the font in CSS:
Chunk HTML
For big HTML you might get Uncaught Mpdf\MpdfException: The HTML code size is larger than pcre.backtrack_limit xxx
error, or you might just get empty or blank result. In these situations you can use chunk methods while you added a separator to your HTML:
Added Support for the Macroable Trait
You can configure the macro in the AppServiceProvider
provider file.
Now
License
Laravel Mpdf is open-sourced software licensed under the MIT license