yii - convert to pdf ( yii2) -


how make when user click profile button,it display in pdf file. i've install mpdf extension. below code try convert personalinfo.php page pdf.

class mpdfcontroller extends controller {     public function actionpersonalinfo() {         // sql query here         $content = $this->renderpartial('personalinfo', ['model' => $model]);          // setup kartik\mpdf\pdf component         $pdf = new pdf([             // set use core fonts             'mode' => pdf::mode_core,             // a4 paper format             'format' => pdf::format_a4,             // portrait orientation             'orientation' => pdf::orient_portrait,             // stream browser inline             'destination' => pdf::dest_browser,             // html content input             'content' => $content,             // format content own css file if needed or use             // enhanced bootstrap css built krajee mpdf formatting             'cssfile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',             // css embedded if required             'cssinline' => '.kv-heading-1{font-size:18px}',             // set mpdf properties on fly             'options' => ['title' => 'profilestudent'],             // call mpdf methods on fly             'methods' => [                 'setheader'=>['profile'],                 'setfooter'=>['{pageno}'],             ]         ]);          /*------------------------------------*/         yii::$app->response->format = \yii\web\response::format_raw;         $headers = yii::$app->response->headers;         $headers->add('content-type', 'application/pdf');         /*------------------------------------*/          // return pdf output per destination setting         return $pdf->render();     }     ... } 

thanks

seem don't have model. try passing id when call action , use id retrieve info in $model

public function actionpersonalinfo($id) {    $model = $this->findmodel($id);     $content = $this->renderpartial('personalinfo', ['model' => $model]);    // setup kartik\mpdf\pdf component   $pdf = new pdf([   // set use core fonts   'mode' => pdf::mode_core,   .... 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -