Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii2 pdf generation not working

Tags:

php

pdf

yii2

mpdf

I have install mpdf using this link pdf yii2 installer , This is not working.

My action is :

 public function actionReport() {
 // get your HTML raw content without any layouts or scripts
 $content = '<html><head></head><body><h1 class="kv-heading-1">hello</h1></body></html>';

 // setup kartik\mpdf\Pdf component
 $pdf = new Pdf([
   // set to use core fonts only
   'mode' => Pdf::MODE_CORE,
   // A4 paper format
   'format' => Pdf::FORMAT_A4,
   // portrait orientation
   'orientation' => Pdf::ORIENT_PORTRAIT,
   // stream to browser inline
   'destination' => Pdf::DEST_BROWSER,
   // your html content input
   'content' => $content,
   // format content from your own css file if needed or use the
   // enhanced bootstrap css built by Krajee for mPDF formatting
   //'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
   // any css to be embedded if required
   'cssInline' => '.kv-heading-1{font-size:18px}',
   // set mPDF properties on the fly
   'options' => ['title' => 'Krajee Report Title'],
   // call mPDF methods on the fly
   'methods' => [
     'SetHeader'=>['Krajee Report Header'],
     'SetFooter'=>['{PAGENO}'],
   ]
 ]);

 // return the pdf output as per the destination setting
 return $pdf->render();
}

Output:

output

What should I have to do for pdf ?

like image 330
unknownbits Avatar asked Jan 07 '23 21:01

unknownbits


1 Answers

Try using

 // set to use core fonts only
'mode' => Pdf::MODE_BLANK,
like image 106
ScaisEdge Avatar answered Jan 15 '23 21:01

ScaisEdge