python-barcode
python-barcode copied to clipboard
How to remove the text
Hi i would like to know how to remove the text from under the barcodes, to have only the barcode, no text.
Hello! How do you run the command? For example:
- python-barcode create "123456789000" outfile -b ean will generate barcode without any text.
Ideally, this should be exposed as a flag that both the ImageWriter and SVGWriter expose.
Until I get a change to implement that, as a hack, you can use this writer:
class ImageWitoutTextWriter(ImageWriter):
def _paint_text(self, xpos, ypos):
pass
Hello, I came across this issue by reading the documentation as well but eventually discovered by looking at the source that there is in fact an option called write_text=True in the base writer options.
You should update your documentation so people know it exists.
Keep up the good work
Just write these lines before your code
from barcode.base import Barcode
Barcode.default_writer_options['write_text'] = False
It looks like this is a duplicate of #24. @WhyNotHugo, would you accept a PR with the code given there?
Ideally, this should be exposed as a flag that both the ImageWriter and SVGWriter expose.
Until I get a change to implement that, as a hack, you can use this writer:
class ImageWitoutTextWriter(ImageWriter): def _paint_text(self, xpos, ypos): pass
Works for me! God Bless You, I really Thank you! I look a lot for something like that, you solved it easily. I still don't understand how it works, but it solved my big problem :D
Pra quem procura algo em português, esse é meu código que gera a imagem sem o texto do código de barras:
from barcode.writer import ImageWriter
class ImageWitoutTextWriter(ImageWriter):
def _paint_text(self, xpos, ypos):
pass
ean = barcode.get('ean13', '123456789102', writer=ImageWitoutTextWriter())
filename = ean.save('ean13')
filename
'ean13.png'
from barcode.base import Barcode Barcode.default_writer_options['write_text'] = False
its works
Closing as dupe of #24. PRs welcome.