Generating a barcode in a PDF for Rails with Prawnto and barcode-generator
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.
After a few searches i found barcode-generator from anujluthra.
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'))


3 Comments
comments rss [?] | trackback uri [?]Can you tell me where to find out about barcode scanning hardware that could be used with your project?
Exactly what I needed. Thanks!
The barcode that is displayed using this is blurred. have been told that barcode readers cannot read them.
Submit your comment
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>