RE: [Zope] Displaying a pdf file.
Thanks for your reply. Specifically I am trying to do the following: I have and existing application that does the following. 1) user enters data then hits save 2) data is stored in a oracle database 3) the data plus some calculates are displayed back to the user in html This works fine however I have a new requirement for #3. Instead of displaying the data back to the user in html, I am to take the data add disclamer pages (total 4-5 pages) and display it to the user in pdf format. To do this I plan to do the following after the user hits 'save': 1) save the data in the oracle database 2) call and external procedure that will run an oracle report to create the report, save it as a pdf file on the local unix file system (ex. 'myfile.pdf'). 3)?? THIS IS WHERE I NEED HELP ?? I now need some way of having the user view this pdf file. Am I over complicating this? From zope can I just call a url (even if its on another web server that displays) the pdf. I don't really need it in zope to view it, do !? Thanks. Mike -----Original Message----- From: J Cameron Cooper [mailto:jccooper@jcameroncooper.com] Sent: Friday, August 15, 2003 11:59 AM To: Michael Guerrero; Zope user list Subject: Re: [Zope] Displaying a pdf file.
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."
Michael Guerrero wrote:
Thanks for your reply.
Specifically I am trying to do the following:
I have and existing application that does the following. 1) user enters data then hits save 2) data is stored in a oracle database 3) the data plus some calculates are displayed back to the user in html
This works fine however I have a new requirement for #3. Instead of displaying the data back to the user in html, I am to take the data add disclamer pages (total 4-5 pages) and display it to the user in pdf format.
To do this I plan to do the following after the user hits 'save': 1) save the data in the oracle database 2) call and external procedure that will run an oracle report to create the report, save it as a pdf file on the local unix file system (ex. 'myfile.pdf'). 3)?? THIS IS WHERE I NEED HELP ??
Why save the pdf file? You could just emit it on the fly inline or as an attachment down the http link to the user. If your need for a beautiful document is slight, you can reuse your html with the server-side utility htmldoc. Or send the data back from Oracle in XML and do an XSL:FO transformation on it to create PDF (actually, I don't know whether this would be fast enough). As you say, you don't need to use Zope. hth -- ------------ Mark Barratt Text Matters 37 Upper Redlands Road, Information design: Reading RG1 5JE, UK We help explain things using phone +44 (0)118 986 8313 .language fax +44 (0)118 931 3743 .design email markb@textmatters.com .systems web http://www.textmatters.com .process
This works fine however I have a new requirement for #3. Instead of displaying the data back to the user in html, I am to take the data add disclamer pages (total 4-5 pages) and display it to the user in pdf format.
To do this I plan to do the following after the user hits 'save': 1) save the data in the oracle database 2) call and external procedure that will run an oracle report to create the report, save it as a pdf file on the local unix file system (ex. 'myfile.pdf'). 3)?? THIS IS WHERE I NEED HELP ?? I now need some way of having the user view this pdf file.
Am I over complicating this? From zope can I just call a url (even if its on another web server that displays) the pdf.
I don't really need it in zope to view it, do !?
Zope has nothing to do with viewing anything. Zope just serves it. The question is how. 1. you can save it to the FS and use a product like I previously mentioned (probably LocalFS) to get to and serve it. Since you're doing it dynamically, that's probably not the best idea. 2. just have your external method return the contents of the file. Be sure to name the method something.pdf to get around IE's brokenness. 3. skip the database entirely and have Zope generate the PDF for you. If you have no explicit dependency on using that Oracle report program, you can look at something like http://www.reportlab.com/toolkit/ http://www-106.ibm.com/developerworks/linux/library/l-sc6.html?loc=dwmain http://zope.org/Members/Dirk.Datzert/RenderableCharts/view http://zope.org/Members/gaaros/ZpdfDocument/zpdfannounce/view http://zope.org/Members/jack-e/CMFReportTool/view http://zope.org/Members/gaaros/ZpdfDocument/view http://mail.zope.org/pipermail/zope/2002-January/106265.html --jcc
participants (3)
-
J Cameron Cooper -
Mark Barratt -
Michael Guerrero