railken / dompdf-bundle
此包提供了在symfony中使用dompdf的包装器。
1.0.3
2017-04-24 09:40 UTC
Requires
- php: ^7.0
- dompdf/dompdf: *@dev
- symfony/framework-bundle: ^2.8.6 || ^3.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-05 18:19:01 UTC
README
此包提供了在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许可证下可用。