[reportlab-users] Barcode checksum printed in human readable format

Stéphane Travostino stephane.travostino at gmail.com
Thu Nov 20 09:59:02 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
sorry for pasting the same example as in the previous mail.
When a Code39 barcode is created with the humanReadable variable set, the
text is printed including the checksum.
The expected behaviour is to see the text without the checksum.

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.graphics.barcode import code39

TEXT = "TEST01L4"

c=canvas.Canvas("barcode.pdf",pagesize=A4)
barcode=code39.Standard39(TEXT, barWidth=0.423*mm, barHeight=10*mm,
ratio=2.75, humanReadable=True)
barcode.drawOn(c,50*mm,50*mm)
c.showPage()
c.save()

You'll see that the checksum is printed with the text.
Here is the patch to solve this issue, diffed from SVN
http://svn.reportlab.com/svn/public/reportlab/community/trunk/src/reportlab/graphics/barcode/code39.py

:

- --- code39.py 2006-05-04 12:48:36.000000000 +0200
+++
/usr/lib/python2.5/site-packages/reportlab/graphics/barcode/code39.py
2008-11-20 15:51:12.000000000 +0100
@@ -138,7 +138,8 @@
return self.decomposed

def _humanText(self):
- - return self.stop and
self.encoded[1:-1] or self.encoded
+ text = self.stop and
self.encoded[1:-1] or self.encoded
+ return self.checksum and
text[:-1] or text

class Standard39(_Code39Base):
"""

Stephane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081120/3417e37f/attachment.html>


More information about the reportlab-users mailing list