How to load images in django reportlab
hi i am trying to load a image onto a pdf with reportlab but i keep getting
OSError at /view_checklist_print/1
Cannot open resource "check_box_outline_blank.svg"
This is my test
i21 = False
This is my view
def checklist_report(reques):
buffer = io.BytesIO()
c = canvas.Canvas(buffer, pagesize=(8.5 * inch, 11 * inch))
def checkboxgenerator(a, b, checkdata):
checked = 'check_box_FILL.svg'
unchecked = 'check_box_outline_blank.svg'
x_start = a
y_start = b
blankbox = c.drawImage(unchecked, x_start, y_start, width=120, preserveAspectRatio=True, mask='auto')
checkedbox = c.drawImage(checked, x_start, y_start, width=120, preserveAspectRatio=True, mask='auto')
if checkdata == False:
return blankbox
else:
return checkedbox
checkboxgenerator(20, 300, i21)
c.showPage()
c.save()
buffer.seek(0)
return FileResponse(buffer, as_attachment=False, filename=test.pdf')
Please can you help me load the image correctly
You should put your SVG files in the same directory as your current python file or use the exact path to the SVG file path.