svikramjeet / laravel-pdf
为laravel 5提供HTML2PDF功能,使用wkhtmltopdf库
1.0.2
2013-12-14 01:13 UTC
Requires
- php: >=5.3.0
- illuminate/support: ~4
- mikehaertl/phpwkhtmltopdf: 1.1.x
This package is auto-updated.
Last update: 2024-09-09 10:57:08 UTC
README
一个简单的Laravel 4服务提供者,用于包含wkhtmltopdf库。
安装
可以通过在项目的composer.json中要求ignited/laravel-pdf包来通过Composer安装Laravel PDF服务提供者。
{
"require": {
"ignited/laravel-pdf": "1.*"
}
}
注意(你还需要包含wkhtmltopdf二进制文件)
32位系统
{
"require": {
"h4cc/wkhtmltopdf-i386": "*"
}
}
64位系统
{
"require": {
"h4cc/wkhtmltopdf-amd64": "*"
}
}
如果需要,你可以包含这两个系统。
配置
要使用PDF服务提供者,你必须在启动Laravel应用程序时注册提供者。
使用Artisan发布包配置。
php artisan config:publish ignited/laravel-pdf
在生成的app/config/packages/ignited/laravel-pdf配置文件中更新你的设置。
取消注释相关的二进制文件。
32位系统
return array( # Uncomment for 32-bit systems 'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386'
64位系统
return array( # Uncomment for 64-bit systems 'bin' => base_path() . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'
在app/config/app.php中找到providers键并注册AWS服务提供者。
'providers' => array( // ... 'Ignited\Pdf\PdfServiceProvider', )
在app/config/app.php中找到aliases键并添加AWS外观别名。
'aliases' => array( // ... 'PDF' => 'Ignited\Pdf\Facades\Pdf' )
用法
在routes.php
Route::get('/', function() { $pdf = PDF::make(); $pdf->addPage('<html><head></head><body><b>Hello World</b></body></html>'); $pdf->send(); });