Hi All,
I am looking to generate a PDF page from the data submitted in a web form.
For this I am using REportLab.
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
class Handler:
def do(self, environ, start_response):
form = cgi.FieldStorage(fp=environ['wsgi.input'],
environ=environ)
html = """
<meta http-equiv="refresh"
content="0;url=https://www.mywebsite.in/home.py" /> """
printpdf = form.getvalue('print') ## This is a checkbox in
html { If checked then create the PDF file}
if printpdf == 1:
c = canvas.Canvas('Patient_info.pdf', pagesize=letter)
c.setFont('Helvetica', 12)
c.drawString(30,750, ptbn)
c.showPage()
c.save()
os.open("open Patient_info.pdf")
output = html
mimeType = "text/html"
status = "200 OK"
response_headers = [("Content-type", mimeType),
("Content-length", str(len(output)))]
start_response(status, response_headers)
return [output]
If i enter the code in python prompt, from c = canvas .... , a PDF
file is created and saved in the current working directory.
But not when I am doing it from a webpage.py file. There is no error,
the PDF web page / Acroread does not open / launch the page.
Do I need to add / change some thing, if wsgi requires it, in the
above code to generate the PDF file ? If yes, then how should the line
be written?
Thank you
Nitin
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en.