[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-24 Thread Peter
Just to close this off. I think I am in a bit of a catch 22.. Because the behaviour *is exactly what I want *i.e. stream goes straight to download option, I don't get the open/save dialogue so can't change the setting and after reading this (possibly related Firefox bug report)* https://

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Peter
Hi Niphlod, (& Paolo read this!) halt. downloading is something the browser can decide. opening the saved > file is something your operating system does. > The browser can only send the response which gives the user a choice > between saving and opening directly the file. > If the user choose

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Niphlod
halt. downloading is something the browser can decide. opening the saved file is something your operating system does. The browser can only send the response which gives the user a choice between saving and opening directly the file. If the user chooses "open" instead of "save" ... nothing can pr

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Peter
Many thanks for response Paolo! I have tried your suggestion... # 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) s_io = pdf.output(dest

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Paolo Valleri
With this: ... s_io = pdf.output(dest='S') response.headers['Content-Type']='application/pdf' response.headers['Content-Disposition'] = 'attachment; filename="%s"' % file_name raise HTTP(200, s_io, **response.headers) You get the same you have now with response.stream but it's cleaner. Without

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-16 Thread Peter
On Sunday, 16 October 2016 05:24:10 UTC+1, Peter wrote: > > > > I have this code that doesn't work too well... > > > import os > import sys > pdf = receipt_PDF() > pdf.add_page() > rcpt_filename = "RCPT_%s_%s.pdf" % (session.rcpt_number, > session.rcpt_recipient) > rcpt_filename = rcpt_filename.

[web2py] Re: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-16 Thread Peter
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() pdf.add_page()