Samstag, 18. September 2010

How to receive something send from an Adobe Acrobat PDF via Stripes

Last three days were terribly frustrating...
I couldn't seem to be able to find a single person who tried this before.
Thus now this entry:

So, Adobe Acrobat has such a nice function to let you add a "Submit" button into your pdf.
Since our company works heavily with Stripes I thought that it would be quiet convinient to click on the "Submit" within the pdf, send the data to our ActionBean and let the validation decide if everything was correct.

The big question now was: How does Adobe send the data?
When you create a submit button you can descide how and what you want to transmit.
I did choose html and thought "Yea, it will most likely transmit the whole thing in a gigantic string"

ohhhh, how wrong I was...

The only question to my above thought was, how I can tell stripes to accept this String and set it into a variable for further processing.
After a very long time of failing I took a look at the request and, oh wonder.

Adobe does not send the data in a gigantic String. It does send the content in kay-value pairs (the name of the text-field/checkbox beeing the key).

only thing left: introduce variables/getter and setter with the corresponding names.


Conclusion:
If you submit a PDF with a text-field named "test" just create a variable "test" with the getters/setters and stripes correctly loads the values into it. Validating this is now a piece of cake.

Have fun.