mirror of https://github.com/interlegis/sapl.git
Edward Ribeiro
9 years ago
5 changed files with 122 additions and 31 deletions
@ -0,0 +1,27 @@ |
|||
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') |
Loading…
Reference in new issue