uga/twig2pdf-bundle
Composer 安装命令:
composer require uga/twig2pdf-bundle
包简介
twig2pdf
README 文档
README
Twig2pdf Bundle
Twig2pdf for Symfony 2/Drupal 8 as a service.
_______ _____ ____ _ _ ____ ____ _____ |_ _\ \ / /_ _/ ___| || | | _ \| _ \| ___| | | \ \ /\ / / | | | _| || |_| |_) | | | | |_ | | \ V V / | | |_| |__ _| __/| |_| | _| |_| \_/\_/ |___\____| |_| |_| |____/|_| ____ _ _ _ _ ____ _ _____ ______ __ | __ )| | | | \ | | _ \| | | ____| | __ ) \ / / | _ \| | | | \| | | | | | | _| | _ \\ V / | |_) | |_| | |\ | |_| | |___| |___ | |_) || | |____/ \___/|_| \_|____/|_____|_____| |____/ |_| ____ _ _ _ _ _____ _____ ____ ____ _______ __ | _ \| | / \ | \ | | ____|_ _/ __ \| _ \| ____\ \ / / | |_) | | / _ \ | \| | _| | |/ / _` | | | | _| \ \ / / | __/| |___ / ___ \| |\ | |___ | | | (_| | |_| | |___ \ V / |_| |_____/_/ \_\_| \_|_____| |_|\ \__,_|____/|_____| \_/ \____/
How to install ?
Just add this to your composer.json file:
"require": { "uga/twig2pdf-bundle": "^1.1" } Or you tape in your ROOT project composer require uga/twig2pdf-bundle
Enable it in the Kernel
new UGA\Html2PDFBundle\UGAHtml2PDFBundle() ,
How to make it ?
In your controller:
protected $pdf2html ; public function __construct( \UGA\Html2PDFBundle\Factory\Html2pdfFactory $pdf2html ) { $this->pdf2html = $pdf2html ; }
In your action:
$html2pdf = $this->pdf2html->getInstance() ; $html2pdf->WriteHTML($template); $html2pdf->Output('exemple.pdf');
You can pass every option you would pass to twig2pdf, for instance :
$html2pdf = $this->pdf2html->getInstance('P', 'A4', 'en', true, 'UTF-8', array(10, 15, 10, 15)); or by container
$html2pdf = $this->container->get('uga_html2_pdf.service')->getInstance('P', 'A4', 'fr', null, null, null);
If the previous arguments are not provided, the factory uses its own default values. You can
change this default values by adding the bundle configuration to your app/config/config.yml :
uga_html2_pdf: html2_pdf_orientation: 'P' html2_pdf_format: 'A4' html2_pdf_lang: 'fr' html2_pdf_unicode: true html2_pdf_encoding: 'UTF-8' html2_pdf_margin: [10,15,10,15]
Integration with twig template :
$template = $this->template->render('AcmeMyAppBundle:Default:index.html.twig',array( 'CLASS_HTML2PDF' => "HTML2PDF FOR SYMFONY 2.8.18 " )) ; $html2pdf = $this->pdf2html->getInstance() ; $html2pdf->WriteHTML($template); $html2pdf->Output('exemple.pdf');
Full example ( Controller ) :
<?php namespace Acme\MyAppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class DefaultController extends Controller { protected $entityManager ; protected $template ; protected $pdf2html ; public function __construct( \Doctrine\ORM\EntityManager $entityManager , \Twig_Environment $template , \UGA\Html2PDFBundle\Factory\Html2pdfFactory $pdf2html ) { $this->entityManager = $entityManager; $this->template = $template ; $this->pdf2html = $pdf2html ; } public function indexAction() { $template = $this->template->render('AcmeMyAppBundle:Default:index.html.twig',array( 'CLASS_HTML2PDF' => "CLASS HTML2PDF FOR SYMFONY 2.8.18 " )) ; $html2pdf = $this->pdf2html->getInstance() ; $html2pdf->WriteHTML($template); $html2pdf->Output('exemple.pdf'); return $this->render('AcmeMyAppBundle:Default:index.html.twig'); } }
Update package in vendor project ?
composer install
Information:
- Programmer: Spipu
- Web Site : http://html2pdf.fr/
- Wiki : http://html2pdf.fr/en/wiki
- Support : http://html2pdf.fr/en/forum
Contact Me
Nadir Fouka < nadir@fouka.ovh >
- Web Developer Grenoble Alpes University 2017
- Data Scientist Planet@Dev
uga/twig2pdf-bundle 适用场景与选型建议
uga/twig2pdf-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 272.49k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「TCPDF」 「html2pdf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 uga/twig2pdf-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uga/twig2pdf-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 uga/twig2pdf-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
TCPDF is a PHP class for generating PDF documents and barcodes.
Captures website screenshot and converts website to PDF using Screenshot machine - online website screenshot generator and website to PDF converter.
TCPDI is a PHP class for importing PDF to use with TCPDF
TCPDI is a PHP class for importing PDF to use with TCPDF
Convert any URL to PDF and/or HTML to PDF in PHP with the PDFmyURL API
Modified version of TCPDF that includes option for setting barcode's bar width
统计信息
- 总下载量: 272.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-24
