2017 © Pedro Peláez
 

library files-bundle

Files Bundle for Symfony 2

image

imag/files-bundle

Files Bundle for Symfony 2

  • Thursday, May 26, 2016
  • by BorisMorel
  • Repository
  • 2 Watchers
  • 2 Stars
  • 2,753 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 3 % Grown

The README.md

FilesBundle

This bundle can create/manage PDFs files. it can create a Pdf from a html page and append many Pdfs files on the document and zip final document. It use KnpSnappyBundle to create PDF from Html and ZendPdf to append pdfs files., (*1)

Install

  1. Download FilesBundle
  2. Enable the bundle
  3. Configure the KnpSnappyBundle

How get the bundle

Caution:, (*2)

The dev-master version have not backward compatibility with the 2.x version., (*3)

Composer

Modify your composer.json on your project root, (*4)

``` json // {root}/composer.json, (*5)

{ [...], "require": { [...], "imag/files-bundle": "dev-master" } }, (*6)


### Enable the Bundle ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new IMAG\FilesBundle\IMAGFilesBundle(), ); }

Configure KnpSnappyBundle

Please read the official KnpSnappyBundle documentation https://github.com/KnpLabs/KnpSnappyBundle, (*7)

Usage

Create PDF from Html

``` php <?php, (*8)

$pdf = $this->get('imag_files.pdf') ->setTemplate("foo.html.twig", array('includeVar', $includeVar)) ->setPdfPrefix('foo-file') // Like : 'foo-file-uniqId().pdf' ->setPath('/home/foo/tmp') // Default sys_get_temp_dir() ->addParameter('name', $value) ->htmlToPdf() ;, (*9)


### Append pdf file to final document ``` php <?php $pdf = $this->get('imag_files.pdf') ->setPdfPath($finalPdf) ->appendFiles(array($file1, $files2)) ;

Adding files into zip archive

``` php <?php, (*10)

$zip = $this->get('imag_files.zip') ->add($pdf) ;, (*11)


## Example ### Twig template ``` html <!DOCTYPE html> <html> <head> <meta charset='utf-8'> {% include('NSFooBundle:Pdf/css:' ~ includeVar) %} </head> <body> <h1>{{ data.title }}</h1> <h2>{{ data.body }}</h2> </body> </html>

The Versions

17/06 2014
04/10 2013