Wkhtml library doesn't accept second parameter in url?

I use the wkhtml library to generate html in pdf, but it does not accept the second parameter in the url?

exec('C://"Program Files"//wkhtmltopdf.exe ' . 'http://localhost/test.php?a=351&b=2' . ' ' . $file_name . ''); 

Any ideas?

+4
source share
2 answers

Try setting the command to a variable, repeat it and try directly from the executable file, not from PHP. This may give a readable error.

Also, try putting the url in quotes, I just tried the following command and it worked perfectly

 wkhtmltopdf.exe "https://www.google.com/search?hl=fi&safe=off&biw=1195&bih=732&site=imghp&tbm=isch&sa=1&q=test&oq=test" test.pdf 
+5
source

I suggest using escapeshellarg () (escapes and causes the problem as a reserved character for shell commands)

 $print_url = escapeshellarg("http"//site.com/print_page.php?arg1=$arg1&arg2=$arg2"); 

then

 $print = exec("/usr/bin/wkhtmltopdf -T 0 -B 0 -L 0 -R 0 $print_url $path/$file 2>&1"); 
+1
source

All Articles