dev-master
9999999-dev https://github.com/astterx/Vel.gitA wrapper for mPDF which allows to use mPDF in Symfony 2.3|~3.0 projects
MIT
The Requires
The Development Requires
by Sandu Velea
pdf mpdf
A wrapper for mPDF which allows to use mPDF in Symfony 2.3|~3.0 projects
MpdfBundle is a wrapper service for mPDF class, created for Symfony projects., (*1)
composer.json
file:"require": { ... "vel/mpdf-bundle": "dev-master" }
php composer.phar update
app/AppKernel.php
:$bundles = array( ... new Vel\MpdfBundle\VelMpdfBundle(), )
This example creates a PDF document from HTML code with default options (font, font size, margins, orientation):, (*2)
$mpdfService = $this->get('vel.mpdf'); $html = '<h2>Hello world</h2>'; $respose = $mpdfService->generatePDFResponseFromHTML($html);
$mpdfService = $this->get('vel.mpdf'); $html = '<h2>Hello world</h2>'; $content = $mpdfService->generatePDF($html); ```` #### Use different options to generate a PDF document with text header and HTML footer
$mpdfService = $this->get('vel.mpdf'); $mpdfService->createMpdfInstance( $format = 'A4', $fontSize = 0, //default $fontFamily = '', //default $marginLeft = 15, $marginRight = 15, $marginTop = 16, $marginBottom = 16, $marginHeader = 9, $marginFooter = 9, $orientation = 'P' // P for portrait, L for landscape ); $mpdfService->getMpdf()->setHeader('Text header'); $mpdfService->getMpdf()->setHTMLFooter(', (*3)
'); $html = ', (*4)
'; $mpdfService->generatePDFResponseFromHTML($html), (*5)
By default the bundle add 'utf-8' to mPDF constructor class. #### Get an instance of \mPDF class If you would like to work with mPDF class itself, you can use a getMpdf method:
$mpdfService = $this->get('vel.mpdf'); $mPDF = $mpdfService->getMpdf(); ``` Read mPDF documentation for more options: http://mpdf1.com, (*6)
A wrapper for mPDF which allows to use mPDF in Symfony 2.3|~3.0 projects
MIT
pdf mpdf