Giter Club home page Giter Club logo

mpdfportbundle's Introduction

Installation

Using Composer (Symfony 2.x, Symfony 3.0.x)

  • Run a command
composer require tfox/mpdf-port-bundle
  • Add a new line to app/AppKernel.php:
$bundles = array(
  ...
  new TFox\MpdfPortBundle\TFoxMpdfPortBundle(),
)

Using deps-file (Symfony 2.0.x)

  • Add a new entry to your deps file:
[TFoxMpdfPortBundle]
    git=https://github.com/tasmanianfox/MpdfPortBundle.git
    target=/bundles/TFox/MpdfPortBundle 
  • Add a new line to app/AppKernel.php:
new TFox\MpdfPortBundle\TFoxMpdfPortBundle(), 
  • Add a new line to app/autoload.php:
'TFox' => __DIR__.'/../vendor/bundles',
  • Run a command
php bin/vendors install

A Quick Start guide

How to create a Response object

This small example creates a PDF document with format A4 and portrait orientation:

public function indexAction()
{
   return new \TFox\MpdfPortBundle\Response\PDFResponse($this->getMpdfService()->generatePdf('Hello World'));
}

/**
 * @return \TFox\MpdfPortBundle\Service\PDFService
 */
private function getMpdfService()
{
  return $this->get('t_fox_mpdf_port.pdf');
}

Generate a variable with PDF content

Sometimes it is necessary to get a variable which content is PDF document.

$myVar = $this->getMpdfService()->generatePdf('Hello World');

How to get an instance of \mPDF class

If you would like to work with mPDF class itself, you can use a getMpdf method:

$mpdf = new \Mpdf\Mpdf();

Additional options

Additional options might be passed via the second argument:

public function indexAction()
{
    return new \TFox\MpdfPortBundle\Response\PDFResponse($this->getMpdfService()->generatePdf('Hello World', array(
            'format' => 'A4-L' // A4 page, landscape orientation
    )));
}

Detailed description is available on official manual page: https://mpdf.github.io/

mpdfportbundle's People

Contributors

pabgaran avatar pabloveintimilla avatar billytom avatar sergbelyakov avatar markitosgv avatar yashmika avatar muxx avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.