I am trying to get the below command to run but it is not running as far as I can tell because the file is not being generated. I am not getting any error messages at all, this command was working fine when I was testing it on my linux box but I am moving over my website to a windows box running xampp since I wont have an internet connection for a few days. So I am changing the command to work with windows. I think there must be an error in my command somewhere but since I have little experience with working with apache, php on windows I am hoping someone else can spot an error if there is one.
$command = 'C:\\Program Files (x86)\\PDF Labs\\PDFtk Server\\bin\\pdftk.exe C:\\xampp\\htdocs\\lc712\\pdf\\TimeCard.pdf fill_form C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.fdf' . ' output C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.pdf flatten';
exec($command);
This is the final code that works:
$command = '"C:\Program Files (x86)\PDF Labs\PDFtk Server\bin\pdftk.exe" C:\xampp\htdocs\pdf\TimeCard.pdf fill_form C:\xampp\htdocs\pdf\results\\' . $userName . '.fdf' . ' output C:\xampp\htdocs\pdf\results\\' . $userName . '.pdf flatten';
exec($command);
C:\Program Files (x86)\PDF Labs\PDFtk Server\bin\pdftk.exe
contains spaces, so Windows will try to execute C:\Program
with arguments Files
, (x86)\PDF
, Labs\PDFtk
, Server\bin\pdftk.exe
, ...
Try escaping the path with quotes:
$command = '"C:\\Program Files (x86)\\PDF Labs\\PDFtk Server\\bin\\pdftk.exe" C:\\xampp\\htdocs\\lc712\\pdf\\TimeCard.pdf fill_form C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.fdf' . ' output C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.pdf flatten';
exec($command);