【问题标题】:IIS output results "QFontEngineWin failure" when running wkhtmltopdf process from PHP从 PHP 运行 wkhtmltopdf 进程时,IIS 输出结果“QFontEngineWin 失败”
【发布时间】:2019-07-11 15:11:22
【问题描述】:

运行 php 脚本时我的 IIS 服务器结果 QFontEngine failure

基本上我有从 html 生成 pdf 的 laravel web 应用程序,它在幕后使用类似这样的东西

<?php 

use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
require __DIR__ . '/vendor/autoload.php';


$process = Process::fromShellCommandline('wkhtmltopdf --lowquality "C:\WINDOWS\TEMP\test.html" "C:\WINDOWS\TEMP\test.pdf"', null, null);
$process->run();

// executes after the command finishes
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}

echo $process->getOutput();

如果通过 IIS Web 服务器运行以下脚本,该命令的输出如下:

Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==============================> ] 50%
QFontEngine::loadEngine: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
[============================================================] 100%
Counting pages (2/6) 
[============================================================] Object 1 of 1
Resolving links (4/6) 
[============================================================] Object 1 of 1
Loading headers and footers (5/6) 
Printing pages (6/6)
[> ] Preparing
[============================================================] Page 1 of 1
Done 

如果我像 php index.php 这样在终端内运行此脚本,则不会出现 QFontEngine 失败和作业成功等错误。

我已经检查了这个问题“Issue running 32-bit executable on 64-bit Windows”,但我的字体服务正在运行,所以我什至不知道在哪里寻找解决方案?

提前谢谢你。

【问题讨论】:

  • “但是我的字体服务正在运行” - 不是那个服务给你这些错误吗?另外,您是否尝试过该帖子中的解决方案?
  • 错误输出来自名为 wkhtmltopdf 的应用程序。我检查了我的字体服务,它运行时没有任何错误。

标签: php iis windows-10 wkhtmltopdf


【解决方案1】:

我从 Linux 发行版中知道 wkHtmlToPdf 有两种编译形式:一种无需图形终端(“无头”)即可工作,另一种则没有。我可以假设您有一个没有图形终端就无法工作的软件,并且 IIS 环境正在以无窗口模式(即没有图形终端)运行 wkhtmltopdf。您是否尝试过 https://wkhtmltopdf.org/downloads.html 上的二进制文件?缺少指标与没有显示上下文来获取指标是一致的。

【讨论】:

  • 我尝试了 32/64 位版本,但它有点无关紧要,因为它们只有两个 Windows 版本。
  • 如果这两个都不起作用,您有两个选择:尝试将 wkhtml 作为桌面进程运行(也许从这个讨论开始:forums.iis.net/t/1233510.aspx)或将问题发送到 wkhtmltopdf.org/support.html 并查看如果他们在 Windows 上无头运行就知道了。
  • 我以前工作过。它最近无缘无故地开始这样做了。
  • 如果我从终端运行它,它可以正常工作。
  • 是的,但是终端是一个窗口桌面进程,它有显示上下文。 IIS 没有窗口/桌面上下文。
猜你喜欢
  • 1970-01-01
  • 2013-01-29
  • 2012-08-13
  • 2017-02-04
  • 1970-01-01
  • 2014-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多