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