A simple way of generating barcodes.
For a project i needed to generate a barcode image in a PDF invoice. I was already using Prawnto to generate the PDF and needed a way to generate a barcode image to use with Prawnto.
Install the gbarcode gem and ImageMagic.
if your are on OSX and get the following error: “sh: gs: command not found” then you don’t have postscript installed. Install Postscript trough Port. (port install postscript)
I found out that Prawnto really likes absolute file system paths instead of relative image tags that barcode-generator returns, so i forked the project on GitHub and added a new option to return the file system path instead of an image tag.
My fork can be found at: http://github.com/matsimitsu/barcode-generator/tree/master and can be installed as a plugin with:
script/install plugin git://github.com/matsimitsu/barcode-generator.git
To use this all in Prawnto use the following code:
pdf.image(barcode('FJJ4JD', :output_method => 'full_path'))