bideogemu/mpdf-bundle
最新稳定版本:2.7
Composer 安装命令:
composer require bideogemu/mpdf-bundle
包简介
Mpdf for Symfony 7
关键字:
README 文档
README
Pdf generator for Symfony. From Sasedev - mPDF Bundle
What is it?
This is a Symfony Pdf Factory for use inside a controller to generate a PDF file from twig rendering using MPDF lib.
Installation
Step 1: Download the bundle using composer
$ composer require bideogemu/mpdf-bundle
Composer will install the bundle to your project's vendor directory.
Step 2: Enable the bundle
Enable the bundle in the config if flex it didn't do it for you:
<?php // config/bundles.php return [ // ... BideoGemu\MpdfBundle\BideoGemuMpdfBundle::class => ['all' => true], // ... ];
Usage
You can use the factory in your controllers just like this:
<?php use BideoGemu\MpdfBundle\Factory\MpdfFactory; // ... public function pdf($id, Request $request, MpdfFactory $MpdfFactory) { // ... $mPdf = $MpdfFactory->createMpdfObject([ 'mode' => 'utf-8', 'format' => 'A4', 'margin_header' => 5, 'margin_footer' => 5, 'orientation' => 'P' ]); $mPdf->SetTopMargin("50"); $mPdf->SetHTMLHeader($this->renderView('twigfolder/pdf/pdf_header.html.twig', $TwigVars)); $mPdf->SetFooter($this->renderView('twigfolder/pdf/pdf_footer.html.twig', $TwigVars)); $mPdf->WriteHTML($this->renderView('twigfolder/pdf/pdf_content.html.twig', $TwigVars)); return $MpdfFactory->createDownloadResponse($mPdf, "file.pdf"); } // ...
Reporting an issue or a feature request
Please feel free to open issues or submit pull requests to improve the bundle.
统计信息
- 总下载量: 2.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-14