I would take POST data, and plug it into a templating system (like Django's), which is using something like LaTeX to define the basic properties of the document and populating with data and logic from Django.
Basically a mix of two markups in one file. Meh, there's probably a better way to do that.