PHPExcel PDF 库尚未定义
PHPExcel PDF Library has not been defined
我这辈子都无法让 PHPExcel 查看我的 PDF 库。
这是我目前拥有的:
$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererLibrary = 'mPDF5.4';
$rendererLibraryPath = dirname(__FILE__).'/mpdf/' . $rendererLibrary;
// Here's the magic: you __tell__ PHPExcel what rendering engine to use
// and where the library is located in your filesystem
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
$rendererLibraryPath
)) {
die(
'Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
' as appropriate for your directory structure'
);
}
$objWriter = new PHPExcel_Writer_PDF($objPHPExcel);
$objWriter->save("test.pdf");
我的 "mpdf" 文件夹位于该项目文件夹的根目录中,我的相关 php 文件也是如此。
但在浏览器中我一直看到:
Please set the $rendererName and $rendererLibraryPath values as
appropriate for your directory structure
我已经阅读了 documentation 的相关部分,但我不明白为什么我的 php 脚本看不到我的 pdf 库。
PHPExcel 代码仅在此处进行两项检查:名为 dirname(__FILE__).'/mpdf/mPDF5.4
的文件夹是否存在(使用 file_exists() call); and that it is readable (using is_readable())....其中一项检查失败。
检查该文件夹的权限
我发现将 'die' 更改为 'echo' 有助于找到我在 $rendererLibraryPath
中遇到的问题
我这辈子都无法让 PHPExcel 查看我的 PDF 库。
这是我目前拥有的:
$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererLibrary = 'mPDF5.4';
$rendererLibraryPath = dirname(__FILE__).'/mpdf/' . $rendererLibrary;
// Here's the magic: you __tell__ PHPExcel what rendering engine to use
// and where the library is located in your filesystem
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
$rendererLibraryPath
)) {
die(
'Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
' as appropriate for your directory structure'
);
}
$objWriter = new PHPExcel_Writer_PDF($objPHPExcel);
$objWriter->save("test.pdf");
我的 "mpdf" 文件夹位于该项目文件夹的根目录中,我的相关 php 文件也是如此。
但在浏览器中我一直看到:
Please set the $rendererName and $rendererLibraryPath values as appropriate for your directory structure
我已经阅读了 documentation 的相关部分,但我不明白为什么我的 php 脚本看不到我的 pdf 库。
PHPExcel 代码仅在此处进行两项检查:名为 dirname(__FILE__).'/mpdf/mPDF5.4
的文件夹是否存在(使用 file_exists() call); and that it is readable (using is_readable())....其中一项检查失败。
检查该文件夹的权限
我发现将 'die' 更改为 'echo' 有助于找到我在 $rendererLibraryPath
中遇到的问题