PHPExcel和Mpdf不生成文件

时间:2016-09-05 13:38:32

标签: php phpexcel mpdf

我使用PHPExcel生成模板,然后我希望使用Mpdf将其转换为PDF文件。我使用PHPExcel 1.7.8和Mpdf 6.0

但问题在于

  1. 未生成PDF文件
  2. 浏览器想要显示生成的文件。
  3. 我的代码

        $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
        $rendererLibrary = 'mpdf';
        $rendererLibraryPath = APPPATH.'plugins/' .
        $rendererLibrary;
        if (!PHPExcel_Settings::setPdfRenderer(
                     $rendererName,
                     $rendererLibraryPath
               )) {
               die(
                     'Please set the $rendererName and $rendererLibraryPath values' .
                     PHP_EOL .
                     ' as appropriate for your directory structure'
        ); }
    
        $filename = "DWG Register.pdf"; //save workbook to a file name
    
        header('Content-Type: application/pdf'); //mime type
        header('Content-Disposition: attachement;filename="'.$filename.'"'); //tell browser what's the file name
        header('Cache-Control: max-age=0'); //no cache
    
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF');          
        $objWriter->setSheetIndex(0);
        $objWriter->save('php://output');
        exit;
    

0 个答案:

没有答案