【问题标题】:wkhtmltopdf with javascript-delay not working带有javascript-delay的wkhtmltopdf不起作用
【发布时间】:2013-04-05 15:34:59
【问题描述】:

使用以下代码创建的 pdf 尚未完成 javascript 的呈现,因此 javascript 已在一半的表格上执行(例如,如果有 100 个表格,则有时完成 50 个,其他时候完成 52、54 个等)。

我正在使用标志--javascript-delay 40000 试图延迟页面的检索,但结果是相同的。它仍然太快地扣动扳机。我知道这是问题所在,因为当我使用浏览器时一切正常。

如何正确设置延迟?也许shell_exec 有问题?

$command = shell_exec("xvfb-run -a -s '-screen 0 640x480x16' wkhtmltopdf-i386 --dpi 300 --javascript-delay 40000 --page

编辑:

使用版本:

wkhtmltopdf-0.11.0_rc1

【问题讨论】:

    标签: php wkhtmltopdf


    【解决方案1】:

    搜索了几个小时后发现了问题。 wkhtmltopdf 停止慢速脚本:

    Loading pages (1/6)
    Warning: A slow script was stopped                                
    Counting pages (2/6)                                               
    Resolving links (4/6)                                                       
    Loading headers and footers (5/6)                                           
    Printing pages (6/6)
    

    所以我需要使用标志--no-stop-slow-scripts

    $command = shell_exec("xvfb-run -a -s '-screen 0 640x480x16' wkhtmltopdf-i386 --no-stop-slow-scripts --dpi 300 --page-size A4 $page /tmp
    

    【讨论】:

    • 感谢您发布此内容,我遇到了同样的问题!
    • --no-stop-slow-scripts--javascript-delay 40000 都为我做了这件事。谢谢。
    • 感谢@TheMightyLlama。如果没有 --javascript-delay 选项,它将无法工作。
    • @SungKim,我很高兴即使在将近三年后这也有所帮助。
    • @TheMightyLlama 和 Tom:感谢您的回复,过去 2 天一直在尝试使用 wkhtmltopdf 和 Twitter 推文嵌入来解决问题!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    • 1970-01-01
    相关资源
    最近更新 更多