Re: Drawing QRcode
Vaibhav Gajengi <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <CADaVOyVv_3tJuz_foyxVJXD9Ch8XW3SU3_MCJpY8X3G9F30O4Q@mail.gmail.com> |
Hello , I tried using that but its not giving me the result. Can you explain me which info should i give for size of widget ? I tried with by giving the parameters as below. but i am not getting the exact use of this parameters. Below is the code part qrw = QrCodeWidget(item,barHeight=10*mm,barWidth=10*mm,barBorder=6) Can you explain the above paramters ? Thanks Vaibhav On 26 August 2014 22:31, Tim Roberts <[email protected]> wrote: > Vaibhav Gajengi wrote: > > > I want to ask one basic stuff regarding QRcode generation. > I am using the reportlab 2.7 for drawing the QRcode i want to draw the > QRcode of 10mm * 10mm. > > i want help regarding how to set the width & height of QRcode. > > my code snippet is : > qrw = QrCodeWidget(itemtodraw,height=10*mm,width=10*mm) > > But its not getting correctly drawn of 10*mm by 10*mm > > > There are a couple of things going on here. > > You can't make a QR code arbitrarily small. The size of the widget > depends on the amount of information you are embedding in the code. The > QrCodeWidget here ignores the width and height you supply. It generates an > object using nominal sizing. You then find out with qrw.getBounds() how > large the nominal code is. > > Once you have that, you can scale the code yourself to fit the spot you > have for it when you embed it in a drawing object. This is why you see > this code in virtually every QR example: > b = qrw.getBounds() > w = b[2]-b[0] > h = b[3]-b[1] > > So, this will do what you ask, but the results aren't very interesting > because 10mm is just too small: > > unit = 10*mm > qrw = QrCodeWidget('hello cruel world!') > b = qrw.getBounds() > w = b[2]-b[0] > h = b[3]-b[1] > d = Drawing(unit,unit,transform=[unit/w,0,0,unit/h,0,0]) > d.add(qrw) > > -- > Tim Roberts, [email protected] > Providenza & Boekelheide, Inc. > > > _______________________________________________ > reportlab-users mailing list > [email protected] > http://two.pairlist.net/mailman/listinfo/reportlab-users > >