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 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同