Barby

Barby is a Ruby library that generates barcodes in a variety of symbologies.

Its functionality is split into barcode and “outputter” objects: * Barby::Barcode objects turn data into a binary representation for a given symbology. * Barby::Outputter then takes this representation and turns it into images, PDF, etc.

You can easily add a symbology without having to worry about graphical representation. If it can be represented as the usual 1D or 2D matrix of lines or squares, outputters will do that for you.

Likewise, you can easily add an outputter for a format that doesn’t have one yet, and it will work with all existing symbologies.

For more information, check out the Barby wiki.

New require policy

Barcode symbologies are no longer required automatically, so you’ll have to require the ones you need.

If you need EAN-13, require 'barby/barcode/ean_13'. Full list of symbologies and filenames below.

Example

“by require ‘barby’ require ‘barby/barcode/code_128’ require ‘barby/outputter/ascii_outputter’

barcode = Barby::Code128B.new(‘BARBY’)

puts barcode.to_ascii #Implicitly uses the AsciiOutputter

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

# # # # ## # # ## ## # ### # # ## ### ## # ## ### ### ## ### #

      B          A          R          B          Y

Supported symbologies

“by require ‘barby/barcode/

Maruku could not parse this XML/HTML: 
<filename>'

NameFilenameDependencies
Code 25code_25
├─ Interleavedcode_25_interleaved
└─ IATAcode_25_iata
Code 39code_39
Code 93code_93
Code 128code_128
└─ GS1 128gs1_128
EAN-13ean_13
├─ Booklandbookland
└─ UPC-Aean_13
EAN-8ean_8
UPC/EAN supplemental, 2 & 5 digitsupc_supplemental
QR Codeqr_coderqrcode
DataMatrix (Semacode)data_matrixsemacode
PDF417pdf_417JRuby

Outputters

“by require ‘barby/outputter/

Maruku could not parse this XML/HTML: 
<filename>_outputter'

filenamedependencies
ascii
cairocairo
html
pdfwriter
pngchunky_png
prawnprawn
rmagickRMagick
svg

Formats supported by outputters

  • Text (mostly for testing)
  • PNG, JPEG, GIF
  • PS, EPS
  • SVG
  • PDF
  • HTML

For more information, check out the Barby wiki.