All code in the controller, untested - but it works locally! PDF, here we come