hi!
i have a problem i cant solve. I want to download a pdf from report lab, but return this error
Error running WSGI application
2021-03-12 12:18:13,179: AttributeError: 'Canvas' object has no attribute 'read'
This is my view:
from django.http import FileResponse
from reportlab.pdfgen import canvas
from reportlab_qrcode import QRCodeImage
from reportlab.lib.units import mm
from werkzeug.wsgi import FileWrapper
def etichetta_generazione(request,pk):
buffer = io.BytesIO()
etichetta= canvas.Canvas(buffer)
dataqr = 'hello world'
qr = QRCodeImage(dataqr, size=30 * mm)
qr.drawOn(etichetta,0,0)
etichetta.showPage()
etichetta.save()
buffer.seek(0)
w = FileWrapper(etichetta)
return FileResponse(w, as_attachment=True,filename='etichetta.pdf')
Any tips to solve the problem?