nitmedia/wkhtml2pdf

Html 2 Pdf - 使用wkhtml2pdf,在32位和64位Linux + MacOS上运行

2.1.0 2017-03-06 14:34 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:50:19 UTC


README

Latest Build Status

版本 1.0 - Html到PDF组合包

#使用说明#

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

驱动

wkhtml2pdf

版本: 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)

版权(c) <2013>

特此授予任何获得此软件及其相关文档副本(“软件”)的人免费使用该软件的权利,不受任何限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向软件提供的人这样做,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的任何副本或主要部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类索赔、损害或其他责任是基于合同、侵权或其他方式,源于、因之而产生或与软件或软件的使用或其他交易有关。