Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在ReportLab PDF中包含远程图像_Python_Django_Reportlab - Fatal编程技术网

Python 在ReportLab PDF中包含远程图像

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.

我使用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.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.