mpdf 输出生成错误检测到错误。PDF 文件生成中止:指令"allow_url_include"已弃用



我正在编写一个wordpress插件,并创建一个生成发票并通过电子邮件发送发票的函数。生成PDF文件时出现问题。每次尝试生成PDF文件都会以错误结束:检测到错误。PDF生成中止:";allow_url_include";指令已弃用

我的代码:

$defaultConfig = (new MpdfConfigConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new MpdfConfigFontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
try {
$mpdf = new MpdfMpdf([
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/mpdf2/vendor/mpdf/mpdf/ttfonts',
]),
'fontdata' => $fontData + [
'roboto' => [
'R' => 'Roboto-Regular.ttf',
'B' => 'Roboto-Bold.ttf',
]
],
'mode' => 'UTF-8',
'format' => 'A4',
'default_font_size' => '12',
'default_font' => 'roboto',
'margin_left' => 25,
'margin_top' => 25,
'margin_right' => 25,
'margin_bottom' => 25,
'debug' => true,
]);
$dir = plugin_dir_path(__DIR__);
$mpdf->SetDisplayMode('fullwidth');
$mpdf->WriteHTML($html);
$mpdf->Output($dir . 'haccp/invoice_pdf/' . $invoice_name, 'F');
} catch (MpdfMpdfException $e) { // Note: safer fully qualified exception name used for catch
// Process the exception, log, print etc.
echo $e->getMessage();
}

mPDF在升级到PHP 7.4后,在ini_set调用或PHP配置(PHP.INI文件、.htaccess、服务器配置(中捕获到一个由您设置allow_url_includeINI变量引起的错误。

删除allow_url_include设置更改或回滚到PHP 7.3,或者禁用不推荐使用的警告。

请参阅https://www.php.net/manual/en/filesystem.configuration.php

相关内容

最新更新