如何在Yii中将查看页面转换为pdf

如何在Yii中将查看页面转换为pdf,pdf,yii,Pdf,Yii,如何从controller将查看页面转换为pdf格式的Yii。 在main.php中,我添加了以下代码 'ePdf' => array( 'class' => 'ext.yii-pdf.EYiiPdf', 'params' => array( 'mpdf' => array( 'librarySourcePath' => 'applicat

如何从controller将查看页面转换为pdf格式的Yii。 在main.php中,我添加了以下代码

 'ePdf' => array(
        'class'         => 'ext.yii-pdf.EYiiPdf',
        'params'        => array(
            'mpdf'     => array(
                'librarySourcePath' => 'application.vendors.mpdf.*',
                'constants'         => array(
                    '_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
                ),
                'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
            ),
            'HTML2PDF' => array(
                'librarySourcePath' => 'application.vendors.html2pdf.*',
                'classFile'         => 'html2pdf.class.php', // For adding to Yii::$classMap

            )
        ),
    ),
控制器代码为

$mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
$mPDF1->WriteHTML($this->renderPartial('printformat', array(), true));
$mPDF1->Output();

错误:includempdf.php[function.include]:无法打开流:没有这样的文件或目录

错误表明,在使用它之前必须包含mpdf.php

您正在将YIPDF捆绑包与html2pdf和mpdf一起使用

首先从下载Yii Pdf,并将其作为受保护的/extensions/Yii Pdf ext.Yii-Pdf ext.Yii-Pdf包含在“class=>”ext.Yii-Pdf.EYiiPdf“中,。这意味着您的扩展文件夹包含yii pdf作为目录

然后,从下载mpdf,并将其作为protected/vendors/mpdf放置在vendors中,如中所示

'librarySourcePath' => 'application.vendors.mpdf.*',
所有的解释都是错误的