Utilizzando reportlab, come posso generare una serie di codici qr e inserirli in un pdf e quindi aprirlo nel browser dell'utente. Ecco il mio tentativo. Grazie in anticipo. Per questo codice qui sotto, non succede nulla. Mi aspettavo di essere richiesto di salvare il file pdf.Generare più codici qr in un file pdf utilizzando reportlab e framework django
from reportlab.pdfgen import canvas
from django.http import HttpResponse
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.barcode.qr import QrCodeWidget
from reportlab.graphics import renderPDF
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
p = canvas.Canvas(response)
qrw = QrCodeWidget('Helo World!')
b = qrw.getBounds()
w=b[2]-b[0]
h=b[3]-b[1]
d = Drawing(45,45,transform=[45./w,0,0,45./h,0,0])
d.add(qrw)
renderPDF.draw(d, p, 1, 1)
p.showPage()
p.save()
return response
Puoi descrivere le tue difficoltà in un modo più specifico? Che cosa fa il tuo codice giusto/sbagliato, dove hai esattamente difficoltà ecc. – Rytmis