royopa / fpdf-symfony2
fpdf vendor for use with symfony, based on toooni/fpdf
Installs: 308 380
Dependents: 0
Suggesters: 0
Security: 0
Stars: 28
Watchers: 4
Forks: 22
Open Issues: 0
Requires
- php: >=5.3.3
- setasign/fpdf: ~1.8
- setasign/fpdi: ~2.3
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is auto-updated.
Last update: 2024-10-29 04:36:22 UTC
README
Uses FPDF 1.8 and FPDI 2.3, tested in Symfony 2+ and 3+
Instalation and Usage
Package available on Composer.
If you're using Composer to manage dependencies, you can use
composer require royopa/fpdf-symfony2
Usage
class WelcomeController extends Controller { public function indexAction() { $pdf = new \FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); return new Response($pdf->Output(), 200, array( 'Content-Type' => 'application/pdf')); } }
FPDF
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. FPDF is a open source project: you may use it for any kind of usage and modify it to suit your needs.
On the fpdf homepage you will find links to the documentation, forums and so on.
Example
My Controller:
<?php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ public function indexAction(Request $request) { $pdf = new \FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); return new Response($pdf->Output(), 200, array( 'Content-Type' => 'application/pdf')); } }