Skip to main content
Participating Frequently
April 26, 2018
Answered

Filling Form Dropdown with PHP/PDFtk

  • April 26, 2018
  • 3 replies
  • 3007 views

Hello, I would like to know if it is possible to dynamically fill a dropdown/list of a PDF Form using PHP or PDFtk.

I've used PHP in order to fill in some fields, I've been able to fill in text fields, select a radio button and even check boxes. (Using

/php-pdftk)

The only thing I can't fill is the list with a lot of values, I've just been able to "write" somehow into the field but it is not an item of the list.

I've also tried using PDFtk to export data from a FDF and a XML, it doesn't work at all.

Is it possible to fill a list using PHP or PDFtk? even a FDF or XML file would be also nice (since I can use these to use the PDFtk commands)

This topic has been closed for replies.
Correct answer Thom Parker

You can certainly fill lists with FDF. To do this you need to read the FDF specification. You could also use the FDF toolkit, but this is not absolutely necessary. An FDF file can be pure text, so it can be built using PHP string operations.

Google "FDF specification" and you'll get links to both the FDF spec and toolkit

3 replies

Legend
April 26, 2018

We make the point because FDF is most often used client side, by direct delivery of the FDF. With the right software an FDF can be merged server side, but I don't think Adobe have a product for that any more. If you have other APIs, they are likely to be simpler than working with FDF.

Participating Frequently
April 26, 2018

Yeah, I know many tools are now deprecated or not being maintained anymore, but I'll still try using some.

Thom Parker
Community Expert
Community Expert
April 26, 2018

If the PDF is open in Acrobat/Reader and the FDF data is returned to Acrobat/Reader in an HTTP response, then the browser is irrelevant.  All the action is contained within Acrobat. The only time you run into trouble is if the FDF is linked directly on a webpage. This is particularly problematic for mobile devices. To make this work you need a methodology where the request for the FDF happens from inside Acrobat, so that no external tools ever have to deal with the FDF.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Legend
April 26, 2018

You'll need to test every popular browser on each platform to see if your solution works. Client side processing is pretty much dead, to be honest, because of this.

Participating Frequently
April 26, 2018

It's all server-side scripting, actually and I would just make the file available once it's been treated.

Legend
April 26, 2018

These are not Adobe products.  Perhaps there is a forum from the makers of these products.

Participating Frequently
April 26, 2018

In that case what would be the FDF file to populate a dropdown list?

I've tried to export data from Adobe Acrobat Pro DC with forms containing lists but the FDF files do not contain the list items. It only exports the selected item from the list but not all.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 26, 2018

You can certainly fill lists with FDF. To do this you need to read the FDF specification. You could also use the FDF toolkit, but this is not absolutely necessary. An FDF file can be pure text, so it can be built using PHP string operations.

Google "FDF specification" and you'll get links to both the FDF spec and toolkit

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often