Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf with javascript-delay not working

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
like image 739
Tom Avatar asked Apr 05 '13 15:04

Tom


1 Answers

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
like image 169
Tom Avatar answered Nov 05 '22 15:11

Tom