コード例 #1
0
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
コード例 #2
0
ファイル: barcode.py プロジェクト: Micronaet/micronaet-aeroo
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
コード例 #3
0
ファイル: PTGenerator.py プロジェクト: nickdotcat/pricetagman
def drawBarcode(basePic, barcode):
	try:
		print '======> 绘制条形码', barcode.title
		bar = EanBarCode()
		im = bar.getImage(barcode.codeNumber)
		basePic.paste(im, tuple(barcode.position))
		return basePic
	except Exception:
		raise Exception, 'E-010: 绘制条形码失败,请检查配置是否正确'
コード例 #4
0
ファイル: barcode.py プロジェクト: danielharbor/openerp
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
コード例 #5
0
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