For creating PDF files in Symfony I'm using TCPDF class with WhiteOctoberTCPDFBundle. Both installed via composer.
I need to create custom header and footer by extending TCPDF class, like mentioned in TCPDF documentation.
But the only working solution for me is to extend TCPDF class directly in vendors and then set MYPDF class as default in WhiteOctoberBundle inside getConfigTreeBuilder() method in vendor/whiteoctober/tcpdf-bundle/DependencyInjection/Configuration.php.
So my Configuration.php file looks like this:
public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('white_october_tcpdf');
Bundle author here :-) This is in the bundle documentation, but for a quick reference:
MYPDF class and place it somewhere within your normal Symfony2 code base - let's say in
This class needs to extend the base TCPDF class, which is brought in via the vendors. You'll get an exception thrown if it's not.
config.yml or similar:
white_october_tcpdf: class: 'Acme\DemoBundle\MYPDF'
You should be then able to use this as per the docs:
$pdfObj = $container->get("white_october.tcpdf")->create();
which will give you a new instance of your