m4t1t0 / fop-pdf-bundle
Symfony 2 Apache FOP integration
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- symfony/symfony: >=2.3
This package is not auto-updated.
Last update: 2025-06-21 19:04:06 UTC
README
This bundle provides integration with Apache FOP (http://xmlgraphics.apache.org/fop/) for Symfony2
Installation and configuration
Get the bundle
Add to your composer.json
{
"require": {
"m4t1t0/fop-pdf-bundle": "dev-master"
}
}
Use composer to download the new requirement
$ php composer.phar update m4t1t0/fop-pdf-bundle
Add FopPdfBundle to your application kernel
<?php // app/AppKernel.php public function registerBundles() { return array( // ... new m4t1t0\FopPdfBundle\FopPdfBundle(), // ... ); }
Configure the bundle
If the fop executable is different than /usr/bin/fop you need to configure this in your config.yml file
# FopPdfBundle Configuration
fop_pdf:
fop: /usr/local/bin/fop
Usage
Use the Pdf annotation in your action
<?php /** * @Route("/download-pdf") * @Pdf() */ public function downloadPdfAction() { return array( 'name' => 'Rafa', ); }
Create the view downloadPdf.fo.twig inside your Resources directory
{% extends "FopPdfBundle::basea4.fo.twig" %}
{% block content %}
<fo:block>
Hello {{ name }}!
</fo:block>
{% endblock %}
Options
The Pdf annotation suport these options:
-
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 -
template: Indicates the template to render instead the guesser one.
<?php /** * @Route("/download") * @Pdf() */ public function downloadPdfAction() { return array( 'name' => 'Rafa', '_pdf_output' => 'custom_pdf_output_filename.pdf', ); }
TODO
- Support PHP templates, at this moment only twig is supported.
- Create a service to render the XSL-FO template instead of annotation.
- Create twig extensions to help the creation of XSL-FO templates.
- Create more base templates.