I have this working fine from Linux command line:
wkhtmltopdf entry.html output.pdf
But the following doesn't work from PHP code:
exec ('wkhtmltopdf entry.html output.pdf');
Interesting, I've googled and a lot of non-checked solutions and with no explanation why this is a problem. Thanks if you have the good ones.
Open a command prompt window. The syntax for using the tool is fairly simple, enter the name wkhtmltopdf, followed by the URL of the web page, and the name of the PDF that you want to create, like so.
had the same problem and i don't think anyone else should waste > 3 hours:
the solution is here: wkhtmltopdf error in apache log
you just have to install xvfp "to emulate a x-environment"
exec("xvfb-run -a wkhtmltopdf test.html output.pdf")
wkhtmltopdf has bindings, one of them is for PHP. You could give those a shot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With