tags:

views:

374

answers:

3

How can I find out the name of the fields in a PDF file using PHP?

The only thing I can think of is converting the PDF file to HTML, but that really sounds like overkill.

My end goal is to generate an FDF file (this bit I'm happy with) to populate the fields of a PDF file which I don't have control over, so I don't know what field names I need to use.

A: 

this might be what you are after http://www.setasign.de/products/pdf-php-solutions/fpdi/

bumperbox
A: 

I am also looking for same. I searched it lot, but i only got solution for html to pdf or text to pdf.

But no where i got solution for pdf to html. I hope here may i get answer

santosh
Looking inside a PDF file with notepad I've discovered that a text field is listed as "T/(Field-name)" however that's as far as I have gotten. Do share the answer here if you discover anything.
James
try this for pdf to html http://sourceforge.net/projects/pdftohtml
bumperbox
Thanks, but cntents in the generated html is not well formatted. and to run this it need to have root access to server to install it.
santosh
+2  A: 

If you are willing to use a command line tool, see

http://www.accesspdf.com/pdftk/

The pdftk command can generate an FDF file from a PDF form file.

pdftk formfile.pdf generate_fdf

The form fields are the portion of the output that looks like

...
<< /T(f1-1) /V(text of field) >>
<< /T(f1-2) /V(text of another field) >>
...
bmb