Skip to content

Instantly share code, notes, and snippets.

@doobeh
Created December 21, 2011 19:44
Show Gist options
  • Save doobeh/1507381 to your computer and use it in GitHub Desktop.
Save doobeh/1507381 to your computer and use it in GitHub Desktop.
Basic Reportlab barcode/label code.
x = marginLeft + (j*labelWidth)
y = marginTop + (i*labelHeight)
c.setFillColorCMYK(0,0,0,1)
c.setFont("Helvetica",12)
c.drawString(x + (10 * mm), y + (21 * mm), item.product.upper())
drawing = Drawing()
barcode = Ean13BarcodeWidget()
barcode.value = str(item.upc[1::])
barcode.barHeight = 12 * mm
barcode.barWidth = 0.95
barcode.fontSize = 6
drawing.add(barcode)
drawing.drawOn(c,x + (10 * mm), y + (8 * mm))
c.setFont("Helvetica",7)
c.drawString(x + (10 * mm), y + (4 * mm), item.serial)
c.showPage()
c.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment