To start this post we must acknowledge the existence of a Zend library to fill in pdfs here and also the fact that there were some people who had used it before even if it was as far as I know only in the 1.x version like here.
The integration between Symfony2 and Zend2 is rather simple since both support namespaces the only thing left is (adapted from here):
git submodule add git://github.com/zendframework/zf2.git vendor/Zend
And register the namespace:
'Zend' => __DIR__.'/../vendor/Zend/library',
And the demo code:
$zf2pdf = new \Zend\Pdf\PdfDocument(__DIR__.'/../pathtoyourfile/test.pdf', null, true); $page = $zf2pdf->pages; $style = new \Zend\Pdf\Style(); $style->setFont(\Zend\Pdf\Font::fontWithName(\Zend\Pdf\Font::FONT_HELVETICA),12); $style->setFontSize(12); $page->setFont($style->getFont(), $style->getFontSize()); $page->drawText('Hello world!', 72, 720); $zf2pdf->save(__DIR__.'/../pathtoyourfile/testout.pdf');
Here we just used the Zend framework classes to work it out without documentation like it used to be in Symfony2. Please help us help you and write more blogs like this by donating on the top right corner of the site.