I was struggling with the same problem.
My solution on a Windows 2008 R2
server with PHP 5.4
:
exec('C:\inetpub\wwwroot\mywebsite\subdir\wkhtmltopdf input.html output.pdf');
AND this was it (After > 5 hours searching the net including this) a new file called output.txt, renamed it to output.pdf and give the user 'everybody' rights to it.
These are my tryouts:
exec(C:\inetpub\wwwroot\mywebsite\wkhtmltopdf );
echo(exec(wkhtmltopdf.exe cache.html output.pdf));
exec("xvfb-run -a wkhtmltopdf test.html output.pdf")
$execute = "xvfb-run -a wkhtmltopdf cache.html output.pdf";
$out = shell_exec("/path/to/wkhtmltopdf --version"); echo($out);
$out = passthru('/usr/local/bin/wkhtml2pdf
Hope these are usefull to others
exec(/usr/bin/wkhtmltopdf ...)
, if the sub-shell invoked by PHP ends up having a different PATH setting than your standard default shell. As well, if you're doing the exec from within a web-based script, then permissions are going to be a factor as well. – Hunyadi