コード例 #1
0
 public function actionPrint()
 {
     $person = null;
     $billPersonal = null;
     if (isset($_GET['p'], $_GET['s'])) {
         $ids = explode(',', $_GET['s']);
         $person = Person::findOne($_GET['p']);
         $billPersonal = BillPersonal::getAsociated($_GET['p'], $ids);
         if ($person !== null && count($billPersonal) > 0) {
             $content = $this->renderPartial('print', ['person' => $person, 'billPersonal' => $billPersonal]);
             $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => Yii::t('app', 'Bill') . ' ' . Yii::t('app', 'Report')], 'methods' => ['SetHeader' => [Yii::t('app', 'Summary')], 'SetFooter' => ['{PAGENO}']]]);
             return $pdf->render();
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }