I haven't implemented dynamic form populating before, but the last time I needed a web-based dynamic PDF solution I used ActivePDF:
http://www.activepdf.com/products/serverproducts/toolkit/Not sure how applicable or easy it will be for you, but the feature list seems to work for your need:
"Dynamic PDF form-filling - populate PDF forms with database data and generate form fields on the fly."
With that program, it shouldn't be too difficult for you to write a script to accomplish what you're thinking of.