2013-04-12 48 views
0

我必須在Python3中將圖像(地圖)包含到PDF文件中。用Python顯示PDF格式的Google靜態地圖3

我從谷歌靜態地圖API圖像,使用URL像這樣的:

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

PyPDF的圖像功能

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

給我這個錯誤:

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

我認爲這是因爲圖像沒有任何擴展?

還有其他方法嗎?理念?

謝謝。

回答

1

的谷歌靜態地圖API響應通過URL返回GIF格式圖像的HTTP請求

因此,儘量GIF和PNG不作爲類型:)

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

+0

好, 謝謝!但是現在,我得到了以下錯誤:RuntimeError:FPDF錯誤:GIF支持需要PIL。 Python 3不支持PIL?你有想法嗎?謝謝 – user1845467

+0

當然,你需要一個替代PIL(見:http://stackoverflow.com/questions/3896286/image-library-for-python-3),那麼你需要獲得圖像並將其轉換爲支持的格式。然後與此合作 – Xavjer