Filling in PDF Form Fields with PHP
In developing a website, most developers are familiar with the HTML language necessary to any web page. They know they can also add control elements, make the website dynamic or store data in the database by using programming languages such as, PHP, Java, Ruby, Python, and so forth...
I would like to share with everyone my experiences about submitting a form from a PDF document to a PHP environment. If you wonder how a PDF form can interact with PHP then you have selected the right article! It is quite easy!
1. How does the PDF interact with PHP?
First, you need to create a PDF form which contains text boxes and a "submit" button. Beware each field has to be named because it will be used when the form is submitted. Actually, it is similar to how it is done in HTML. To do this, you should already have the Adobe Acrobat Professional installed in your computer.
When the form is submitted, the data is passed to a function along with the location of the PDF file. The function returns some XML content of a FDF file which is a format for handling forms within PDF documents. When the user download the FDF file, it will get the PDF form that contains the data from FDF. If you would like more information about FDF, you could read this documentation.
2. How easy is it to use?
In my opinion, it is not a complicated code to read and write. Currently, there are two libraries "createFDF" and "createXFDF" that provide simple PHP functions which can get the data and write it into the FDF form. You can also download the zip file for more details.