[reportlab-users] About a bug in barcodes
Robin Becker
robin at reportlab.com
Fri Sep 3 04:48:21 EDT 2010
On 02/09/2010 19:33, Germán M. Bravo wrote:
> 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.
strokeWidth==0 is not the same as no stroke being drawn. In all rational worlds
it would be, but according to some person in postscript land zero means the
smallest width possible. That's a bug in my opinion, but established by ancient
convention, but just for PDF since line drawing in other universes has a
different heritage.
I think this patch makes sense so I'll try and put it in today
>
> (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 --------
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
--
Robin Becker
More information about the reportlab-users
mailing list