I have used kartik pdf extension to print my report in pdf format.Things are going well in my local computer but when i put my codes in server error appears like this:
我已使用kartik pdf扩展名以pdf格式列印我的报告。我的本地计算机运行得很好,但是当我将代码输入服务器错误时,会出现如下情况:
Fatal error: Class 'mPDF' not found in myproject/vendor/kartik-v/yii2-mpdf/Pdf.php on line 281
In server i have uploaded yii2-mpdf folder inside kartik-v folder and also mpdf folder. My code of controller for pdf print:
在服务器上,我上传了yii2-mpdf文件夹在kartik-v文件夹和mpdf文件夹。我的pdf打印控制器代码:
use kartik\mpdf\Pdf;
public function actionPearlFinancialReport()
{
$pdf = new Pdf([
//'mode' => Pdf::MODE_CORE,
'mode' => Pdf::MODE_UTF8,
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_PORTRAIT,
'destination' => Pdf::DEST_BROWSER,
'content' => $this->renderPartial('_financial_report', ['model' => $model,'parameter'=>$parameter]),
'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
'cssInline'=> '.kv-heading-1{font-size:15px;text-align:center;}',
'options' => ['title' => 'Pearl Financial Report'],
'methods' => [
'SetHeader'=>['Pearl Financial Report'],
'SetFooter'=>['{PAGENO}'],
]
]);
$response = Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_RAW;
$headers = Yii::$app->response->headers;
$headers->add('Content-Type', 'application/pdf');
}
}
What to do?
要做什么吗?
1 个解决方案
#1
-1
Try to register this extension with composer:
尝试注册这个扩展与作曲家:
For example my work directory is c:\xampp\htdocs\my-project
例如,我的工作目录是c:\xampp\htdocs\my-project。
In a command prompt -> cd c:\xampp\htdocs\my-project
在命令提示符-> cd c:\xampp\htdocs\my-project
And register with this command:
并按以下命令注册:
C:\xampp\htdocs\my-project>php c:\xampp\htdocs\composer.phar require kartik-v/yii2-mpdf "dev-master"
C:\ xampp \根\我的项目> php C:\ xampp \根\作曲家。phar需要kartik-v / yii2-mpdf“dev-master”
I always register kartik's extensions with this metod, I hope want to be useful for you too.
我总是用这个metod注册kartik的扩展,我希望对您也有用。
#1
-1
Try to register this extension with composer:
尝试注册这个扩展与作曲家:
For example my work directory is c:\xampp\htdocs\my-project
例如,我的工作目录是c:\xampp\htdocs\my-project。
In a command prompt -> cd c:\xampp\htdocs\my-project
在命令提示符-> cd c:\xampp\htdocs\my-project
And register with this command:
并按以下命令注册:
C:\xampp\htdocs\my-project>php c:\xampp\htdocs\composer.phar require kartik-v/yii2-mpdf "dev-master"
C:\ xampp \根\我的项目> php C:\ xampp \根\作曲家。phar需要kartik-v / yii2-mpdf“dev-master”
I always register kartik's extensions with this metod, I hope want to be useful for you too.
我总是用这个metod注册kartik的扩展,我希望对您也有用。