[reportlab-users] Drawing QRcode

Vaibhav Gajengi vaibhav.gajengi at gmail.com
Wed Aug 27 05:28:32 EDT 2014


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 <timr at probo.com> 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, timr at probo.com
> Providenza & Boekelheide, Inc.
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140827/d5b2136f/attachment.html>


More information about the reportlab-users mailing list