异常类型:ValueError 异常值:
视图 canvas.views.pdfDirectory 没有返回 HttpResponse 对象。
异常位置:/usr/local/lib/python2.6/dist-packages/Django-1.4.3-py2.6.egg/django/core/handlers/base.py in get_response,第 129 行
import os
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import cm, mm, inch, pica
def pdfDirectory(imageDirectory, outputPDFName = 'ima.pdf'):
dirim = str(imageDirectory)
output = str(outputPDFName)
width, height = letter
height, width = letter
c = canvas.Canvas(output, pagesize=letter)
# try:
for root, dirs, files in os.walk(dirim):
for name in files:
lname = name.lower()
if lname.endswith(".JPG") or lname.endswith(".gif") or lname.endswith(".png"):
filepath = os.path.join('/home/deepak/Downloads', 'image')
c.drawImage('/home/deepak/Downloads/imag.pdf', inch, inch * 1)
c.showPage()
c.save()
return output
# print "PDF of Image directory created"
# except:
# print "Failed creating PDF"