Have been outputting pdfs for a while and this is what works for me ...
note, I don't close the pdf pdf.close? but this allows the user to
either open or save the file anywhere on their machine (Linux and Windows)
....
pdf.cell( ln=0, h=9.0, align='R', w=178.0, txt="%s %s" % (euro(),
'{:10,.2f}'.format(inv_tot)), border=0 )
import os
import sys
if session.inv_print_type == 'ORIGINAL':
invc_filename = "INVC_%s_%s.pdf" %
(session.inv_number,session.inv_company)
else:
invc_filename = "INVC_%s_%s_COPY.pdf" % (session.inv_number,
session.inv_company)
invc_filename = invc_filename.replace(' ','_')
invc_filename = invc_filename.replace( '&', 'and')
s_io = pdf.output(dest='S')
response.headers['Content-Type']='application/pdf'
response.headers['Content-Disposition'] = 'attachment; filename="%s"' %
invc_filename
raise HTTP(200, s_io, **response.headers)
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.