Very easy using pisa. You also need to install reportlab and html5lib
but once these have been installed it is simple:
# to directly get the html for a view
html = response.render("myview.html", locals())
filename = "C://outputpdf.pdf"
f = file(filename, "wb")
pdf = pisa.CreatePDF(html, f)
f.close()
if not pdf.err:
pisa.startViewer(filename)
The only thing is I found there was actually a pdf generator included
with web2py called pyfpdf. I was all set to replace pisa with this but
now it seems to have disappeared from the book and I can find no
mention of it. Would be useful to have a pdf generator included in the
box with web2py - why was it removed?