symfony - 更改 WhiteOctober TCPDF 包配置值

标签 symfony tcpdf symfony-2.1

我已经开始在我的 symfony 项目中使用 WhiteOctober TCPDF 包,但我不知道如何更改默认配置值,例如页面格式。我试过把它放在我的 config.yml 中:

white_october_tcpdf:
    tcpdf:
        k_tcpdf_external_config: true
        pdf_page_format: 'LETTER'
        pdf_author: 'Company Name'
        pdf_header_title: 'Order Confirmation'
        pdf_header_string: 'Company Name'
        pdf_header_logo: '%kernel.root_dir%/../web/images/logo.png'
        pdf_header_logo_width: '35'
        pdf_margin_header: 15
        pdf_margin_footer: 15
        pdf_margin_top: 25
        pdf_margin_bottom: 25
        pdf_margin_left: 25
        pdf_margin_right: 25

但它们在调用时完全被忽略
$pdf = $this->get('white_october.tcpdf')->create();

在我的 Controller 中。生成的 PDF 仍然是 A4,没有标题和默认边距。

我是否缺少使捆绑包采用我的自定义配置的东西?

最佳答案

我也有同样的问题。更改供应商代码不是最佳实践。我的解决方法如下:

我在 src 文件夹中创建了一个新类“CustomWhiteOctoberTCPDFBundle”。

namespace TCPDFBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class CustomWhiteOctoberTCPDFBundle extends Bundle
{
 public function getParent()
    {
        return 'WhiteOctoberTCPDFBundle';
    }  
    public function boot() {
         //Put modified method as mentioned in the previous answer

    }
}

On AppKernel.php put:
    public function registerBundles()
    {
        $bundles = array(...
            new WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle(),
            new TCPDFBundle\CustomWhiteOctoberTCPDFBundle(),

关于symfony - 更改 WhiteOctober TCPDF 包配置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13235808/

相关文章:

symfony - 两个项目共享相同的实体——如何维护代码?

php - 用于 PHP 的 TCPDF 在使用特殊(斯洛文语)字符 đ 时创建空 PDF

php - 无法使用 TCPDF 从 MySQL 查询生成 PDF

php - 如何使用文本左下角的 XY 坐标在 TCPDF 中定位文本?

php - symfony2 教程 - 生成包

Symfony2 ACL 访问多个用户的多个对象

php - Symfony2 有条件验证

php - Symfony2 Sonata 项目 sonata_type_model 与 OneToMany 实体 sortby

php - symfony2 中的 var_dump 数据过多

Symfony 2 FOSElasticaBundle : elastic search documents are not automatically synchronized with entities : need to run ' fos:elastica:populate'