WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
572 stars 123 forks source link

Redable text under bars is cut out from the image #225

Closed santiagovassallo closed 6 months ago

santiagovassallo commented 6 months ago

Hello! I'm facing this issue

barras

This is the code snippet I've used

import barcode
Code128 = barcode.get_barcode_class('code128')
c = Code128('04480000001240013002404300002234825000000000000512005225165')
c.save('barras')

The thing is, all the codes I need to create are like that, meaning they are a string of 59 chars (digits actually) long.

I tested the bars with a reader and it works, however, the human readable part is cut short.

Is there any option I may be missing to fix this?

Thanks a lot!

WhyNotHugo commented 6 months ago

Did you manage to work around this?

santiagovassallo commented 6 months ago

Yes, sorry! I should have posted how I did it when I closed this. Here it is!

   ...
    encoder = barcode.get_barcode_class('code128')
    codigo_128 = encoder(codigo, writer=ImageWriter())
    buffer = BytesIO()
    codigo_128.write(buffer, options={'font_size': 6})
   ...

It was just a matter or changing the font size from the default 10 to something smaller. Thanks man!