railken/dompdf-bundle

此包提供了在symfony中使用dompdf的包装器。

安装: 115

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 12

类型:symfony-bundle

1.0.3 2017-04-24 09:40 UTC

This package is auto-updated.

Last update: 2024-09-05 18:19:01 UTC


README

Latest Stable Version Latest Unstable Version License

Build Status Scrutinizer Code Quality Code Climate Coverage Status SensioLabsInsight

Donate to this project using Flattr Donate to this project using PayPal

此包提供了在symfony中使用dompdf的包装器。

安装

php composer.phar require core23/dompdf-bundle

启用此包

    // app/AppKernel.php

    public function registerBundles()
    {
        return array(
            // ...

            new Core23\DompdfBundle\Core23DompdfBundle(),

            // ...
        );
    }

用法

当您需要将HTML页面转换为PDF时,只需在控制器中的任何位置使用此功能即可

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

// Stream the pdf to the browser
$dompdf->streamHtml($html, "document.pdf");

// Get binary content of the pdf document
$dompdf->getPdf($html);

配置

您可以在config键下配置每个dompdf选项。

core23_dompdf:
    defaults:
        dpi: 150
        defaultPaperSize: A4
        ...

此包在MIT许可证下可用。