Using Symfony2 and PdfBundle to generate dynamically PDF files, I cannot generate files really.
Following the documentation instructions, I installed all the information about the package:
autoload.php:
'Ps' => __DIR__.'/../vendor/bundles',
'PHPPdf' => __DIR__.'/../vendor/PHPPdf/lib',
'Imagine' => array(__DIR__.'/../vendor/PHPPdf/lib', __DIR__.'/../vendor/PHPPdf/lib/vendor/Imagine/lib'),
'Zend' => __DIR__.'/../vendor/PHPPdf/lib/vendor/Zend/library',
'ZendPdf' => __DIR__.'/../vendor/PHPPdf/lib/vendor/ZendPdf/library',
AppKernel.php:
... new Ps \ PdfBundle \ PsPdfBundle (), ...
I think that all the settings are configured correctly, since I do not get any "library not found" and nothing like that ...
So, after all this, I do this in the controller:
...
use Ps\PdfBundle\Annotation\Pdf;
...
public function generateInvoicePDFAction($name = 'Pedro')
{
return $this->render('AcmeStoreBundle:Shop:generateInvoice.pdf.twig', array(
'name' => $name,
));
}
And having this twig file:
<pdf>
<dynamic-page>
Hello {{ name }}!
</dynamic-page>
</pdf>
Well. One way or another, what I just got on my page is regular HTML code, created as if it were a normal Response rendering.
The annotation Pdf()should give a βspecialβ behavior to create a PDF file instead of rendering regular HTML.
, , http://www.mysite.com/*...*/pdf, , , HTML-:
<pdf>
<dynamic-page>
Hello Pedro!
</dynamic-page>
</pdf>
( HTML Hello Pedro! .
? - ? *.html.twig *.pdf.twig? ...: (