prg / portabledocument-bundle
此插件可选项地生成带有CSS样式的PDF文件。
v1.0
2014-07-23 15:06 UTC
Requires
- mpdf/mpdf: ~5.7
- symfony/framework-bundle: >=2.0.0
This package is not auto-updated.
Last update: 2024-09-24 03:23:23 UTC
README
PortableDocumentBundle是mPDF库的PHP(5.3+)封装。它允许您从HTML生成PDF文件。
安装
使用composer,添加
{ "require": { "prg/portabledocument-bundle": "dev-master" } }
然后在您的内核中启用它
// app/AppKernel.php public function registerBundles() { $bundles = array( //... new PRG\PortableDocumentBundle\PRGPortableDocumentBundle(), //...
从控制器响应中渲染PDF文档
$pdfGenerator = $this->get('pguso.mpdf'); $html = $this->renderView('YourBundle:Folder:file.html.twig', array( 'args' => $args )); return new Response( $pdfGenerator->generateFromView($html, array( 'stylesheet' => '/pdf/style.css' //optional )) );