每次在 WKHTMLTOPDF(使用 php)中创建 PDF 时,我都会在 apache 错误日志中收到以下内容:
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==========> ] 17%
[===================> ] 32%
[==============================> ] 50%
[=====================================> ] 63%
[============================================> ] 74%
[============================================================] 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
然而,创建的 pdf 没有任何错误,有没有办法阻止这种情况,因为错误日志变得非常大,并且还掩盖了真正的错误?
谢谢
最佳答案
专门让 wkhtmltopdf 静音:
使用
--quiet
标志:exec("wkhtmltoimage -q …");
并根据
2>/dev/null
或类似的 shell 功能重定向 stderr:exec("wkhtmltopdf -q … 2>&1");
顺便说一句,后者适用于大多数命令行工具。
关于php - wkhtmltopdf 为每个创建的 pdf 写入 apache 错误日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31221196/