2

我想生成从 Google 应用引擎数据库中检索图像的 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 和鸭嘴兽。

提前致谢!!!

4

1 回答 1

0

谢谢@蒂姆。作为记录,解决方案是将 base_url 和变量 url 放在 Image() 中。前任。图片(base_url + object_image_url)。它只需要绝对网址。

于 2014-01-31T14:37:18.450 回答