Example #1
0
i = 0
j = 0
f = None

lines = sys.stdin.readlines()

for idx in xrange(len(lines)):
    items = lines[idx].strip().split(';')
    if idx % 30 == 0:
        if f and not f.closed:
            f.write(svgfoot)
            f.close()
        f = open('barcodes' + str(p) + '.svg','w')
        p += 1
        i = 0
        j = 0
        f.write(svghead)
    elem = Popen(('./zint','--directsvg','--notext', '-d', items[1]), 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, 50+i*140 , 180+j*140) )
    elem.insert(-1, '      <text x="39.50" y="69.00" text-anchor="middle" font-family="Helvetica" font-size="14.0" fill="#000000" >%s</text>' % items[0])
    f.write('\n'.join(elem)+'\n\n')
    i += 1
    if i >= width:
        i = 0
        j += 1

if not f.closed:
    f.write(svgfoot)
    f.close()