[reportlab-users] Appengine - Reportlab (Get Photo from Model)

Martinho Arantes martinhoarantes at gmail.com
Mon Oct 4 08:42:44 EDT 2010


Hi, I´m using the latest reportlab version 2.5 to generate PDF´s.
I´m also using Google App Engine and Django.

I can get also an image that is in my source folder. Ex: for heading or
footer.
Everything went well to generate the PDF, but I'm having great difficulty
printing to a PDF an image that an user uploaded, like his own photo.
The photo is a property and is defined in model as BlobProperty ().

*Handler: *
class savePDF(webapp.RequestHandler):
def post(self):
user= models.Users.all()
p = canvas.Canvas(self.response.out)
p.drawString(50, 720, 'Curriculum Vitae : ' + '%s' % user.name)

image = canvas.ImageReader(StringIO.StringIO(user.photo))
p.drawImage(image, 40,700)

*Model:*
class User(db.Model):
photo = db.BlobProperty()
name = db.StringProperty(required = True)

*View:*
<table align="center">
<tbody>
<tr>
<td>Upload Photo: </td>
<td><img src="/uploadFoto" /></td>
</tr>
<tr>
<td>User Name: </td>
<td>{{ user.name }}</td>
</tr>
<tr>
<td>User Photo: </td>
<td>{{ user.photo }}</td>
</tr>

*Note:* I´ve modified utils.py this
post<http://blog.notdot.net/2010/04/Generating-PDFs-on-App-Engine-Python-and-introducing-Mapvelopes>
.

I´m getting errors like this one:
File "C:\Users\hp\workspace\x-ray\src\principal.py", line 441, in post image
= canvas.ImageReader(StringIO.StringIO(user.photo)) File
"reportlab.zip\reportlab\lib\utils.py", line 588, in *init* File
"reportlab.zip\reportlab\lib\utils.py", line 582, in *init* RuntimeError:
Imaging Library not available, unable to import bitmaps only jpegs
fileName=<StringIO.StringIO instance at 0x04A5A030>
identity=[ImageReader at 0x4a62290].

*Please note that i uploaded an .jpeg image.*

So, i don´t get the error. If someone could help, i´d be very happy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20101004/d6440767/attachment.htm>


More information about the reportlab-users mailing list