Zint


This is a Ruby FFI wrapper for the Zint barcode generation library (www.zint.org.uk/zintSite). You must have Zint installed on your system for this gem to work at all. Note that this is an alpha release and just gets the essentials done. fork the code and add tests of more barcode coverage.

Install

As mentioned, you must install the zint project to be able to use this gem. Once that dependency is satisfied, then you can just do the usual gem install.

gem install zint

Usage

Summary

require 'zint'
# Create a code-128 barcode
bc = Zint::Barcode.new("test")
bc.print! # file is now on relative path "out.png"
bc.path = "my_bc.png"
bc.print! # file is now on relative path "my_bc.png"
bc.path = "my_bc.svg"
bc.print!
bc.print! # file is now on relative path "my_bc.svg"

# create a qrcode
qrcode = Zint::Barcode.new("test", Zint::BARCODE_QRCODE)
qrcode.path = "qrcode.png"
qrcode.print! # file is now on relative path "qrcode.png"
qrcode_string = qrcode.buffer!
puts qrcode_string

#QRCode with more options, specifically set a high error correction capacity
qrcode = Zint::QRCode.new("test", Zint::QRCode::ECC_H)
qrcode.path = "qrcode.ecc_h.png"
qrcode.print! # file is now on relative path "qrcode.ecc_h.png"
# encode barcode as text
qrcode.path = "qrcode.ecc_h.txt"
puts qrcode.buffer!

TODO: Add more documentation