nmalo / dompdf-bundle
用于在 Symfony 2 中使用 DomPDF 的包装器(由 SlikNL/DompdfBundle 分支而来)
1.0.1
2015-08-27 16:32 UTC
Requires
- php: >=5.3
- symfony/framework-bundle: 2.*
- symfony/symfony: 2.*
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();