response.headers['Content-Disposition'] = 'attachment; filename=tuto1.pdf'

On Sunday, 18 November 2012 20:32:29 UTC-6, Paul Rykiel wrote:
>
> Greetings, 
>  
> I am new to Web2py and I am trying to create PDF's. 
> The following example code works great and I believe it will work for my 
> project; however, instead of the output going to the screen I would like it 
> to download to a directory ... what do i need to do to make this happen. 
> Thank you in advance for any assistance that you may offer.
>  
> Regards,
>
> from gluon.contrib.fpdf import FPDF
> def pdfexp():
>     example = "this is an example"
>     example2 = "this is example 2"
>     pdf=FPDF()
>     pdf.add_page()
>     pdf.set_font('Arial','B',16)
>     pdf.cell(40,10, example)
>     pdf.add_page()
>     pdf.set_font('Arial','B',16)
>     pdf.cell(40,10, example2)
>     pdf.output('tuto1.pdf','F')
>     return response.stream(open('tuto1.pdf'))
>

-- 



Reply via email to