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

1.0.2 2014-04-13 16:01 UTC

This package is not auto-updated.

Last update: 2024-11-23 16:19:10 UTC


README

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;
	}
}