[reportlab-users] For Generating Multiple QR code o a pdf

Tim Roberts timr at probo.com
Thu Dec 19 13:45:44 EST 2013


Vaibhav Gajengi wrote:

>

> Hello Vaibhav here,

>

> I want to generate the multiple QR Code on a single pdf file ??

> Can anybody help me in this regards ?? some one posted on internet

> this code snap

>

> qrw = QrCodeWidget('tokenitem')

> print repr(qrw)

> b = qrw.getBounds()

> w=b[2]-b[0]

> h=b[3]-b[1]

> d = Drawing(100,100,transform=[110./w,0,0,110./h,0,0])

> d.add(qrw)


There's one more important step after this:
renderPDF.draw( d, canvas, x, y )

Did you actually try this? The QrCodeWidget generates a series of
graphics.shapes.Groups. The graphics.shapes.Drawing object is a
container for those shape Groups. The (100,100) is the size of the
drawing surface in pixels, and the transform parameters make sure the QR
code is scaled to fit into that size. Then, the renderPDF.draw line
places that drawing on the canvas, at the (x,y) location in the
renderPDF.draw call.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list