1

Running on windows7, using wkhtmltopdf to generate a pdf from our site works fine from a command prompt. Running the exact same wkhtmltopdf command from a servlet running in jetty via commons-exec results in a blank pdf.

I've turned on the accesslog valve on our site as well as installed netmon on win7, and I can clearly see that the web request to our site itself is being generated when invoked from the command prompt, but isn't being generated at all from the jetty-launched process.

I've examined the event logs with Event Viewer on win7, but I don't see any security exceptions or such that might explain the empty pdf. The fact that it is generating a pdf implies that the wkhtmltopdf executable is being invoked correctly.

Any ideas what might be causing wkhtmltopdf to not have http access?

4

1 回答 1

2

解决了它,以防其他人遇到这个问题:虽然 wkhtmltopdf 可执行文件运行良好,但它在没有任何环境变量的情况下启动,这导致 http 请求静默失败(或者至少以我从未发现的方式失败)。更改进程启动器以将所有环境变量从启动进程复制到 wkhtmltopdf 进程解决了该问题。

请注意,我最终通过将 wkhtmltopdf 包装在 bat 脚本中并在其中打印出 env vars 和其他状态来解决此问题。不得不重新编写我的 bat 脚本,但这是值得的。

于 2010-11-23T03:33:41.157 回答