Hi,
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):
doc.pdf
out.fdf
pdftk.exe
And created a PHP script with the following:
<?php
make_pdf();
function make_pdf()
{
// Send a force download header to the browser with a file MIME type
header("Content-Type: application/force-download
");
header("Content-Dispositio
n: 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?