0

I have to include an image (map) into a PDF file in Python3.

I get the image from google static map API, using an URL like this one:

http://maps.google.com/maps/api/staticmap?zoom=12&size=300x300&markers=46.75165,6.98996&sensor=false

The Image function of PyPDF

pdf.image(name, x=None, y=None, w=0, h=0, type='PNG', link='')

Give me this error:

RuntimeError: FPDF error: Not a PNG file: http://maps.google.com/maps/api/staticmap?zoom=12&size=300x300&markers=&sensor=false

I think it's beacause of the image dosen't have any extension?

Any other way? Idea?

Thanks.

user1845467
  • 55
  • 2
  • 7

1 Answers1

1

The Google Static Maps API returns a GIF-format image in response to a HTTP request via a URL

Therefore, try GIF and not PNG as type :)

Source: http://blog.programmableweb.com/2008/02/25/google-releases-static-maps-api/

Xavjer
  • 8,838
  • 2
  • 22
  • 42
  • Ok, thanks! But now, I have got the error: RuntimeError: FPDF error: PIL is required for GIF support. PIL is not supported in Python 3? Have you got an idea? Thanks – user1845467 Apr 12 '13 at 07:01
  • Of course you'll need an alternative to PIL (see: http://stackoverflow.com/questions/3896286/image-library-for-python-3 ) then you'll need to get the image and convert it to a supported format. Then work with that – Xavjer Apr 12 '13 at 07:06