How to read xfdf fields in PHP - from submitted PDF

971 Views Asked by At

I am submiting a PDF form (xfdf format) to a php script. Then php saves the file (xfdf) & emails (as an attachment) to some email. I would like to be able to extract two fields from xfdf file (sender name & email), to use as "from:" on the email that contains the xfdf attachment. I do not need all the field, and I know the fields names. I would like to use simple php without installing any other library if possible.

Thank you in advance

1

There are 1 best solutions below

0
On

XFDF files are XML files (see Adobe XFDF Spec 3.0).

PHP has a number of libraries that will allow you to extract data from XML files. Check your server setup which of these libraries are available in your installation. Since you have gotten the XFDF upload and the email sending working already, all you need to do is this:

  • open the uploaded file
  • read its contents
  • parse the xml
  • extract the data you need

The exact steps are going to depend on the contents of your XFDF files and on the library of your choice.