[ANN] Barby 0.1 - Ruby barcode generator that doesn't suck (thatmuch)

Discussion in 'Ruby' started by Tore Darell, Apr 21, 2008.

  1. Tore Darell

    Tore Darell Guest

    This is something I released a while ago, but I thought I'd announce
    it here too, as I'm sure not everyone in the target group reads my
    blog.

    Barby is a pure Ruby barcode generator. It doesn't rely on 3rd party
    libraries (well, unless you want it to do anything useful) and it's
    easily extensible. It currently supports the following symbologies:

    * Code128
    * GS1128 (aka EAN/UCC-128)
    * EAN-13 (aka UPC-A)
    * Bookland
    * EAN-8
    * Code39

    The logic for generating graphical representations of the barcodes is
    split into "outputters". There are currently two outputters, one that
    uses RMagick and another that annotates a PDF/Writer document, and
    creating new ones is easy.

    Some sample code:


    require 'barby'
    require 'barby/outputter/rmagick_outputter'

    barcode = Barby::Code128B.new('IM-IN-UR-BARCODE')

    File.open('test.png', 'w') do |f|
    f.write barcode.to_png
    end


    Barby is available as a gem (gem install barby) and from
    http://github.com/toretore/barby/tree/master

    If you feel like adding support for more symbologies, let me know and
    I'll put it into the "official" repo. If you spec it too, that's
    doubly awesome.


    --
    Tore Darell
    http://tore.darell.no/
     
    Tore Darell, Apr 21, 2008
    #1
    1. Advertising

  2. Re: [ANN] Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    On Tue, Apr 22, 2008 at 4:05 AM, Tore Darell <> wrote:
    > barcode = Barby::Code128B.new('IM-IN-UR-BARCODE')
    > File.open('test.png', 'w') do |f|
    > f.write barcode.to_png
    > end


    Heh... I just showed this to a work associate of mine who has been
    writing barcodes out directly to an epson printer comm spec.

    He almost fell over in shock.

    I love Ruby :)

    By the way:

    baci:~ mikel$ date
    Tue Apr 22 20:12:57 EST 2008
    baci:~ mikel$ sudo gem install barby
    Password:
    ERROR: could not find barby locally or in a repository

    Maybe still flowing into the gem servers?


    Mikel
     
    Mikel Lindsaar, Apr 22, 2008
    #2
    1. Advertising

  3. Tore Darell

    Tore Darell Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    On Apr 22, 12:13 pm, Mikel Lindsaar <> wrote:
    > On Tue, Apr 22, 2008 at 4:05 AM, Tore Darell <> wrote:
    > > barcode = Barby::Code128B.new('IM-IN-UR-BARCODE')
    > > File.open('test.png', 'w') do |f|
    > > f.write barcode.to_png
    > > end

    >
    > Heh... I just showed this to a work associate of mine who has been
    > writing barcodes out directly to an epson printer comm spec.
    >
    > He almost fell over in shock.
    >
    > I love Ruby :)
    >
    > By the way:
    >
    > baci:~ mikel$ date
    > Tue Apr 22 20:12:57 EST 2008
    > baci:~ mikel$ sudo gem install barby
    > Password:
    > ERROR: could not find barby locally or in a repository
    >
    > Maybe still flowing into the gem servers?
    >
    > Mikel


    Hm, it's a while now since I uploaded it to RF, so it should work.
    This is my first gem on RF, so I might not have done everything right,
    but it works for me now, and has before too.. Hopefully (or, hopefully
    not, probably) it's just some sort of server hickup.

    The gem file is here: http://rubyforge.org/frs/?group_id=5831&release_id=20294

    Tore
     
    Tore Darell, Apr 23, 2008
    #3
  4. Tore Darell

    Foreero Ivan Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    Does it work with PDF ??? how ??

    I try to run this

    require 'barby'
    require 'barby/outputter/rmagick_outputter'

    barcode = Barby::Code128B.new('IM-IN-UR-BARCODE')

    File.open('test.png', 'w') do |f|
    f.write barcode.to_png
    end


    but ruby says me that
    barby.rb:8: uninitialized constant Barby::Code128B (NameError)
    what I doing wrong??






    Tore Darell wrote:
    > On Apr 22, 12:13 pm, Mikel Lindsaar <> wrote:
    >>
    >> Maybe still flowing into the gem servers?
    >>
    >> Mikel

    >
    > Hm, it's a while now since I uploaded it to RF, so it should work.
    > This is my first gem on RF, so I might not have done everything right,
    > but it works for me now, and has before too.. Hopefully (or, hopefully
    > not, probably) it's just some sort of server hickup.
    >
    > The gem file is here:
    > http://rubyforge.org/frs/?group_id=5831&release_id=20294
    >
    > Tore


    --
    Posted via http://www.ruby-forum.com/.
     
    Foreero Ivan, Apr 23, 2008
    #4
  5. Tore Darell

    ivmafo Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    Please somebody can help me , I'm new with ruby , can anybdy tell me
    how use barby with PDF's documents ?

    Thanks







    On Apr 23, 2:09 pm, Foreero Ivan <> wrote:
    > Does it work with PDF ??? how ??
    >
    > I try to run this
    >
    > require 'barby'
    > require 'barby/outputter/rmagick_outputter'
    >
    > barcode = Barby::Code128B.new('IM-IN-UR-BARCODE')
    >
    > File.open('test.png', 'w') do |f|
    >   f.write barcode.to_png
    > end
    >
    > but ruby says me that
    > barby.rb:8: uninitialized constant Barby::Code128B (NameError)
    > what I doing wrong??
    >
    >
    >
    > Tore Darell wrote:
    > > On Apr 22, 12:13 pm, Mikel Lindsaar <> wrote:

    >
    > >> Maybe still flowing into the gem servers?

    >
    > >> Mikel

    >
    > > Hm, it's a while now since I uploaded it to RF, so it should work.
    > > This is my first gem on RF, so I might not have done everything right,
    > > but it works for me now, and has before too.. Hopefully (or, hopefully
    > > not, probably) it's just some sort of server hickup.

    >
    > > The gem file is here:
    > >http://rubyforge.org/frs/?group_id=5831&release_id=20294

    >
    > > Tore

    >
    > --
    > Posted viahttp://www.ruby-forum.com/.
     
    ivmafo, Apr 25, 2008
    #5
  6. Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    Foreero Ivan wrote:
    > Please somebody can help me , I'm new with ruby , can anybdy tell me
    > how use barby with PDF's documents ?


    It's not the only way, but if you're using Ruby FPDF, I've written a
    small extension that can print Barby codes into FPDF-generated PDFs:

    http://rca.vmk.zhdk.ch/blog/software/

    Or straight in svn:

    http://code.zhdk.ch/svn/leihs/trunk/lib/fpdf/fpdf_barby.rb

    The next feature I'll add is that you can specify the maximum width of
    barcodes, as some applications apparently require this.

    The code is not very Rubyish as you'll see, but we can't really help it.
    With Ruby FPDF we're stuck in a world where Ruby speaks PHP, so which
    way around should an FPDF extension think? This one is messed up in its
    head and tries to do both, with variables in all sorts of casings. I'll
    have to clean that up. Also, some more error handling would be nice.

    We'll be starting to use this in production with several ten thousand
    barcodes in Code 128A and Code 39, because we soon need to put together
    a batch labeling feature for our inventory system, so I'm sure it'll
    improve a bit then :)

    Let me know how and if it works for you, against all odds.

    Ramon
    --
    Posted via http://www.ruby-forum.com/.
     
    Ramon Cahenzli, Jun 13, 2008
    #6
  7. Tore Darell

    Tore Darell Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    On Jun 13, 8:15 am, Ramon Cahenzli <> wrote:
    > Foreero Ivan wrote:
    > > Please somebody can help me , I'm new with ruby , can anybdy tell me
    > > how use barby with PDF's documents ?

    >
    > It's not the only way, but if you're using Ruby FPDF, I've written a
    > small extension that can print Barby codes into FPDF-generated PDFs:



    Also, if you're using PDF::Writer, there's built-in support for that:


    require 'barby'
    require 'barby/outputter/pdfwriter_outputter'

    pdf = PDF::Writer.new
    barcode = Barby::Code128B.new('humbaba')
    barcode.annotate_pdf(pdf)


    The CairoOutputter can generate PDFs from scratch if you for some
    reason want that:


    require 'barby/outputter/cairo_outputter'

    File.open('test.pdf'){|f| f << barcode.to_pdf }


    In the git repo there's an experimental PrawnOutputter that can both
    annotate and generate PDFs using Prawn.

    Tore
     
    Tore Darell, Jul 12, 2008
    #7
  8. Tore Darell

    Kevin Marsh Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    [Note: parts of this message were removed to make it a legal post.]

    Hate to resurrect an old thread, but I got this to work with Prawn, and it's
    pretty slick.
    (This is in a prawnto/Rails view)

    require 'barby'
    require 'barby/outputter/prawn_outputter'

    pdf.bounding_box [450,700], :width => 100 do
    barcode = Barby::Code39.new(@order.order_identifier)
    barcode.annotate_pdf(pdf, :height => 30)
    end

    Plops a nice vector barcode right there. Really slick!

    Kevin

    On Sat, Jul 12, 2008 at 11:20 AM, Tore Darell <> wrote:

    > On Jun 13, 8:15 am, Ramon Cahenzli <> wrote:
    > > Foreero Ivan wrote:
    > > > Please somebody can help me , I'm new with ruby , can anybdy tell me
    > > > how use barby with PDF's documents ?

    > >
    > > It's not the only way, but if you're using Ruby FPDF, I've written a
    > > small extension that can print Barby codes into FPDF-generated PDFs:

    >
    >
    > Also, if you're using PDF::Writer, there's built-in support for that:
    >
    >
    > require 'barby'
    > require 'barby/outputter/pdfwriter_outputter'
    >
    > pdf = PDF::Writer.new
    > barcode = Barby::Code128B.new('humbaba')
    > barcode.annotate_pdf(pdf)
    >
    >
    > The CairoOutputter can generate PDFs from scratch if you for some
    > reason want that:
    >
    >
    > require 'barby/outputter/cairo_outputter'
    >
    > File.open('test.pdf'){|f| f << barcode.to_pdf }
    >
    >
    > In the git repo there's an experimental PrawnOutputter that can both
    > annotate and generate PDFs using Prawn.
    >
    > Tore
    >
    >
     
    Kevin Marsh, Dec 18, 2008
    #8
  9. Tore Darell

    Andy Tolle Guest

    Re: Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    To whoever wrote this application/extension, I'd like to express my
    gratitude. I'm facing an issue where barcodes could be the solution...
    especially how these barcodes can be outputted to PDF is hopeful to me,
    so I'm looking forward putting it to the test... anyway, without your
    collective efforts, I'd had little to test, so thanks a bunch.

    Regards,
    A.

    --
    Posted via http://www.ruby-forum.com/.
     
    Andy Tolle, Feb 7, 2011
    #9
  10. Tore Darell

    botp Guest

    Re: [ANN] Barby 0.1 - Ruby barcode generator that doesn't suck (that much)

    On Tue, Apr 22, 2008 at 2:05 AM, Tore Darell <> wrote:
    > This is something I released a while ago, but I thought I'd announce


    Hi, you mentioned a ver 0.1 but we got a ver0.4.2. Are they the same gem?

    thanks for barby (very nice name btw)
    best regards -botp
     
    botp, Feb 8, 2011
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tore Darell

    [ANN] Barby 0.2.0

    Tore Darell, Jul 16, 2008, in forum: Ruby
    Replies:
    2
    Views:
    117
    Tore Darell
    Jul 17, 2008
Loading...

Share This Page