python-barcode icon indicating copy to clipboard operation
python-barcode copied to clipboard

how to set text position?

Open goog opened this issue 6 years ago • 5 comments

code128_barcode

goog avatar Jul 17 '19 03:07 goog

You can configure several parameters, including changing the distance between the text and the barcode (.text_distance':1 option)...

for example:

def barcode_generator(x): <indentation> ean = barcode.get('ean13', x, writer=ImageWriter()) <indentation> filename = ean.save(x, options = {'text_distance':1, 'quiet_zone':2.5, module_height':6,'font_size':16})

x="770332600000" barcode_generator(x):

blutme avatar Sep 24 '19 06:09 blutme

Keeping this open as a reminder to improve the docs on this topic.

WhyNotHugo avatar Feb 25 '20 01:02 WhyNotHugo

As a side note, the text_distance option is the distance from the top of the barcode to the top of the text. I would have expected this to be the distance from the bottom of the barcode to the text instead, as it seems unlikely that the user would want the text and barcode to overlap.

toxicantidote avatar Jun 03 '22 01:06 toxicantidote

While using python-barcode I found that the text placement is incorrect. I believe text_distance is used correctly as the distance between the bottom of the barcode modules and the text but the text is drawn at the wrong place which means that for small text_distance values, the text overlaps on the barcode.

tytouf avatar Oct 05 '22 22:10 tytouf

I opened #177 and proposed a patch that fixes the issue when using small values of text_distance.

tytouf avatar Oct 05 '22 22:10 tytouf