WhyNotHugo / python-barcode

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

Barcode Text Size #169

Open svn-josh opened 2 years ago

svn-josh commented 2 years ago

Hello, i cant seem to find a way to increase the barcodetext size. Mine is pretty small now and needs to be bigger. can someone help?

import labels
from reportlab.graphics import shapes
from barcode import Code39
from barcode.writer import ImageWriter
import os

#Create Label Format(mm)
height = 100
width = 50
specs = labels.Specification(height, width, 1, 1, height, width)

#Draw Label
def draw_label(label, width, height, obj):
    # Just convert the object to a string and print this at the bottom left of
    # the label.
    label.add(shapes.Image(80, 25, width=200, height=100, path=obj))

# Create the sheet.
sheet = labels.Sheet(specs, draw_label, border=False)

#User Input
lager = int(input("Bitte das Lager angeben(z.b. 1-8):"))
regal = int(input("Bitte die Regal Nummer angeben(z.b. 10-80):"))
platz = int(input("Bitte die Platz Anzahl angeben(z.b. 0-30):"))
ebene = int(input("Bitte die Ebenen Anzahl angeben(z.b. 0-5):"))

# Add a couple of labels.
labelc = 0
ebenec = 0
platzc = 0
while True:
    barcode = f"{lager}{regal:02d}{platzc:02d}{ebenec}"
    barcodetext = f"{regal:02d}-{platzc:02d}-{ebenec:02d}"
    barcode39 = Code39(barcode, writer=ImageWriter(), add_checksum=False)
    barcode39.save(f"./temp/{lager}{regal:02d}{platzc:02d}{ebenec}", text=barcodetext)
    sheet.add_label(f"./temp/{lager}{regal:02d}{platzc:02d}{ebenec}.png")
    #os.remove(f"./temp/{lager}{regal:02d}{platzc:02d}{ebenec}.png")
    labelc += 1
    platzc += 1
    if platzc > platz:
        platzc = 1
        ebenec += 1
        if ebenec > ebene:
            break

# Save the file and we are done.
sheet.save(f'Lager-{lager}_Regal-{regal}.pdf')
for file in os.listdir("./temp"):
    if file.endswith(".png"):
        os.remove(f"./temp/{file}")

print("{0:d} label(s) output on {1:d} page(s).".format(sheet.label_count, sheet.page_count)) 
WhyNotHugo commented 2 years ago

See #17. PRs for this are welcome.