Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Wednesday, July 13, 2011

Generate BarCode in Python

You can Generate Barcode (image, Pdf Etc...) in Python
Example is for JPG file
from reportlab.graphics.barcode import createBarcodeDrawing, \
getCodes
def get_image(self, value, width, hight, hr, code='QR'):
""" genrating image for barcode """
options = {}

if width:options['width'] = width
if hight:options['hight'] = hight
if hr:options['humanReadable'] = hr
try:
ret_val = createBarcodeDrawing(code, value=value,
**options)
except Exception, e:
raise osv.except_osv('Error', e)
return ret_val.asString('jpg')


To get Supported barcode in your system

$ print getCodes()

reference : report lab