如何使用reportlab将图像插入PDF?

时间:2019-09-12 15:30:21

标签: python reportlab

我想将URL引用的图像插入PDF。我将python与reportlab结合使用。下面是我尝试的代码片段:

flowables=[]
I = Image('https://www.python.org/static/community_logos/python-logo-master-v3-TM.png')
flowables.append(I)

我收到此错误:

Exception Type: TypeError
Exception Value:
__init__() missing 4 required positional arguments: 'y', 'width', 'height', and 'path'

所以我再次尝试了该错误消息中提到的参数:

logo= 'https://www.python.org/static/community_logos/python-logo-master-v3-TM.png'
flowables=[]
I = Image(path=logo, x = 2.188*inch, y=0.5*inch, height=0.7 * inch, width=0.7 * inch)
flowables.append(I)

现在我遇到此错误:

Exception Type: AttributeError
Exception Value:
'Image' object has no attribute 'getKeepWithNext'

0 个答案:

没有答案