Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 1.46 KB

README.md

File metadata and controls

87 lines (66 loc) · 1.46 KB

pdf-bundle

Build Status

Installation

  1. Install KwizerPdfBundle
  2. 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;
	}
}