【问题标题】:Yii-PDF Extension Gives ErrorYii-PDF 扩展出错
【发布时间】:2014-10-21 12:14:33
【问题描述】:

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

  1. 从 Git 下载扩展。 See
  2. 将 edpf 扩展数组放入 cpnfig/Main.php 中。
  3. 将扩展文件放在Extensions文件夹中的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)
                )*/
            )
        )
    ),

【问题讨论】:

  • 你写的main.php是什么?
  • 请查看我更新的问题。

标签: php yii yii-extensions mpdf html2pdf


【解决方案1】:

我假设您放置在扩展文件夹中。所以,应该是这样的。 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 放在 vendor 文件夹下,它看起来像这样

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

【讨论】:

  • 我很确定我是在组件下的application/config/main.php中写的。
  • 如果您将扩展文件夹放入 mpdf,则不能以这种方式路由 application.vendor.mpdf.*。它指出受保护/供应商。不是扩展文件夹。
  • 否正如您在我的问题中看到的那样,我将 mpdf 和 Html2pdf 放在 vendor 文件夹中。
  • 是不是在'components'下面=>array(?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-05
  • 1970-01-01
  • 2013-03-19
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
相关资源
最近更新 更多