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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退