tiitoo / tcpdfbundle
Provides TCPDF integration for Symfony
Installs: 62
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- symfony/framework-bundle: 2.7.*
- tecnick.com/tcpdf: >=6.0.041
This package is auto-updated.
Last update: 2024-10-30 01:53:40 UTC
README
Installation
Using composer
Add following lines to your composer.json
file:
Symfony 2.3.*
"require": {
...
"gonzakpo/tcpdfbundle": "dev-master"
}
Execute:
php composer.phar update "gonzakpo/tcpdfbundle"
Add it to the AppKernel.php
class:
// ...
new Io\TcpdfBundle\IoTcpdfBundle(),
No Using composer
-
Download TCPDF library at http://sourceforge.net/projects/tcpdf/files/ and put it in vendor folder
-
Add this bundle to your vendor/ dir * Vendor Mode Add the following lines in your deps file::
[IoTcpdfBundle] git=git://github.com/ioalessio/IoTcpdfBundle.git target=/bundles/Io/TcpdfBundle
Run the vendor script:
./bin/vendors install
-
Add the "Io" namespace to your autoloader:
// app/autoload.php $loader->registerNamespaces(array( 'Io' => DIR.'/../vendor/bundles', // your other namespaces ));
//in same file include tcpdf library require_once DIR.'/../vendor/tcpdf/tcpdf.php';
-
Add the "Io" namespace to your kernel:
// app/ApplicationKernel.php public function registerBundles() { return array( // ... new Io\TcpdfBundle\IoTcpdfBundle(), // ... ); }
HOW TO USE:
//in mybundle/controllers/myController.php
class MyController extends Controller
{
/**
* @Route("/mypage.pdf")
*/
public function mypageAction()
{
$html = $this->renderView('MyBundle:MyController:mypage.pdf.twig', array());
//io_tcpdf will returns Response object
return $this->get('io_tcpdf')->quick_pdf($html);
}
}
//in mybundle/Resources/views/myController.pdf.twig
put here your html code
TODO
- smart method for easier PDF generation and customization
- cache pdf generation
- @PDF('template.twig') annotation system