The easiest way is to set up the form to submit to the PHP script using the same method and format as an HTML form would. So reading data submitted by a PDF form can be as simple as it is from an HTML form.
The difference is in the type of response that you'd send back. The best method is to return an FDF response that includes something the provides some feedback to the user. For example, it could cause a pop-up message to be displayed or fill a field in the form. This is the same idea as AJAX (and FDF can be considered analogous to JSON as they're both structured data interchange formats used for asynchronous client/server communication), and was the method PDF forms used before AJAX was ever available for use with a browser.
Note that this won't work with most non-Adobe PDF viewers since they don't support submitting to a web server, or correctly handling an FDF response, or both. It will work with the desktop versions of Adobe Reader/Acrobat, even when not using in a web browser. I wouldn't recommend this as something for the general public to use, but if you have a set of users that you can compel to use such a system, it can work well.
Thanks for the response George!
I have about 4-5 forms I need users to fill out. The end game is for the user to submit the first form, then have the contents of the first form fill out the second form.
I've already created a function for importing data to the PDF using FDF from my webserver. Works Great. The problem is going the other way (Exporting from PDF to webserver). I would prefer not to use FDF as it requires much slicing and dicing of all the extra characters. I would prefer to throw all form data into an array and pass it back to my webserver - as I already have a html/php form on my webserver to accept the array.
You said it's just like an HTML form. How would I reference the individuals fields ( textfields, checkboxes, dropdowns etc.)
1 person found this helpful
Take a look a the Doc.submitForm() API documentation: Acrobat DC SDK Documentation - Doc.submitForm()
The "cSubmitAs" parameter allows you to select - among other formats - "HTML", which will create a standard HTML forms submission, just like from a web form. All you do in PHP is use the $_POST array to reference the field data.
Keep in mind that besides FDF, there is also XFDF to submit data to the PHP script. XML is usually much easier to handle than FDF (but then again, in PHP, a HTML forms submission is built right into the system).