我已经开始在我的 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/