Sistema de Apoio ao Processo Legislativo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
1002 B

from reportlab.lib.units import mm
from reportlab.graphics.barcode import createBarcodeDrawing
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics.charts.barcharts import HorizontalBarChart
class BarcodeDrawing(Drawing):
def __init__(self, text_value, *args, **kw):
barcode = createBarcodeDrawing(
'Code128', value=text_value, barHeight=10 * mm, humanReadable=True)
Drawing.__init__(self, barcode.width, barcode.height, *args, **kw)
self.add(barcode, name='barcode')
# def barcode(request):
# #instantiate a drawing object
# import barcode
# d = barcode.BarcodeDrawing("HELLO WORLD")
# binaryStuff = d.asString('gif')
# return HttpResponse(binaryStuff, 'image/gif')
if __name__ == '__main__':
# use the standard 'save' method to save barcode.gif, barcode.pdf etc
# for quick feedback while working.
BarcodeDrawing("HELLO WORLD").save(
formats=['gif', 'pdf'], outDir='.', fnRoot='barcode')