prg/portabledocument-bundle

This bundle to generate PDFs optionally with css styling.

Installs: 52

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/prg/portabledocument-bundle

v1.0 2014-07-23 15:06 UTC

This package is not auto-updated.

Last update: 2025-10-21 08:53:38 UTC


README

PortableDocumentBundle is a PHP (5.3+) wrapper for the mPDF Library. It allows you to generate pdfs from html.

Installation

With composer, add:

{
    "require": {
        "prg/portabledocument-bundle": "dev-master"
    }
}

Then enable it in your kernel:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new PRG\PortableDocumentBundle\PRGPortableDocumentBundle(),
        //...

Render a pdf document as response from a controller

$pdfGenerator = $this->get('pguso.mpdf');

$html = $this->renderView('YourBundle:Folder:file.html.twig', array(
            'args' => $args
        ));

return new Response(
          $pdfGenerator->generateFromView($html, array(
                'stylesheet' => '/pdf/style.css' //optional
            ))
        );