0

I have a PHP file that creates a pdf fill form and uses pdftk to merge the data into the template.

I am having trouble getting php to execute the batch file in order to run the program and merge it.

$current = '\\oma-entfs-002\aps\wwwroot\tuition\uploads\';

My PHP code:

        $WshShell = new COM("WScript.Shell");
        $WshShell->exec($current.'makePDF.bat ' .$fdf_file.' '.$newPDF); 

The Batch File:

pushd \\oma-entfs-004\APS\wwwroot\tuition
pdftk uploads/Educational_Assistance_Request_Form_North_America.pdf fill_form uploads/%1 output uploads/%2 need_appearances
popd

Both COM and Exec are enabled on the server as far as I can tell.

When I run the batch file from command line, it works just fine so I think there is something with PHP not running the file correctly.

Any suggestions on the best way to debug this and identify the root cause?

SBB
  • 8,560
  • 30
  • 108
  • 223
  • is your path correct? did you try using `__dir__` and than relative path? like: `$current = __dir__ . '/uploads/'` or if the folder is not inside the dir where you run it than `__dir__ .'/../uploads/'` – Laci K Oct 22 '14 at 23:22
  • `__dir__` is providing the same output as I am currently getting in the example – SBB Oct 22 '14 at 23:24
  • ok, than did you try `cmd.exe /c yourpath/file.bat` or maybe try `$WshShell->run()` – Laci K Oct 22 '14 at 23:46
  • I think the issue is that `pdftk` is installed on the web server but the location of where the batch file is located is on a file share that doesn't have the plugin installed. So when referencing `C:\PDFtk\bin\pdftk.exe` or `pdftk` its not installed on the same server as where the batch file is located – SBB Oct 23 '14 at 00:00
  • Its possible, you could try creating the batch with php and exec it, this way you will run it where the pdftk is installed. – Laci K Oct 23 '14 at 00:16
  • Related, [How do you run a .bat file from PHP?](http://stackoverflow.com/q/835941) – jww Nov 15 '16 at 04:06

0 Answers0