ftwex/fpdf-symfony2

fpdf vendor for use with symfony2, based on royopa/fpdf-symfony2

1.0 2015-07-17 01:36 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:28:40 UTC


README

Uses FPDF 1.7, tested in Symfony 2.5+

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality

Instalation and Usage

Package available on Composer.

If you're using Composer to manage dependencies, you can use

composer require ftwex/fpdf-symfony2

Usage

class WelcomeController extends Controller
{
    public function indexAction()
    {
        $pdf  = new \FPDF_FPDF();
        $pdi  = new \FPDF_FPDI();

        $pdf->AddPage();
        $pdf->SetFont('Arial','B',16);
        $pdf->Cell(40,10,'Hello World!');
        $pdf->Output();
    }
}

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

See My Controller:

<?php

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class WelcomeController extends Controller
{
    public function indexAction()
    {
        $pdf  = new \FPDF_FPDF();
        $pdi  = new \FPDF_FPDI();

        //my code...

        return new Response($pdf->Output( 'MyPDF.pdf', 'I'), 200, array('Content-Type' => 'application/pdf'));
    }
}