Skip to content

Instantly share code, notes, and snippets.

@driscollis
Created March 5, 2018 21:16
Show Gist options
  • Save driscollis/426e5a1e916dfcf278e2ba56376e7023 to your computer and use it in GitHub Desktop.
Save driscollis/426e5a1e916dfcf278e2ba56376e7023 to your computer and use it in GitHub Desktop.
# eanbc_demo.py
from reportlab.graphics.barcode import eanbc
from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet
def eanbc_demo(barcode_value):
doc = SimpleDocTemplate('eanbc_demo.pdf')
styles = getSampleStyleSheet()
flowables = []
flowables.append(Paragraph('EAN-8 code:',
style=styles['Normal']))
barcode = eanbc.Ean8BarcodeWidget(barcode_value)
flowables.append(barcode)
doc.build(flowables)
if __name__ == "__main__":
eanbc_demo('123456789')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment