2017 © Pedro Peláez
 

symfony-bundle pdf-bundle

Siphoc PDF Bundle for Symfony2

image

siphoc/pdf-bundle

Siphoc PDF Bundle for Symfony2

  • Sunday, January 22, 2017
  • by jelmersnoeck
  • Repository
  • 1 Watchers
  • 14 Stars
  • 23,491 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 13 Versions
  • 2 % Grown

The README.md

PDFBundle

The Siphoc PDF Bundle provides an easy way to create PDF's from your views., (*1)

Build Status, (*2)

Installation

Step 1: Download the bundle using Composer

Add SiphocPdfBundle to composer., (*3)

{
    "require": {
        "siphoc/pdf-bundle": "2.0.*"
    }
}

Install the bundle:, (*4)

$ composer.phar update siphoc/pdf-bundle

Composer will install the bundle with the required dependencies., (*5)

Step 2: Enable the bundle

In your AppKernel add the following:, (*6)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Siphoc\PdfBundle\SiphocPdfBundle(),
    );
}

Step 3: configure your bundle

In your config.yml file:, (*7)

siphoc_pdf:
    basepath: "%kernel.root_dir%/../web"
    binary: "/usr/local/bin/wkhtmltopdf"
    options:
        'lowquality': false
        'enable-javascript': true
        'debug-javascript': true

Usage

Download

In your controller, you can download the contents of your controller like this:, (*8)

$pdfGenerator = $this->get('siphoc.pdf.generator');
$pdfGenerator->setName('my_pdf.pdf');
return $pdfGenerator->downloadFromView(
    'AcmeDemoBundle:Demo:index.html.twig', array(
        'name' => $name,
    )
);

Inline display

There's also an option to display the contents in the browser. To do so, use the following example:, (*9)

$pdfGenerator = $this->get('siphoc.pdf.generator');
$pdfGenerator->setName('my_pdf.pdf');
return $pdfGenerator->displayForView(
    'AcmeDemoBundle:Demo:index.html.twig', array(
        'name' => $name,
    )
);

Documentation

The main Documentation can be found in Resources/doc/index.html. It is auto-generated by PHPDocumentor2. The directory itself is excluded through git because we use the PHPDoc Markdown plugin to create proper MD files to include in Git., (*10)

If you want to contribute, be sure to update the documentation and run both PHPDocumentor2 and PHPDoc Markdown. This way the documentation keeps up to date properly., (*11)

Development

This bundle is mainly created and maintained for Darwin Analytics., (*12)

Tests

For tests I've used PHPUnit. Contributions need to be supported with tests., (*13)

License

This bundle is under the MIT License., (*14)

Dependencies

Buzz

For external calls, I've included the Buzz Bundle from @kriswallsmith., (*15)

Snappy

To create the actual PDF. We're using Snappy. This has the wkhtmltopdf dependency. Be sure that you use the latest version (>=0.11.0_rc1)., (*16)

Symfony

Since this is a Symfony bundle, there are some Symfony dependencies., (*17)

Http Foundation

To create a proper response, I've implemented the Symfony 2.1 Http Foundation component., (*18)

Templating

To render the views automatically, I've added the templating component to force a proper templating engine., (*19)

HttpKernel

Since version 1.1.2 we've implemented a logger instance. This depends on the Symfony2 HttpKernel component., (*20)

The Versions

11/02 2013

1.0.0

1.0.0.0 http://siphoc.github.com

Siphoc PDF Bundle for Symfony2

  Sources   Download

MIT

The Requires

 

pdf