Python 在ReportLab PDF中包含远程图像
我使用Django应用程序生成带有reportlab的PDF,其中包含oxxo条形码,但我收到以下错误:Python 在ReportLab PDF中包含远程图像,python,django,reportlab,Python,Django,Reportlab,我使用Django应用程序生成带有reportlab的PDF,其中包含oxxo条形码,但我收到以下错误: Can not open resource "https://www2.oxxo.com: 我的代码是 p.drawImage(url,PAGE_WIDTH/2.0-120,380) 从- 图像当然不能是url。您可以下载本地文件中的图像,并将该文件的路径包含为第一个参数值image我尝试导入cStringIO import io import PIL.image fd=urllib2.
Can not open resource "https://www2.oxxo.com:
我的代码是
p.drawImage(url,PAGE_WIDTH/2.0-120,380)
从-
图像
当然不能是url。您可以下载本地文件中的图像,并将该文件的路径包含为第一个参数值image
我尝试导入cStringIO import io import PIL.image fd=urllib2.urlopen(datos['url'])image\u file=StringIO.StringIO(fd.read())im=PIL.image.open(image\u file)print im p.drawImage(im,PAGE_WIDTH/2.0-80430150,80,mask='auto')请用此更新您的问题,以及当前的输出和错误是什么。我尝试mport cStringIO import io import io import PIL.Image fd=urllib2.urlopen(datos['url'])Image_file=StringIO.StringIO(fd.read())im=PIL.Image.open(Image_文件)print im p.drawImage(im,页宽/2.0-80430150,80,mask='auto')但属性错误异常值:rfind
drawImage(image, x, y, width=None, height=None, mask=None, preserveAspectRatio=False, anchor='c')
Draws the image (ImageReader object or filename) as specified.
“image” may be an image filename or an ImageReader object.