kwizer15 / pdf-bundle
PDF library for Symfony2
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- itbz/fpdf: 1.7.1
- symfony/framework-bundle: ~2.3
This package is not auto-updated.
Last update: 2024-11-23 16:19:10 UTC
README
Installation
- Install KwizerPdfBundle
- Enable the bundle
Install KwizerPdfBundle
Add the following dependency to your composer.json file:
{ "require": { "kwizer15/pdf-bundle": "1.0.*" } }
Update vendors
$ php composer.phar update
Enable the bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Kwizer\PdfBundle\KwizerPdfBundle(), ); }
Using the bundle
Hello World
The document
<?php // src/Acme/DemoBundle/PdfDocument/MyPdf.php namespace Acme\DemoBundle\PdfDocument; class MyDocument extends \Kwizer\PdfBundle\Core\AbstractPdfDocument { public function buildContent() { $this->builder->cell('Hello World !!!'); } }
Controller
<?php // src/Acme/DemoBundle/Controller/MyController.php ... use Symfony\Component\HttpFoundation\Response; use Acme\DemoBundle\PdfDocument\MyDocument; class MyController extends Controller { public function myAction() { $response = new Response(); $response->headers->set('Content-Type', 'application/pdf'); $response->headers->set('Content-Disposition', 'inline; filename=my.pdf'); $pdf = $this->get('kwizer.pdf.factory')->createPdf(new MyDocument()); $response->setContent($pdf); return $response; } }