【问题标题】:HTML to PDF Creation in Cakephp在 Cakephp 中创建 HTML 到 PDF
【发布时间】:2013-12-21 17:23:22
【问题描述】:

路径:供应商/dompdf

我收到致命错误:第 313 行的 C:\wamp\www\sms_app\app\Controller\SentMessagesController.php 中找不到类 'DOMPDF'。

为什么我会出错?这是我的代码:

function example()
    {   
        //App::import('Vendor','dompdf',array('file'=>'dompdf'.DS.'dompdf_config.inc.php'));
        require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
        $html =
        '<html><body>'.
        '<p>Put your html here, or generate it with your favourite '.
        'templating system.</p>'.
        '</body></html>';
        try{
            $this->dompdf = new DOMPDF();
        }
        catch (Exception $e)
        {
            echo $e;
        }
        $papersize = "legal";
        $orientation = 'landscape';
        $this->dompdf->load_html($html);
        $this->dompdf->set_paper($papersize, $orientation);
        $this->dompdf->render();
    
        $output = $this->dompdf->output();
        file_put_contents('Brochure.pdf', $output);
    
    }

【问题讨论】:

  • 您可能需要确定应该加载类DOMPDF 并确保该类在使用之前存在,即debug around here
  • 我建议你使用美妙的CakePDF插件。

标签: php cakephp


【解决方案1】:

错误消息非常清楚地告诉您出了什么问题。如果该文件中存在该类,请检查您包含的文件,我怀疑它是否存在。如果不知道该类在哪个文件中并加载该文件。检查 Dompdf 如何加载其文件。

【讨论】:

    【解决方案2】:

    此错误明确表示您缺少一个类,因此请检查您的代码中实际导入类的方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-20
      • 2013-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多