doujia2090 2015-03-02 08:33
浏览 175

使用dompdf库在PHPExcel中生成pdf文件

Using dompdf library generate the pdf file, while i opened that pdf file it shows failed to load content error. I set renderer path and renderer library given below.

$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF; $rendererLibrary = 'dompdf.php'; $rendererLibraryPath = name(FILE).'/../dompdf/libraries/dompdf/'.$rendererLibrary;

  • 写回答

2条回答 默认 最新

  • douqi3913 2015-03-02 12:12
    关注

    Try this

    $rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
    $rendererLibrary = 'dompdf.php';
    $rendererLibraryPath = dirname(__FILE__). 'libs/classes/dompdf' . $rendererLibrary;
    

    Correct your PHP according to this

    $file = "path_to_file";
    $fp = fopen($file, "r") ;
    
    header("Cache-Control: maxage=1");
    header("Pragma: public");
    header("Content-type: application/pdf");
    header("Content-Disposition: inline; filename=".$myFileName."");
    header("Content-Description: PHP Generated Data");
    header("Content-Transfer-Encoding: binary");
    header('Content-Length:' . filesize($file));
    ob_clean();
    flush();
    while (!feof($fp)) {
       $buff = fread($fp, 1024);
       print $buff;
    }
    exit;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序