Python 如何使用Platypus将Google app engine动态图像对象添加到ReportLab pdf文档中;图像阅读器&x27;对象没有属性';getKeepWithNext";

Python 如何使用Platypus将Google app engine动态图像对象添加到ReportLab pdf文档中;图像阅读器&x27;对象没有属性';getKeepWithNext";,python,google-app-engine,pdf-generation,reportlab,platypus,Python,Google App Engine,Pdf Generation,Reportlab,Platypus,我想生成从谷歌应用程序引擎数据库检索图像的PDF #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(

我想生成从谷歌应用程序引擎数据库检索图像的PDF

#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)
我见过一些解决方案,包括从画布添加图像。虽然很不方便,因为我更愿意在故事中添加元素,然后创建文档,但我尝试了。但它仍然不起作用

有人做到过这一点吗?我的意思是,动态地使用谷歌应用程序引擎图像、reportlab和platypus


提前感谢

谢谢你@Tim。对于记录,解决方案是将基本url和变量url放置在Image()中。例如图像(基本url+对象图片url)。它只需要绝对url。

如果appengine应用程序中有一个处理程序可以为图像提供服务,那么使用与上面示例完全相同的方法。ALternatley从blob或blobstore实体创建图像()。ImageReader init接受文件名或URL或StringIO或PIL映像实例作为其初始实例。