We help IT Professionals succeed at work.
Get Started

How to run a remote exe using php

Last Modified: 2012-05-09

I need to be able to fill in fields within a precreated PDF document using PHP. I have worked out how to do this from the command line using info from this page: http://stackoverflow.com/questions/77873/filling-pdf-forms-with-php

The command line I am using is:

pdftk doc.pdf fill_form out.fdf output out.pdf flatten

This executes pdftk.exe and takes my document and fills it in using the info stored in out.fdf. The resulting PDF is saved as out.pdf.

The next step was to get it working using PHP. I uploaded the following files to my remote server (into one folder):


And created a PHP script with the following:


function make_pdf()
      // Send a force download header to the browser with a file MIME type
      header("Content-Type: application/force-download");
      header("Content-Disposition: attachment; filename=\"out.pdf\"");
      // Actually make the PDF by running pdftk - make sure the path to pdftk is correct
      // The PDF will be output directly to the browser - apart from the original PDF file, no actual PDF wil be saved on the server.
      passthru("pdftk doc.pdf fill_form out.fdf output - flatten");

Ran the script... no output at all. Just a blank page. I also tried using exec() and shell_exec(). No joy apart from a return code of 127...

I checked that the exe file was executable (chmod 755). Still no joy... Does the exe have to be placed somewhere specific on the server?
Watch Question
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE