首页 > 解决方案 > 获取最新版本的 mPDF (7.1) 以使用 phpExcel?

问题描述

我将 mPDF v5.7.4 与 phpExcel 一起使用,它可以工作,但这似乎是开箱即用兼容的新版 mPDF。

我将 mPDF 包含在这些行中:

$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererLibraryPath = dirname(__FILE__) . '/mpdf';

if (!PHPExcel_Settings::setPdfRenderer(
        $rendererName,
        $rendererLibraryPath
    )) {
    die(
        'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
        '<br />' .
        'at the top of this script as appropriate for your directory structure'
    );
}

// Redirect output to a client’s web browser (PDF)
header('Content-Type: application/pdf');
header('Content-Disposition: attachment;filename="pdf.pdf"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); // $objPHPExcel is set before this whole code block
$objWriter->save('php://output');

但是最新版本(7.1)具有不同的文件结构,如果可能的话,我无法弄清楚如何包含它。有任何想法吗?

5.7.4 文件结构:

在此处输入图像描述

7.1 文件结构:

在此处输入图像描述

标签: phpphpexcelmpdf

解决方案


推荐阅读