简体   繁体   中英

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:

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(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. You can download the image in a local file and include that file's path as the value of first parameter image .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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