weixin_33736832 2015-04-29 06:54 采纳率: 0%
浏览 47

HTML到PDF转换器dompdf

I want to use dompdf i've downloaded from github and extracted on my webserver but i face error as, (i'm on windows).I also tried this but didn't help

      define('DOMPDF_ENABLE_AUTOLOAD', false);

     <br />
     <b>Fatal error</b>:  Class 'DOMPDF' not found in           

     <b>C:\xampp\htdocs\Rental\controlleregister.php</b> on line <b>38</b><br />

here's my code

    if(!empty($_POST['pr_data'])){
$pr_dt=$_POST['pr_data'];
require_once("../assets/converter/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($pr_dt);
$dompdf->render();
$dompdf->stream("sample.pdf");
echo $dompdf;
exit;
}


   jQuery('.btn-print').click(function() {
   var pr_data = jQuery('.tc').html();
   jQuery.post('../controller/register.php', {
     'pr_data': pr_data
   }, function(result) {
   console.log(result);
  });
  });

I downloaded dompdf from dompdf i didn't use composer for installing i've used third one Download and extract

UPDATE I've also tried checking whether dompdf file path is correct

   if(!@include("../assets/converter/dompdf/dompdf_config.inc.php")) throw new Exception("Failed to include 'script.php'");

and check whether class exist

if (class_exists('dompdf'))
     { 
        echo "class exist";
     }
     else{
        echo "does not exist";
     }

 if (is_file("../assets/converter/dompdf/dompdf_config.inc.php"))
    {
        echo "PATH is CORRECT";
        require_once("../assets/converter/dompdf/dompdf_config.inc.php");
    }

now the output

      does not exist PATH is CORRECT
      Fatal error: Class 'DOMPDF' not found in            
       C:\xampp\htdocs\Rental\view\createMRA.php on line 83

Update

I'm able to download a corrupt pdf why so?

        Fatal error: Class 'Font' not found in C:\xampp\htdocs\Rental\assets\converter\dompdf\include\font_metrics.cls.php on line 346
  • 写回答

1条回答 默认 最新

  • weixin_33739523 2015-04-29 09:51
    关注

    Try including this file DOMPDF_INC_DIR/dompdf.cls.php to your working file. This is where the DOMPDF class is defined.

    Hope this would resolve your issue.

    -Naim

    评论

报告相同问题?

悬赏问题

  • ¥25 matlab数值溢出该怎么解决?
  • ¥15 大家帮我看看为什么错了
  • ¥15 unity互动琴弦抖动效果
  • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
  • ¥15 nginx无证书访问https失败
  • ¥15 树莓派启动AP热点传入数据
  • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)
  • ¥15 在误装Windows server2019 后如何利用Windows.old恢复?
  • ¥20 代码实现状态连接包过滤防火墙的设计与实现
  • ¥15 vscode的红色箭头爆红和has no default export报错