php - wkhtmltopdf 为每个创建的 pdf 写入 apache 错误日志

标签 php apache pdf wkhtmltopdf error-log

每次在 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 静音:

  1. 使用--quiet标志:

     exec("wkhtmltoimage -q …");
    
  2. 并根据 2>/dev/null 或类似的 shell 功能重定向 stderr:

     exec("wkhtmltopdf -q … 2>&1");
    

顺便说一句,后者适用于大多数命令行工具。

关于php - wkhtmltopdf 为每个创建的 pdf 写入 apache 错误日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31221196/

相关文章:

javascript - 动态设置全局 JS 变量

php - 如何从 php 用户输入创建 redis key ?

php - PHP 中的 HTTP 摘要身份验证

java - "Find Tag from Selection"在标记的 pdf 中不起作用?

java - PDFBox使用adbe.x509.rsa_sha1时在签名字典中指定cert

java - 在java中合并pdf的最佳方法是什么

php - 在 PHP 中返回 1970 年

python - 使用子路径在 Apache 反向代理后面重定向 Flask 登录

apache - 向 .htaccess 添加注释

java - 如何将此 Apache 重写规则转换为 Tuckey UrlRewriteFilter 规则?