Laravel 5 HTML 2 PDF
, (*1)
A simple Laravel 5 service provider for including the wkhtmltopdf library., (*2)
Installation
The Laravel PDF Service Provider can be installed via Composer by requiring the
lucasromanojf/laravel5-pdf package in your project's composer.json., (*3)
{
"require": {
"lucasromanojf/laravel5-pdf": "1.0.*"
}
}
Note (you must also include wkhtmltopdf binaries)
32-bit systems, (*4)
{
"require": {
"h4cc/wkhtmltopdf-i386": "*"
}
}
64-bit systems, (*5)
{
"require": {
"h4cc/wkhtmltopdf-amd64": "*"
}
}
You can include both of these if you need., (*6)
Configuration
To use the PDF Service Provider, you must register the provider when bootstrapping your Laravel application., (*7)
Create the config/laravel-pdf.php configuration file., (*8)
In the config/laravel-pdf.php file:, (*9)
32-bit systems, (*10)
return array(
'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386'
)
64-bit systems, (*11)
return array(
'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'
)
Find the providers key in your config/app.php and register the Service Provider., (*12)
'providers' => array(
// ...
'Ignited\Pdf\PdfServiceProvider',
)
Find the aliases key in your app/config/app.php and add the AWS facade alias., (*13)
'aliases' => array(
// ...
'PDF' => 'Ignited\Pdf\Facades\Pdf'
)
Usage
In routes.php, (*14)
Route::get('/', function() {
$pdf = PDF::make();
$pdf->addPage('<html><head></head><body><b>Hello World</b></body></html>');
$pdf->send();
});