Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generate barcode with reportlab.
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
#I"ll be generating code39 barcodes, others are available
from import code39
# generate a canvas (A4 in this case, size doesn"t really matter)
# create a barcode object
# (is not displayed yet)
# The encode text is "123456789"
# barHeight encodes how high the bars will be
# barWidth encodes how wide the "narrowest" barcode unit is
# drawOn puts the barcode on the canvas at the specified coordinates
# now create the actual PDF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment