dev-master
9999999-dev https://github.com/m4t1t0/FopPdfBundle.gitSymfony 2 Apache FOP integration
GPL v2
The Requires
- php >=5.3.3
- symfony/symfony >=2.3
by Rafael Matito Matito
pdf fop
Symfony 2 Apache FOP integration
This bundle provides integration with Apache FOP (http://xmlgraphics.apache.org/fop/) for Symfony2, (*1)
Add to your composer.json, (*2)
{ "require": { "m4t1t0/fop-pdf-bundle": "dev-master" } }
Use composer to download the new requirement, (*3)
$ php composer.phar update m4t1t0/fop-pdf-bundle
``` php <?php, (*4)
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new m4t1t0\FopPdfBundle\FopPdfBundle(),
// ...
);
}, (*5)
## Configure the bundle If the fop executable is different than /usr/bin/fop you need to configure this in your config.yml file
fop_pdf: fop: /usr/local/bin/fop, (*6)
# Usage Use the Pdf annotation in your action ``` php <?php /** * @Route("/download-pdf") * @Pdf() */ public function downloadPdfAction() { return array( 'name' => 'Rafa', ); }
Create the view downloadPdf.fo.twig inside your Resources directory, (*7)
{% extends "FopPdfBundle::basea4.fo.twig" %} {% block content %} <fo:block> Hello {{ name }}! </fo:block> {% endblock %}
The Pdf annotation suport these options:, (*8)
output: the name of the output file. You can use the PHP strftime function format, more info: http://es1.php.net/manual/en/function.strftime.php
If you need more conrol over the output file name, you can use _pdf_output
variable in your return, (*9)
template: Indicates the template to render instead the guesser one., (*10)
php
<?php
/**
* @Route("/download")
* @Pdf()
*/
public function downloadPdfAction()
{
return array(
'name' => 'Rafa',
'_pdf_output' => 'custom_pdf_output_filename.pdf',
);
}
, (*11)
Symfony 2 Apache FOP integration
GPL v2
pdf fop