Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKHTML + Windows + PHP

I installed wkhtml from here http://code.google.com/p/wkhtmltopdf/downloads/list (specically the wkhtmltox-0.11.0_rc1-installer.exe for Windows). I called ir from the command line and it worked perfect, but when I try to call it using the PHP exec or shell_exec function, it only works if the wkhtmltopdf.exe is located in the same directory my php is.

So, if I do this:

exec("wkhtmltopdf c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf"); 

and the wkhtmltopdf file is in the c:/wamp/www/test directory it works perfect, but if I do this:

exec("C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf");

it doesn't work at all.

Can you help me? I'd like to make it work even when it's in another directory.

Thanks.

like image 982
user1132585 Avatar asked Feb 22 '23 15:02

user1132585


1 Answers

You have to put the path in quotes beacause of the space.

exec('"C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe" c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf');

Alternatively you could just add the wkhtmltopdf directory to your PATH variable.

like image 155
Jona Avatar answered Mar 02 '23 19:03

Jona