def make_barcode(code, code_type='ean13', rotate=None, height=50, xw=1): ''' XXX Micronaet adapt for manage EAN8 ''' if code: if code_type.lower()=='ean13': bar=EanBarCode() im = bar.getImage(code,height) elif code_type.lower() == 'ean8': EAN = barcode.get_barcode_class('EAN8') ean = EAN(code, writer=ImageWriter()) ean.default_writer_options['text_distance'] = 1 ean.default_writer_options['font_size'] = 20 ean.default_writer_options['quiet_zone'] = 1 im = ean.render() elif code_type.lower()=='code128': im = get_code(code, xw, height) elif code_type.lower()=='code39': im = create_c39(height, xw, code) else: return StringIO(), 'image/png' tf = StringIO() try: if rotate!=None: im=im.rotate(int(rotate)) except Exception, e: pass
def make_barcode(code, code_type='ean13', rotate=None, height=50, xw=1, width_factor=1.0): ''' width_factor nos sirve para hacerle mas pequenio, util para docs electronicos ''' if code: if code_type.lower() == 'ean13': bar = EanBarCode() im = bar.getImage(code, height) elif code_type.lower() == 'code128': im = get_code(code, xw, height) elif code_type.lower() == 'code39': im = create_c39(height, xw, code) else: return StringIO(), 'image/png' tf = StringIO() try: if rotate != None: im = im.rotate(int(rotate)) except Exception, e: pass
def make_barcode(code, code_type='ean13', rotate=None, height=50, xw=1): if code: if code_type.lower() == 'ean13': bar = EanBarCode() im = bar.getImage(code, height) elif code_type.lower() == 'code128': im = get_code(code, xw, height) elif code_type.lower() == 'code39': im = create_c39(height, xw, code) else: return StringIO(), 'image/png' tf = StringIO() try: if rotate != None: im = im.rotate(int(rotate)) except Exception, e: pass