From 25a8009558e89da19bf99d756e437722c2566a79 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 26 Jan 2011 17:54:10 +0100 Subject: [PATCH] add barcodes python script --- barcodes.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 barcodes.py diff --git a/barcodes.py b/barcodes.py new file mode 100755 index 0000000..ef6c2fa --- /dev/null +++ b/barcodes.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +# +# requires zint binary from zint package +# + +from subprocess import Popen, PIPE +import sys + +svghead = """ + +""" + +svgfoot = """ + +""" + +if len(sys.argv) > 1: + start = int(sys.argv[1]) +else: + start = 0 +cntx = 7 +cnty = 10 +scalex = 1 +scaley = 0.8 + +f = open('barcodes.svg','w') +f.write(svghead) + +for i in range(cntx): + for j in range(cnty): + elem = Popen(('zint','--directsvg','-d','%06d' % (start+i*cnty+j) ), stdout = PIPE).communicate()[0].split('\n') + elem = elem[8:-2] + elem[0] = elem[0].replace('id="barcode"', 'transform="matrix(%f,0,0,%f,%f,%f)"' % (scalex, scaley, 42+i*150 , 14+j*74.3) ) + elem[23] = 'brm - ' + elem[23].strip() + ' - lab' + f.write('\n'.join(elem)) + +f.write(svgfoot) +f.close()