dprfe04886 2012-05-09 18:28
浏览 78
已采纳

使用dompdf和codeigniter的问题

I have started experimenting with codeigniter and pdfs. I'm using the latest version of both. For some reason, i'm getting this error when trying to render the pdfs:

Warning: require_once(C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php) [function.require-once]: failed to open stream: No such file or directory in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208

Fatal error: require_once() [function.require]: Failed opening required 'C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php' (include_path='.;C:\php\pear') in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208

Code used is:

function pdf()
    {
         $this->load->helper(array('dompdf', 'file'));
         // page info here, db calls, etc.     

         /*
         $data=array(
         "$title"=>"Hello!",
         "$test_questions"=>"1,2,3,4",
         );
         */

        $data['test_questions']= "hello";


         $html = $this->load->view('pdf/test_ibdp', $data, true);

         $filename="Test".$data['test_questions'];

         pdf_create($html, $filename);
         write_file('name', $data);

    }   

And the helper:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename, $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper("a4", "portrait" );
    $dompdf->render();
    $dompdf->stream($filename . ".pdf");
}
?>  

and the view (pure HTML)

<html>
<head>
<title>Hello!</title>
</head>
<body>
    <h1>HelloAgain</h1>
</body>
</html>

Any suggestions? I'm not that experienced in PHP and i'm quite confused. I just re-downloaded the library, i've tried keeping it really simple by stripping away extras in my code. Nothing seems to work. any help would be great :)

  • 写回答

4条回答 默认 最新

  • duanjianl183188 2012-05-12 16:55
    关注

    This is a class autoloader issue. Which version of DOMPDF do you use? I think dompdf 0.5 had a problem when integrated inside a framework like CI. The 0.6 version doesn't have this probleme anymore, and if the problem persists, write

    define("DOMPDF_AUTOLOAD_PREPEND", true)
    

    in dompdf_config.custom.inc.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?