[Zope] Displaying a pdf file.

J Cameron Cooper jccooper at jcameroncooper.com
Fri Aug 15 14:59:22 EDT 2003


>
> What is the best way to display a pdf file in a zope application.  I 
> may select the file from an oracle database of get it from a file 
> system.  I'm not sure at the moment.
>  
> My Zope Bible book shows how to upload a pdf file from a filesytem 
> then view it.  But in my case the pdf I want to view is based on an ID 
> entered by the user.  There may be many different pdf and I can't 
> upload them all.
>  
> I want to be able to
>   1) if the the pdf is on server then
>          view (\docs\my.pdf)  using the correct application type
>  
> or
>   2) if I select the pdf from an oracle table (stored as a BLOB)
>        <dtml-in sql-get_pdf>
>              somehow display the pdf
>        </dtml-in>

You could write a script to automatically upload everything to Zope, use 
load_site.py, or copy your files using FTP or WebDAV.

If you really want to get them from the FS, get LocalFS and make a 
LocalFS object that points to, say, /docs. That's probably the easiest 
way. Well, aside from FTP.

If you want to grab it from a table, you'll want to write a Python 
script (with a .pdf extension!) that returns a single BLOB field, gotten 
by way of a ZSQL method. How that field is selected from the table can 
be determined by REQUEST variable parameters, acquisition context, or 
several other means. Obviously, this takes more work. Just remember that 
you *cannot* display the data inline. That will never work: you must 
return it looking like a single file.

          --jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."





More information about the Zope mailing list