public function actionPrintDispatch() { $dispatch_model_1 = array(); $dispatch_model_2 = array(); $dispatch_id = Yii::$app->request->post('dispatch_number'); if (isset($dispatch_id)) { $dismodel = new DispatchModel(); Yii::$app->response->format = 'pdf'; Yii::$container->set(Yii::$app->response->formatters['pdf']['class'], ['format' => 'Letter', 'orientation' => 'Portrait', 'beforeRender' => function ($mpdf, $data) { }]); $this->layout = '//print_dispatch'; $dispatch_model_2 = $dismodel->getDispatchItems($dispatch_id); return $this->render('dispatch-print-preview.php', ['dispatch_model_2' => $dispatch_model_2]); } else { return $this->render('index'); } }