2
我想生成從Google應用引擎數據庫檢索圖像的pdf。如何使用Platypus將Google應用引擎動態圖像對象添加到ReportLab pdf文檔中:「ImageReader」對象沒有屬性「getKeepWithNext」
#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。
在此先感謝!
如果你在你的appengine應用程序中有一個可以處理圖像的處理程序,那麼你可以使用與上面例子完全相同的方法。 ALternatley從blob或blobstore實體創建Image()。 ImageReader __init__接受文件名或URL或StringIO或PIL Image實例作爲其實例。 –