Performance Issue generating multiple QR codes

Thomas Kremmel <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CA+nmuN-Z46fnbSn67T_DaSy0QWuq2UK=DG90ZX0WuCF9vX4K6Q@mail.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
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.