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

Custom text

Open heiwanokami opened this issue 5 years ago • 2 comments

would it be possible to create feature to include different text than the label says. i.e. label is ABC-123 and I would like to print under the barcode only 123. thx

heiwanokami avatar Jun 18 '20 11:06 heiwanokami

EAN8(label).write(f, {'write_text': False, 'text': "%s\n123. thx" % (label)})

'write_text': False makes it turn off the default text. 'text': "my new text" changes the default text to that new text.

Turn off the default then turn, write your own, including the original label.

tatarize avatar Aug 15 '20 17:08 tatarize

I couldn't get this inline method working. I was able to get @QuickLearner171998 's method to work.

To adapt it to this scenario, it'd look like:

#Put this under the `import` statement but above your code
barcode.default_writer_options['write_text'] = False
barcode.default_writer_options['text'] = "my new text"

SeaDude avatar Dec 28 '20 02:12 SeaDude