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

How to remove the text

Open upriche opened this issue 5 years ago • 8 comments

Hi i would like to know how to remove the text from under the barcodes, to have only the barcode, no text.

upriche avatar Dec 09 '19 16:12 upriche

Hello! How do you run the command? For example:

  • python-barcode create "123456789000" outfile -b ean will generate barcode without any text.

tokt avatar Dec 10 '19 16:12 tokt

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

WhyNotHugo avatar Feb 25 '20 01:02 WhyNotHugo

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

crowdawg avatar May 05 '20 04:05 crowdawg

Just write these lines before your code

    from barcode.base import Barcode
    Barcode.default_writer_options['write_text'] = False

QuickLearner171998 avatar May 23 '20 20:05 QuickLearner171998

It looks like this is a duplicate of #24. @WhyNotHugo, would you accept a PR with the code given there?

nabelekt avatar Mar 18 '21 05:03 nabelekt

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

NatanBudny avatar Jul 16 '21 14:07 NatanBudny

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'


NatanBudny avatar Jul 16 '21 14:07 NatanBudny

from barcode.base import Barcode Barcode.default_writer_options['write_text'] = False its works

ahmedtouahria avatar Jul 01 '22 14:07 ahmedtouahria

Closing as dupe of #24. PRs welcome.

WhyNotHugo avatar Aug 30 '22 15:08 WhyNotHugo