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.
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=[imagerea...@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.
The problem that i´m facing right now is when a user upload a photo,
isn´t displayed on his PDF.
I´ll show you a short pic tinypic.com/r/2ngeont/7, but the image shown
is uploaded by me not by the user.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en.