[英]How to use mPDF in yii2?
I have a yii2
project and I work in front end. 我有一个
yii2
项目,并且在前端工作。 I make an export to excel
, csv
, text
, and others in my project using kartik
export. 我使用
kartik
导出将导出到excel
, csv
, text
等项目中。 Because I want to export to pdf
, then I install kartik mPDF
. 因为我想导出为
pdf
,所以我安装了kartik mPDF
。 But there is an error when I want to export to pdf
. 但是当我想导出为
pdf
时出现错误。 What's the problem? 有什么问题? This is the error:
这是错误:
The pdf rendering library 'mPDF' was not found or installed at path 'C:\\xampp\\htdocs\\Baru\\advanced/vendor/mpdf/mpdf'.
在路径'C:\\ xampp \\ htdocs \\ Baru \\ advanced / vendor / mpdf / mpdf'上找不到或安装了pdf渲染库'mPDF'。
I think you should change path of mpdf lib in export lib config 我认为您应该在导出lib配置中更改mpdf lib的路径
...
'pdfLibraryPath' => '@app/vendor/mpdf/mpdf'
...
Check your path as error shows, I think advanced part is redundant. 如错误所示检查路径,我认为高级部分是多余的。
<?php
use kartik\mpdf\Pdf;
return [
'pdf' => [
'class' => Pdf::className(),
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_PORTRAIT,
'destination' => Pdf::DEST_BROWSER,
'methods' => [
'SetHeader' => 'Merlano PVT LTD',
'SetFooter'=> 'Flamez',
],
],
];
Copy and paste this into your /common/config/main.php 复制并粘贴到您的/common/config/main.php中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.