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

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置