This example shows the how to accomplish advanced printing, with a form controlling parameters for the MapFish or GeoServer print module.
The js is not minified so it is readable. See print-form.js.