简体   繁体   中英

How to add Google app engine dynamic image objects to ReportLab pdf document with Platypus: “ImageReader' object has no attribute 'getKeepWithNext”

I want to generate pdfs that retrieve images from Google app engine database.

#Example. This works perfectly fine in the resulting doc
story.append(Image('http://www.python.org/community/logos/python-logo.png'))

#Im omitting the details heres, but photo object is correctly created
photo = ImageReader()

story.append(photo)
#Gives me the error: 
#AttributeError: 'ImageReader' object has no attribute 'getKeepWithNext'

#I thought it might had to cast to an Image object, so i tried:
story.append(Image(photo))
#It gives me the error:
#AttributeError: 'ImageReader' object has no attribute 'rfind'

#The error points out to the line where I try to build the doc with the story
doc = SimpleDocTemplate(stream, pagesize=portrait(A4), etc.)
doc.build(story)

I have seen some solutions that involve adding the image from the canvas. Although very inconvenient cause I'd much rather go adding adding elements to the Story and then create the doc, I tried it. And it still doesnt work.

Has anybody ever achieved this? I mean, dynamically with google app engine images and reportlab and platypus.

Thanks in advance!!!

Thank you @Tim. For the record, the solution is placing the base_url and the variable url in the Image(). Ex. Image(base_url + object_image_url). It just needed the absolute url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM