Hi Dominic, 
I found the simplest way to serve PDF files is to save them in the static 
directory, and then pass in the folder and the name of the file you want to 
serve as url parameters. See sample code below.  I have also had good 
success building PDF's on the fly using the pyfpdf module which is include 
in web2py. 

def display_ts_pdf():
    import os
    #year, job and filename are passed in on the URL, use variables to 
navigate pdf folder
    tmpfilename=os.path.join(request.folder,'static','pdf',
                            
 request.vars['yr'],request.vars['job'],request.vars['dlfile'])
    response.headers['ContentType'] ="application/pdf";
    data = open(tmpfilename,"rb").read()
    #delete file after buffering
    #os.unlink(tmpfilename) 
    response.headers['Content-Type']='application/pdf'
    return data

-Good luck




On Wednesday, January 7, 2015 at 7:16:54 AM UTC-5, Dominic Balassone wrote:
>
> Hey there,
>
> I'm simply trying to allow my users to click on a hyperlink which will 
> send them to a new tab where they are viewing they pdf (or asked to 
> download a pdf viewing plugin for their browser).
>
> I have already set my pdfs to be saved in the static directory, in a 
> directory called "pdfs," although I do not know if this is actually 
> necessary.
>
> Any advice?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to