{{
import os
from gluon.contrib.fpdf import FPDF
response.headers['Content-Type'] = "application/pdf"
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'I', 14)
pdf.cell(40, 10, "Hello, ExampleServer World")
pdf.ln()
pdf.set_font('Arial', '', 10)
pdf.set_fill_color(210,210,240)
print "found %d results" % (len(results))
for row in results:
fill = 1 if row.id % 2 else 0
pdf.cell(20, 5, str(row.id), '', 0, '', fill)
pdf.cell(50, 5, row.eventtime.isoformat(), '', 0, '', fill)
pdf.cell(40, 5, row.eventstatus, '', 0, '', fill)
pdf.cell(20, 5, row.client, '', 0, '', fill)
pdf.cell(9, 5, str(fill), '', 1, 'C', fill)
pass
print "trying to do pdf,output"
= pdf.output('tut01.pdf', 'S')
}}
stuff = open("/tmp/stuff.pdf", 'w')
stuff.write(pdf.output('tut01.pdf', 'S'))
stuff.close()
response.stream("/tmp/stuff.pdf")
why didn't the first version work? That's what generic.pdf does via gluon/contrib/generic.py's html_to_pdf(), I believe, which I was using as a guide.
I will note that I did have problems with generic.pdf, but I need to research that more. The first issue I could work around, not having PIL available to process my logo's .png (removed the logo, which was called out in layout.html since this is an older app), but there was something else that gave me an error, as well. When I go back and look at that, I may have another question for the list.
/dps