dekamped / kohana-wkhtml2pdf
wkhtml2pdf 的 Kohana 包装器
dev-master
2015-07-16 02:17 UTC
Requires
- php: >=5.3.3
- composer/installers: ~1.0
- kohana/core: >=3.3
This package is not auto-updated.
Last update: 2024-09-28 18:15:58 UTC
README
安装
- 使用 Composer 安装:
composer require dexamped/kohana-wkhtml2pdf - 下载并制作 wkhtml2pdf 二进制文件 - http://wkhtmltopdf.org/downloads.html
- 将二进制文件复制到 MODPATH/kohana-wkhtml2pdf/vendor/bin 目录
- 在 bootstrap 中加载模块
Kohana::modules(array( // ... 'wkhtml2pdf' => MODPATH.'kohana-wkhtml2pdf', // PDF Generator // ... ));
使用方法
/** * Generate and return PDF inline */ public function action_index() { // HTML view to convert to PDF $view = View::factory('pdf/document'); // Generate, return and delete file $this->response->send_file(WKHTML2PDF::pdf($view->render()), 'document.pdf', array('delete' => TRUE)); }