Check out this code: http://github.com/jaywhy/pdf-stamper/tree/master
I haven’t used it, as it wasn’t around when I needed it, so I wrote my own, but this code looks very similar to what I wrote, so it may work well for what you need.
The highlighted line in this link shows how the fields can be listed: