[reportlab-users] Drawing a remote Image from a URL without writing to disk

Robin Becker robin at reportlab.com
Wed May 30 09:56:19 EDT 2012


On 30/05/2012 14:41, Damian Moore wrote:

> Hi ReportLabbers,

>

> Hope you are all doing well. I'm having a little trouble trying to do something

> in ReportLab and not sure if it's possible.

>

> I'm trying to download a remote image (a google map) and add it to a Drawing

> without writing to disk. I've tried using StringIO but the Image class in

> reportlab.graphics.shapes only seems to accept a file path. I'm using a Drawing

> as I need to do something fancy with layout.

>

> Any help would be much appreciated.

>

> Regards,

> Damian

.....

Hi Damian,

I think the problem is actually in the renderXX implementations of drawImage; so
currently renderPDF.drawImage calls _canvas.drawInlineImage which ends up
making the assumption that it can call PDFImage on the path object. I believe
that is old fashioned and you may want to try creating a PIL Image from your
data source and try assigning that to the shapes.Image instance path attribute.

That will work for renderPDF, but perhaps you want to use this for another renderer.
--
Robin Becker


More information about the reportlab-users mailing list