简体   繁体   English

如何在yii2中使用mPDF?

[英]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导出将导出到excelcsvtext等项目中。 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM