I'm currently building a class in PHP that generates PDF documents using the WKHTMLTOPDF command line app.
To do this, I'm using a call to shell_exec to call the WKHTMLTOPDF executable. However, this particular call does not seem to be executed; it returns NULL almost instantly.
A small test I did gave me the following results:
var_dump(shell_exec('ping nu.nl'));
// This prints a string, containting the expected output of the ping command
var_dump(shell_exec('"c:/wkhtmltopdf/wkhtmltopdf.exe" --orientation "Landscape" --page-size "A2" --margin-top "25mm" --margin-left "20mm" --margin-bottom "20mm" --margin-right "20mm" "http://www.nu.nl/" "C:/Temp/1280310218.pdf"'));
// This prints NULL
So, shell_exec()
seems to be working, also safe_mode
is off, and pasting the full command into cmd.exe does run the command properly.
If the problem isn't in either of the above (safe mode, a faulty command, or shell_exec()
itself) what else can it be? All I can think about is a user rights issue, but both the executable and the directory it's in have full access settings for every user group on my system.
(Note: Though I'm developing on a Windows machine, this code will run on a Linux server in production. Hence, windows-only solutions aren't what I'm looking for, unless ofcourse this problem itself turns out to be related to windows)