Yii PDF扩展出现错误


Yii-PDF Extension Gives Error

因此,正如我的标题所说,我正在使用YI_PDF EXTENSION,为此,我必须遵循以下步骤:

  1. 从Git下载扩展。请参阅
  2. 将edpf扩展数组放入cpconfig/Main.php中
  3. 将扩展名文件放在扩展名目录中的extensions文件夹中
  4. 下载mpdf&HTML2PDF并将代码放在Vendors文件夹中

当我运行以下代码时:

$html2pdf = Yii::app()->ePdf->HTML2PDF();
$html2pdf->WriteHTML($this->renderPartial('analysis_report_pdf', array(), true));
$html2pdf->Output();

比它给我错误

未定义属性"CWebApplication.ePdf"。

请帮帮我哪里错了。

更新时间:请参阅我在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
                /*'defaultParams'     => array( // More info: http://mpdf1.com/manual/index.php?tid=184
                    'mode'              => '', //  This parameter specifies the mode of the new document.
                    'format'            => 'A4', // format A4, A5, ...
                    'default_font_size' => 0, // Sets the default document font size in points (pt)
                    'default_font'      => '', // Sets the default font-family for the new document.
                    'mgl'               => 15, // margin_left. Sets the page margins for the new document.
                    'mgr'               => 15, // margin_right
                    'mgt'               => 16, // margin_top
                    'mgb'               => 16, // margin_bottom
                    'mgh'               => 9, // margin_header
                    'mgf'               => 9, // margin_footer
                    'orientation'       => 'P', // landscape or portrait orientation
                )*/
            ),
            'HTML2PDF' => array(
                'librarySourcePath' => 'application.vendors.html2pdf.*',
                'classFile'         => 'html2pdf.class.php', // For adding to Yii::$classMap
                /*'defaultParams'     => array( // More info: http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:accueil
                    'orientation' => 'P', // landscape or portrait orientation
                    'format'      => 'A4', // format A4, A5, ...
                    'language'    => 'en', // language: fr, en, it ...
                    'unicode'     => true, // TRUE means clustering the input text IS unicode (default = true)
                    'encoding'    => 'UTF-8', // charset encoding; Default is UTF-8
                    'marges'      => array(5, 5, 5, 8), // margins by default, in order (left, top, right, bottom)
                )*/
            )
        )
    ),

我假设您放置在扩展文件夹中。所以,应该是这样的。ext表示为受保护->扩展文件夹

 //For mpdf
 'librarySourcePath' => 'application.ext.mpdf.*', //if your are placed under vendor 'librarySourcePath' => 'application.ext.vendors.mpdf.*',  
  //For HTML2PDF
 'librarySourcePath' => 'application.ext.html2pdf.*',  //or 'librarySourcePath' => 'application.ext.vendor.html2pdf.*',

如果你把HTML2PF放在供应商文件夹下,它看起来像

 'librarySourcePath' => 'application.vendor.html2pdf.*',