You should't be putting the quotes around the library.You can catch the output of the command this way:
$commandString = '../wkhtmltopdf/wkhtmltopdf-i386 http://www.estiroad.com/export.php file.pdf 2>&1';
$output = shell_exec($commandString);
The 2>&1
in UNIX will mean that the output will come through. 1 is stdout. 2 is stderr.
Hope this helps.
Or in windows
$commandString = '../wkhtmltopdf/wkhtmltopdf.exe http://www.estiroad.com/export.php file.pdf 2> output';
print $out ? $out : join("", file("output"));
From the permission issue it looks like you're running the production script on linux. Go to your production server and run
$ uname -a
You'll get something like:
Linux ora100 2.6.5-7.252-smp #1 SMP Tue Feb 14 11:11:04 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
the x86_64 suggest you're running a 64 bit CPU, if that's the case download the amd64 version of binary, otherwise download the i386 one. Both can be obrained from this url: http://code.google.com/p/wkhtmltopdf/downloads/list
Keep the windows binary. Have you got a config file? if you do make sure you have a switch where you assign your library path to a constant based on your environment.
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// this is windows server
define('WKHTML_LIB', "../wkhtmltopdf/wkhtmltopdf.exe");
} else {
// or the 64 bit binary?
define('WKHTML_LIB', "../wkhtmltopdf/wkhtmltopdf-i386");
}
Then change your code that initiates wkhtmltopdf:
$commandString = WKHTML_LIB' http://www.estiroad.com/export.php file.pdf 2> output';
print $out ? $out : join("", file("output"));