oscar oscar - 2 months ago 11
Ruby Question

"Codabar" barcode generation seems not correct with rghost_barcode in ruby

I referred to here and ran the following code in ruby:

require 'rghost'
require 'rghost_barcode'

doc.barcode_rationalizedCodabar('515893649655',{:text=>{:size=>8}, :enable=>[:text, :checkintext, :check]})
doc.render :pdf, :resolution => 300, :filename => "barcode.pdf"

Below is the generated barcode:

enter image description here

The problem: I was not able to read this barcode with my barcode reader, and this barcode looks different from the one generated with online free barcode generator here:
enter image description here

You may notice the difference in the very first bars, where red rectangle.

I thought maybe this is because I was generating "rationalizedCodabar". But the article here says that it is the same as "Codabar".

Is there anyone who ever tried codabar generation successfully with ruby with whatever gem?

In general, I'm looking for an established barcode generator for Code39 and Codabar to generate barcodes within from RoR application.

I'm aware of the "barby" gem, but it seems it doesn't generate Codabar barcodes...


The Barcode Writer in Pure PostScript library that underpins Ruby Ghostscript Barcode requires that you specify the start/stop characters directly. In your web-generated example these are B and D but your application may require alternative start/stop characters, "B515893649655D":

doc.barcode_rationalizedCodabar('B515893649655D',{:text=>{:size=>8}, :enable=>[:text]})

Further documentation is available in the BWIPP wiki.