wkhtmltopdf with javascript-delay not working

Deadly 提交于 2019-12-08 02:14:32

问题


The pdf that is created using the code below hasn't finished rendering the javascript so javascript was preformed on half of the tables (say if there are 100 tables then sometimes 50 are done, other times 52, 54 etc).

I'm using the flag --javascript-delay 40000 in trying to delay the retrievement of the page but the results are the same. It's still pulling the trigger too fast. I know this is the issue because when I use the browser everything works correctly.

How can I set the delay properly? Maybe shell_exec is at fault here?

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

EDIT:

using the version:

wkhtmltopdf-0.11.0_rc1

回答1:


Found the problem after searching for hours. wkhtmltopdf stops slow scripts:

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)

So I needed to use the flag --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


来源:https://stackoverflow.com/questions/15837932/wkhtmltopdf-with-javascript-delay-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!