Re: Drawing QRcode

Vaibhav Gajengi <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CADaVOyXcZD8wAMFy4G6Vfb+uCVh9-GwZ7TQyvdLCtBmM1HRxgg@mail.gmail.com>
Hello,

One more Q i want to ask about the rendering the pdf.
i am using the below code snipet for rendering QR Code on the pdf but its
not rendering the pdf on given x & y co-ordinates ?
renderPDF.draw(d,p,x,y)
is is there any reason for that ?
Can you explain me the same ??
Any help Appreciated .


Best Regards
Vaibhav



On 27 August 2014 14:58, Vaibhav Gajengi <[email protected]> wrote:

> 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
>>
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.