prg/portabledocument-bundle

此插件可选项地生成带有CSS样式的PDF文件。

安装: 49

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

v1.0 2014-07-23 15:06 UTC

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
            ))
        );