Skip to content

Instantly share code, notes, and snippets.

@boniattirodrigo
Forked from mmmattos/barcode_i2of5_sample.py
Created November 27, 2015 16:19
Show Gist options
  • Select an option

  • Save boniattirodrigo/6bb694e1accca5c092f5 to your computer and use it in GitHub Desktop.

Select an option

Save boniattirodrigo/6bb694e1accca5c092f5 to your computer and use it in GitHub Desktop.
Creating Barcodes for Brazilian Banking using Python and Reportlab
# Sample i2of5 barcode generation.
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.graphics.barcode.common import I2of5
c=canvas.Canvas("barcode_example.pdf",pagesize=A4)
tb=0.254320987654 * mm # thin bar
bh=20 * mm # bar height
bcl=180 * mm # barcode length
digits = "04198000000000000002131008609000127646104171"
bc=I2of5(digits,barWidth=tb,ratio=3,barHeight=bh,bearers=0,quiet=0,checksum=0)
# Adjust the width
tb = (tb * bcl) / bc.width
bc.__init__(digits, barWidth=tb)
# Render the bc image 5mm from bottom of the page.
bc.drawOn(c,5*mm,5*mm)
c.showPage()
c.save()
@salatiel

salatiel commented Aug 5, 2023

Copy link
Copy Markdown

It not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment