lennon-mudenda / wkhtml2pdf
Html 2 Pdf - 使用 wkhtml2pdf,支持 32 位和 64 位 Linux + MacOS
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-10 11:22:42 UTC
README
版本 1.0 - Html to PDF Composer 包
#使用方法#
return PDF::html('hello'); // hello is naw of blade template
return PDF::html('hello',array('name' => 'Nithin')); // pass variables for the view as second option
return PDF::html('hello',array('name' => 'Nithin'), 'New File'); // thrid option is for the name of the pdf file thats generated
PDF::url('http://google.com'); // Pdf from url
// What to download to a file instead ?
PDF::setOutputMode('F'); // force to file
PDF::html('app.invoices.pdf',['title'=>$title],'/var/www/test.pdf'); // custom download path
Laravel 快速开始
所需设置
在 composer.json
文件的 require
键中添加以下内容
"nitmedia/wkhtml2pdf": "dev-master"
运行 Composer 更新命令
$ composer update nitmedia/wkhtml2pdf
L5
在您的 config/app.php
文件中,将 'Nitmedia\Wkhtml2pdf\L5Wkhtml2pdfServiceProvider'
添加到 $providers
数组的末尾
'providers' => array(
...
Nitmedia\Wkhtml2pdf\L5Wkhtml2pdfServiceProvider::class,
),
L4
在您的 config/app.php
文件中,将 'Nitmedia\Wkhtml2pdf\Wkhtml2pdfServiceProvider'
添加到 $providers
数组的末尾
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'Nitmedia\Wkhtml2pdf\Wkhtml2pdfServiceProvider',
),
在 config/app.php
文件的末尾添加 'PDF' => 'Nitmedia\Wkhtml2pdf\Facades\Wkhtml2pdf'
到 $aliases
数组
'aliases' => array(
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
...
'PDF' => Nitmedia\Wkhtml2pdf\Facades\Wkhtml2pdf::class,
),
配置
请根据当前操作系统设置驱动文件,支持的驱动包括:mac osx、linux 32、linux 64
php artisan vendor:publish
驱动
版本: 0.12.1-rc
驱动类型
- wkhtmltopdf-0.12.1-OS-X.i386 -
Mac OS X 10.8+ (Carbon), 32-bit
- wkhtmltopdf-amd64 -
Linux (Debian Wheezy), 64-bit, for recent distributions (i.e. glibc 2.13 or later)
- wkhtmltopdf-i386 -
Linux (Debian Wheezy), 32-bit, for recent distributions (i.e. glibc 2.13 or later)
故障排除
**There is a debug flag in config where you can test the output of the drivers.**
1. Some users have noted a strange permissions issue executing the drivers. Try chmod'ing the driver files to solve the issue.
2. All asset urls must be absolute, relative urls wont work.
3. ***Ubuntu users*** you need to do => apt-get install libxrender1 libxext6
MIT 许可证 (MIT)
版权所有 <2013>
特此授予任何获得本软件及其相关文档副本(“软件”)的个人免费使用权,不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许软件的接受者进行上述操作,前提是符合以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
本软件按“原样”提供,不受任何保证,无论是明示的、暗示的,还是与特定用途和侵权无关的。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他原因,是否与软件有关、使用或其他方式使用软件。