[reportlab-users] About a bug in barcodes

Germán M. Bravo german.mb at gmail.com
Thu Sep 2 14:33:22 EDT 2010


Barcodes always show a stroke no matter what (even a very small one)
...that makes some printers print a nasty stoke that messes up the
barcode. Rects built for barcodes should not have a stroke at all by
default, but setting a StrokeColor makes reportlab drawing shapes add
a stroke anyway.

(In the eanbc.py for instance, around line 260), where it calls:
Rect(..., strokeColor=barFillColor), it should call Rect(...,
strokeColor=barStrokeColor) instead, and barStrokeColor should come
from self.barStrokeColor that being None by default, instead of
colors.black. That single bug makes my barcodes all messy. Below is a
patch to fix eanbc.py.

------- PATCH FOLLOWS CUT HERE --------
--- reportlab/graphics/barcode/eanbc.py 2010-08-08 10:37:45.000000000 -0500
+++ reportlab/graphics/barcode/eanbc.py 2010-08-31 14:19:30.000000000 -0500
@@ -179,7 +179,8 @@
}
fontSize = 8 #millimeters
fontName = 'Helvetica'
- textColor = barFillColor = barStrokeColor = colors.black
+ textColor = barFillColor = colors.black
+ barStrokeColor = None # Needs to be None for the render not to
show any stroke at all
barStrokeWidth = 0
x = 0
y = 0
@@ -243,6 +244,7 @@
fontSize = self.fontSize
barFillColor = self.barFillColor
barStrokeWidth = self.barStrokeWidth
+ barStrokeColor = self.barStrokeColor

fth = fontSize*1.2
b = ''.join(b)
@@ -255,7 +257,7 @@
if lrect and lrect.y==yh:
lrect.width += barWidth
else:
- lrect =
Rect(x,yh,barWidth,barHeight-dh,fillColor=barFillColor,strokeWidth=barStrokeWidth,strokeColor=barFillColor)
+ lrect =
Rect(x,yh,barWidth,barHeight-dh,fillColor=barFillColor,strokeWidth=barStrokeWidth,strokeColor=barStrokeColor)
gAdd(lrect)
else:
lrect = None
------- PATCH ENDS CUT HERE --------


More information about the reportlab-users mailing list