2017 © Pedro Peláez
 

neos-package pdf

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

image

famelo/pdf

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  • Tuesday, March 6, 2018
  • by mneuhaus
  • Repository
  • 5 Watchers
  • 20 Stars
  • 8,178 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 12 Forks
  • 2 Open issues
  • 8 Versions
  • 10 % Grown

The README.md

Famelo.PDF

Scrutinizer Code Quality, (*1)

This package provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library, (*2)

Example:, (*3)

$document = new \Famelo\PDF\Document('My.Package:SomeDocument');
$document->assign('someVariable', 'foobar');

// Trigger a Download and exit
$document->download('SomeDocument ' . date('d.m.Y') . '.pdf');

// Show the document inline and exit
$document->send();

// Save the document to a local file
$document->save('/Some/Path/SomeDocument ' . date('d.m.Y') . '.pdf');

This example will render a template located at 'resource://My.Package/Private/Documents/SomeDocument.html and convert it to PDF., (*4)

Page Format and orientation

By default pages will be rendered as a A4 Portrait. You can choose another format/orientation like this:, (*5)

// set format to A5 Portrait
$document = new \Famelo\PDF\Document('My.Package:SomeDocument', 'A5');

// set format to an A4 Landscape
$document->setFormat('A4-L');

// set format to 100mm x 200mm
$document->setFormat(array(100, 200));

The MPDF library supports different page sizes with these keywords or an array containing 2 values for width + height:, (*6)

  • A0 - A10
  • B0 - B10
  • C0 - C10
  • 4A0
  • 2A0
  • RA0 - RA4
  • SRA0 - SRA4
  • Letter
  • Legal
  • Executive
  • Folio
  • Demy
  • Royal
  • Ledger
  • Tabloid*

All of the above values can be suffixed with "-L" to force a Landscape page orientation document e.g. "A4-L". If format is defined as a string, the final orientation parameter will be ignored., (*7)

*Ledger and Tabloid are standard formats with the same page size but different orientation (Ledger is landscape, and Tabloid is portrait). mPDF treats these identically; if you wish to use Ledger, you should specify "Ledger-L" for landscape., (*8)

Page numbering in Fluid

If you want to use mPDFs page numbering variables like {PAGENO} or {nbpg} you have to wrap them in a CDATA section, to keep Fluid from interpreting them as variables., (*9)

PDF Generator Implementation

By default this Library uses the MPDF library to generate the PDFs. But you can change the defaultGenerator through the Settings.yaml like this:, (*10)

Famelo:
  PDF:
    # Generator using wkhtmltopdf through knplabs/knp-snappy
    DefaultGenerator: '\Famelo\PDF\Generator\WebkitGenerator'
    DefaultGeneratorOptions:
      Binary: '/usr/local/bin/wkhtmltopdf'

Feel free to create and use a generator for your favorite PDF Library And send me a Pull-Request if you think others might like to use it :), (*11)

The Versions

06/03 2018

dev-master

9999999-dev

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

06/03 2018

3.1.1

3.1.1.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

08/08 2017

3.1.0

3.1.0.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

29/03 2017

3.0.0

3.0.0.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

08/11 2016

2.0.0

2.0.0.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

12/08 2016

1.0.x-dev

1.0.9999999.9999999-dev

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

18/02 2016

1.0.1

1.0.1.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires

 

29/03 2015

1.0.0

1.0.0.0

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

  Sources   Download

The Requires