-
Notifications
You must be signed in to change notification settings - Fork 22
Troubleshooting
andrewheiss edited this page Aug 17, 2010
·
5 revisions
This generally happens for two reasons: (1) the script cannot generate the temporary fdf file, and (2) the server wasn’t able to successfully run pdftk.
1. fdf generation:
- Comment out unlink() (near line 74) to disable the automatic deletion of the temporary pdf file. Run the script and see if any temporary file was made.
- Make sure the folder specified in
tempnam()
(near line 58) is writable by the server. The default directory is . or the current script directory. Runchmod 755
on the folder to guarantee it is writable. - Make a temporary folder (like ./tmp), set the proper permissions (755), and change the path in
tempnam()
to match. - Some server configurations require that folders are owned by the Apache or PHP user to write to them, regardless of the set file permissions. You may need to
chown
the temporary folder to web, www, apache, or whatever your host requires.
2. Running pdftk:
- pdftk must be installed on your server to run properly. In a Windows environment, this is easy: download the standalone .exe file and place it in your project folder somewhere. It’s a little more complicated with Linux servers. Download and install the appropriate build for your distribution and type
whereis pdftk
at a terminal to see where it is installed system-wide (generally/usr/local/bin/pdftk
). You can also compile the program from source, but since it relies on the Javagcj
libraries, it can take a while. - On a shared Linux hosting environment, it can be difficult to install pdftk. Because of security considerations, you might not be allowed to install it. See web hosts with pdftk.
- Set the path to pdftk found in
passthru()
(near line 71) to match your installation. Use an absolute path for more reliability (/usr/local/bin/pdftk
orc:\Program Files\www\pdftk.exe
rather than../pdftk
) - Create a php file with the following code:
<?php passthru("/path/to/pdftk --help"); ?>
- Run the script in your browser. You should see the manual page for pdftk. If you can’t, there’s a problem with the path to pdftk. Verify the path is correct and try again.
If you can successfully run pdftk from the browser, but can’t merge the actual fdf with the pdf form, make sure the fdf file is generated properly.
If you can run pdftk and the fdf is generated, there is likely a problem with your PDF file.
- Make sure your PDF was not created on a Mac (see known issues)
- pdftk can’t handle many of the newer versions of the PDF standard. Save your PDF as version 1.5 and try again.
- Check your version of pdftk (type
pdftk --version
at the terminal) and upgrade to the latest version (1.41 currently)