简体   繁体   English

在 ReportLab PDF 中包含远程图像

[英]Including a remote image in ReportLab PDF

I am using a Django app in order to generate a PDF with reportlab which includes an oxxo barcode, but I get the following error:我正在使用 Django 应用程序生成包含 oxxo 条形码的 reportlab 的 PDF,但出现以下错误:

Can not open resource "https://www2.oxxo.com:

My code is我的代码是

p.drawImage(url,PAGE_WIDTH/2.0-120,380)

From Reportlab documentation for drawImage -来自drawImage Reportlab 文档-

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.

image can certainly not be an url. image当然不能是网址。 You can download the image in a local file and include that file's path as the value of first parameter image .您可以将图像下载到本地文件中,并包含该文件的路径作为第一个参数image的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM