Yii-PDF扩展错误

时间:2014-10-21 12:14:33

标签: php yii yii-extensions mpdf html2pdf

因此,正如我的标题所述,我正在使用YII_PDF EXTENSION,为此我遵循以下步骤:

  1. 从Git下载扩展程序。 See
  2. 将edpf扩展数组放在cpnfig / Main.php中。
  3. 将扩展文件放在目录扩展名中的Extenstions文件夹中。
  4. 下载mpdf& HTML2PDF并将代码放在Vendors文件夹中。
  5. 当我运行以下代码时:

    $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)
                    )*/
                )
            )
        ),
    

1 个答案:

答案 0 :(得分:0)

我假设你放在扩展文件夹中。所以,它应该是这样的。 ext表示protected-> extensions文件夹

 //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.*',