0

I'm using PDFTK to merge some PDFs on my Amazon EC2 instance running Windows Server and IIS7.

When I try running PDFTK using PHP exec(), it does not work. For example:

<?php
$e = exec("pdftk");
var_dump($e); //output is: string(0) ""
?>

I can get other commands to work using exec such as exec("ping 192.168.2.1") but I can't get PDFTK working.

I can also run pdftk from DOS command line, so I know it's installed properly.

I also set the permissions to pdftk.exe to full access for all users (thinking this was a permissions issue).

I remember having a similar problem when I installed PDFTK on another Windows Server Amazon EC2 instance, but I forgot exactly what I needed to change. I thought it had something to do with IIS_USR Permissions but it was a while back and I don't remember the specifics.

Thank you.

user1855093
  • 373
  • 1
  • 2
  • 14
  • 1
    Is pdftk in the path of the script your are trying to run or found in a directory specified by the $PATH env variable? – datasage Jun 06 '13 at 13:29
  • datasage, I originally had pdftk.exe in my Windows/System32 directory. I moved it over to the directory my php script was in and sure enough, it now works. If you want to post it as an answer I will accept it. Thanks! – user1855093 Jun 06 '13 at 23:24

1 Answers1

1

The application either needs to be in the same directory as the script, or within the $PATH environment variable for the user executing the PHP script. With IIS, this is not the user you are logged in with.

datasage
  • 19,153
  • 2
  • 48
  • 54