[reportlab-users] Performance Issue generating multiple QR codes

Thomas Kremmel thomasspin at gmail.com
Wed Sep 17 07:53:10 EDT 2014


additional info: the creation time is directly related to the length of the
input string to the qr code. the data for my qr code is very long and the
resulting qr code quite complex.. the length of the input data is 229. if i
input a text with 10 characters it is very fast.

thus it seems as it needs quite a lot computing power to draw this kind of
complex qr code..

2014-09-17 13:38 GMT+02:00 Thomas Kremmel <thomasspin at gmail.com>:

> Hello,
>
> I'm using Reportlab to generate a pdf with 10 pages. I print on each page
> a QR code, which is about half the size of the A4 page.
>
> The generation of the .pdf takes me about 20 seconds.
> When I generate the .pdf without the QR codes the .pdf is generated
> immediately. Thus it is obvious that the pdf generation of the QR codes
> consumes the most time.
>
> Any idea what I could do here to bring this down to an user acceptable
> time - say 2 seconds.
>
> Here are some source snippets to get an idea what I'm doing.
>
> import from reportlab.graphics.barcode.qr import QrCodeWidget
>
>  def draw_qr_code(self):
>         qr_code_data = get_qr_code_data("input text")
>         qrw = QrCodeWidget(qr_code_data, barLevel='M')
>         b = qrw.getBounds()
>         w=b[2]-b[0]
>         h=b[3]-b[1]
>         d = Drawing(220, 220, transform=[220./w, 0, 0, 220./h, 115, 0])
>         d.add(qrw)
>         self.pdf.drawing(d)
>
>     def drawing(self, drawing):
>         self.story.append(drawing)
>
>      def generate(self):
>         # this consumes about 18 of the 20 seconds..
>         self.pdf.generate()
>
>
> Would be great if someone could shed some light on this topic.
> All the best,
> Thomas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20140917/c8f79121/attachment.html>


More information about the reportlab-users mailing list