protected function getPdfResponse($action, $result, $params)
    {
        if (Yii::$app->response->format !== Response::FORMAT_PDF) {
            return false;
        }
        $headers = Yii::$app->response->getHeaders();
        if (($location = $headers->get('Location')) !== null) {
            return $this->redirect($location);
        }
        $content = Yii::$app->request->isAjax
            ? $this->renderAjax($action->viewName, $params)
            : $this->render($action->viewName, $params);
        parent::afterAction($action, $content);

        $renderer = new \mPDF(
            'pl-x', // mode
            'A4', // format
            0, // font-size
            '', // font
            12, // margin-left
            12, // margin-right
            5, // margin-top
            5, // margin-bottom
            2, // margin-header
            2, // margin-footer
            'P' // orientation
        );
        $renderer->useSubstitutions = true;
        $renderer->simpleTables = false;
        @$renderer->WriteHTML($content);

        $response = new \yii\web\Response();
        $response->setDownloadHeaders($action->id.'.pdf', 'application/pdf', true);
        $response->format = Response::FORMAT_RAW;
        $response->content = $renderer->Output('print', 'S');
        return $response;
    }