WKHTML + Windows + PHP

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

So, if I do this:

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

and the wkhtmltopdf file is located in the c: / wamp / www / test directory, it works fine, 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 would like to make it work, even if it is in a different directory.

Thanks.

+4
source share
3 answers

You must put the path in quotation marks because of a space.

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

Alternatively, you can simply add the wkhtmltopdf directory to your PATH variable.

+5
source

Using Snappy will make life easier for creating pdf using wkhtmltpdf

+2
source

change your exec coding as this.it works for me. :)

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

Happy coding ... :) :)

0
source

Source: https://habr.com/ru/post/1394427/


All Articles