slik/dompdf-bundle
用于在Symfony 2中使用DomPDF的包装器
dev-master
2015-10-30 15:48 UTC
Requires
- php: >=5.3
- symfony/framework-bundle: 2.*
- symfony/symfony: 2.*
This package is not auto-updated.
Last update: 2024-09-14 13:53:58 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();