This example shows the how to create a printable PDF with GeoExt.data.MapfishPrintProvider and GeoExt.PrintMapPanel, using the MapFish or GeoServer print module.
The js is not minified so it is readable. See print-preview.js.