2017 © Pedro Peláez
 

yii2-extension yii2-mpdf

mPDF response formatter for Yii2

image

iutbay/yii2-mpdf

mPDF response formatter for Yii2

  • Friday, October 20, 2017
  • by iutbay
  • Repository
  • 1 Watchers
  • 2 Stars
  • 69 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

yii2-mpdf

mPDF response formatter for Yii2., (*1)

https://packagist.org/packages/iutbay/yii2-mpdf, (*2)

Installation

The preferred way to install this response formatter is through composer., (*3)

Either run, (*4)

composer require "iutbay/yii2-mpdf" "*"

or add, (*5)

"iutbay/yii2-mpdf" : "*"

to the require section of your application's composer.json file., (*6)

Configuration

Add the following lines in the components section of your application configuration :, (*7)

'response' => [
  'formatters' => [
    'mpdf' => [
      'class' => 'iutbay\yii2mpdf\MPDFResponseFormatter',

      // mPDF constructor options : http://mpdf1.com/manual/index.php?tid=184
      //'mPDFConstructorOptions' => [
        //'mode' => '',
        //'format' => 'A4',
        //'defaultFontSize' => '',
        //'defaultFont' => '',
        //'marginLeft' => 15,
        //'marginRight' => 15,
        //'marginTop' => 16,
        //'marginBottom' => 16,
        //'marginHeader' => 9,
        //'marginFooter' => 9,
        //'orientation' => 'P',
      //],

      // mPDF options : http://mpdf1.com/manual/index.php?tid=273
      //'mPDFOptions' => [],

      // css file path aliases, e.g. ['@app/web/css/pdf.css']
      //'cssFiles' => [],

      // page header : http://mpdf1.com/manual/index.php?tid=149
      //'header' => null,

      // page footer : http://mpdf1.com/manual/index.php?tid=151
      //'footer' => null,

      // ouput options : http://mpdf1.com/manual/index.php?tid=125
      //'outputName' => '',
      //'outputDest' => 'I',
    ],
  ],
],

Usage in controllers

Example 1 :, (*8)

public function actionPdf()
{
  Yii::$app->response->format = 'mpdf';
  return $this->render('pdf');
}

Example 2 :, (*9)

public function actionPdf()
{
  Yii::$app->response->format = 'mpdf';
  return [
    // mPDF construtor options : http://mpdf1.com/manual/index.php?tid=184
    //'mPDFConstructorOptions' => [],
    // mPDF options : http://mpdf1.com/manual/index.php?tid=273
    //'mPDFOptions' => [],
    'content' => $this->render('pdf'),
    //'options' => [
        // page header : http://mpdf1.com/manual/index.php?tid=149
        //'header' => 'Left|Center|Right',
        // page footer : http://mpdf1.com/manual/index.php?tid=151
        //'footer' => 'Left|Center|{PAGENO}/{nbpg}',
        // ouput options : http://mpdf1.com/manual/index.php?tid=125
        //'outputName' => 'test.pdf',
        //'outputDest' => 'D',
    //],
  ]
}

The Versions

20/10 2017

dev-master

9999999-dev https://github.com/iutbay/yii2-mpdf

mPDF response formatter for Yii2

  Sources   Download

The Requires

 

by Kevin LEVRON

extension yii2 pdf mpdf

29/01 2016

0.2

0.2.0.0 https://github.com/iutbay/yii2-mpdf

mPDF response formatter for Yii2

  Sources   Download

The Requires

 

by Kevin LEVRON

extension yii2 pdf mpdf

01/11 2015

0.1

0.1.0.0 https://github.com/iutbay/yii2-mpdf

mPDF response formatter for Yii2

  Sources   Download

The Requires

 

by Kevin LEVRON

extension yii2 pdf mpdf