So this is better (thanks to Paul Rykiel's post 
re labels and responders including one Mariano Reingart)...
and hope it helps someone else down the road.

pdf = receipt_PDF()

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) )

response.headers['Content-Type'] = 'application/pdf'
return, 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?*


- (Documentation)
- (Source code)
- (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 
For more options, visit

Reply via email to