So this is better (thanks to Paul Rykiel's post
<https://groups.google.com/forum/#!searchin/web2py/fpdf|sort:relevance/web2py/OZkBWOtwtdQ/gBFdrmMmdOMJ>
re labels and responders including one Mariano Reingart)...
and hope it helps someone else down the road.
pdf = receipt_PDF()
pdf.add_page()
rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, session.rcpt_recipient)
rcpt_filename = rcpt_filename.replace( ' ', '_' )
rcpt_filepath = request.folder + '/static/temp/%s'%(rcpt_filename)
if sys.platform.startswith( "linux" ) :
os.system( "xdg-open %s" %(rcpt_filepath) )
else :
os.system( "%s" %(rcpt_filepath) )
pdf.output(rcpt_filepath,dest='S')
response.headers['Content-Type'] = 'application/pdf'
return response.stream(rcpt_filepath, chunk_size=4096, request=request,
attachment=True, filename=rcpt_filename)
so this code...
- no longer opens the browser pdf reader, user page does not change!
- opens the open/save dialogue box with required filename and allowing
users to save wherever desired!
but it still has one issue...
- as well as opening the open/save dialogue box it automatically opens
Adobe Reader as well and displays the file (a little overkill!)
(It also creates temp files on the system that may/may not need to be
cleaned up - but that's for another day.)
*Can I stop it automatically opening the file in Adobe and if so how?*
Peter
--
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.