tiitoo / tcpdfbundle
为 Symfony 提供 TCPDF 集成
dev-master
2022-10-04 02:38 UTC
Requires
- php: >=5.3.0
- symfony/framework-bundle: 2.7.*
- tecnick.com/tcpdf: >=6.0.041
This package is auto-updated.
Last update: 2024-08-30 01:32:03 UTC
README
安装
使用 composer
将以下行添加到您的 composer.json
文件中
Symfony 2.3.*
"require": {
...
"gonzakpo/tcpdfbundle": "dev-master"
}
执行
php composer.phar update "gonzakpo/tcpdfbundle"
将其添加到 AppKernel.php
类中
// ...
new Io\TcpdfBundle\IoTcpdfBundle(),
不使用 composer
-
从 http://sourceforge.net/projects/tcpdf/files/ 下载 TCPDF 库并将其放入 vendor 文件夹
-
将此包添加到您的 vendor/ 目录 * 供应商模式 在 deps 文件中添加以下行:
[IoTcpdfBundle] git=git://github.com/ioalessio/IoTcpdfBundle.git target=/bundles/Io/TcpdfBundle
运行供应商脚本
./bin/vendors install
-
将 "Io" 命名空间添加到您的自动加载器
// app/autoload.php $loader->registerNamespaces(array( 'Io' => DIR.'/../vendor/bundles', // your other namespaces ));
// 在同一文件中包含 tcpdf 库 require_once DIR.'/../vendor/tcpdf/tcpdf.php';
-
将 "Io" 命名空间添加到您的内核
// app/ApplicationKernel.php public function registerBundles() { return array( // ... new Io\TcpdfBundle\IoTcpdfBundle(), // ... ); }
如何使用
//in mybundle/controllers/myController.php
class MyController extends Controller
{
/**
* @Route("/mypage.pdf")
*/
public function mypageAction()
{
$html = $this->renderView('MyBundle:MyController:mypage.pdf.twig', array());
//io_tcpdf will returns Response object
return $this->get('io_tcpdf')->quick_pdf($html);
}
}
//in mybundle/Resources/views/myController.pdf.twig
put here your html code
待办事项
- 智能方法,易于 PDF 生成和定制
- 缓存 PDF 生成
- @PDF('template.twig') 注解系统