nmalo/dompdf-bundle

用于在 Symfony 2 中使用 DomPDF 的包装器(由 SlikNL/DompdfBundle 分支而来)

维护者

详细信息

github.com/nmalo/DompdfBundle

源代码

安装次数: 6,200

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 0

分支: 24

类型:symfony-bundle

1.0.1 2015-08-27 16:32 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:43:57 UTC


README

此包为在 Symfony2 中使用 DomPDF 提供了包装器。

安装

当使用 composer 时,将以下内容添加到您的 composer.json 中

// composer.json
{
    //...

    "require": {
        //...
        "slik/dompdf-bundle" : "dev-master"
    }

    //...
}

然后运行 php composer.phar update slik/dompdf-bundle

接下来将以下内容添加到您的 appkernel 中

    // in AppKernel::registerBundles()
    $bundles = array(
        // Dependencies
        new Slik\DompdfBundle\SlikDompdfBundle();
    );

自定义配置

将 dompdf_config..inc.php.dist 文件复制到 /app 目录下的 dompdf_config..inc.php 中,并按照 dompdf 使用文档进行操作。

使用方法

每当您需要将某物转换为 PDF 时,只需在控制器中的任何位置使用此即可

    // Set some html and get the service
    $html = '<h1>Sample html</h1>';
    $dompdf = $this->get('slik_dompdf');

    // Generate the pdf
    $dompdf->getpdf($html);

    // Either stream the pdf to the browser
    $dompdf->stream("myfile.pdf");

    // Or get the output to handle it yourself
    $pdfoutput = $dompdf->output();