Versión 1/4
-
Siguiente » -
Versión actual
Guillermo Zdanowicz, 24/03/2016 01:09
PDF¶
Referencia:http://www.bsourcecode.com/yiiframework2/create-pdf-files-using-mpdf-in-yiiframework-2-0/
"require": { "php": ">=5.4.0", "yiisoft/yii2": "*", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*", "mpdf/mpdf":"*" },
composer update
Agregar en ‘vendor/composer/autoload_namespaces.php’ la linea en el arreglo
'mPDF' => array($vendorDir . '/mpdf/mpdf'),
En el controlador SiteController.php
............... use app\models\ContactForm; use mPDF; class SiteController extends Controller { ............... public function actionCreateMPDF(){ $mpdf=new mPDF(); $mpdf->WriteHTML($this->renderPartial('mpdf')); $mpdf->Output(); exit; //return $this->renderPartial('mpdf'); } public function actionSamplePdf() { $mpdf = new mPDF; $mpdf->WriteHTML('Sample Text'); $mpdf->Output(); exit; } public function actionForceDownloadPdf(){ $mpdf=new mPDF(); $mpdf->WriteHTML($this->renderPartial('mpdf')); $mpdf->Output('MyPDF.pdf', 'D'); exit; }