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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
835294a2661ef37b591e5618e5a7b4b2?d=identicon&s=25 Tore Darell (Guest)
on 2008-04-21 20:11
(Received via mailing list)
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.
Fb1a6916e06f221b5b53a6665f9858eb?d=identicon&s=25 Mikel Lindsaar (Guest)
on 2008-04-22 12:14
(Received via mailing list)
On Tue, Apr 22, 2008 at 4:05 AM, Tore Darell <toredarell@gmail.com>
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
835294a2661ef37b591e5618e5a7b4b2?d=identicon&s=25 Tore Darell (Guest)
on 2008-04-23 10:11
(Received via mailing list)
On Apr 22, 12:13 pm, Mikel Lindsaar <raasd...@gmail.com> 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
9c93e8b4826699f1de1180b79a546d53?d=identicon&s=25 Foreero Ivan (ivmafo)
on 2008-04-23 21:08
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 <raasd...@gmail.com> 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
9c93e8b4826699f1de1180b79a546d53?d=identicon&s=25 Foreero Ivan (ivmafo)
on 2008-04-25 20:35
(Received via mailing list)
Please somebody can help me , I'm new with ruby , can anybdy tell me
how use barby with PDF's documents ?

Thanks
38679f9f3d546cc3214bf02e560fc2d0?d=identicon&s=25 Ramon Cahenzli (psy-q)
on 2008-06-13 08:15
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
835294a2661ef37b591e5618e5a7b4b2?d=identicon&s=25 Tore Darell (Guest)
on 2008-07-12 18:25
(Received via mailing list)
On Jun 13, 8:15 am, Ramon Cahenzli <ramon.cahen...@gmail.com> 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
6a2f7f7a997fab1dbf815d155cca50ee?d=identicon&s=25 Kevin Marsh (Guest)
on 2008-12-19 00:48
(Received via mailing list)
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
D55ae6fa9fa065e1f6e6df74459264f5?d=identicon&s=25 Andy Tolle (durexlw)
on 2011-02-07 19:37
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.
797ef431a5e1295b56c08e1db4c8d2df?d=identicon&s=25 botp (Guest)
on 2011-02-08 03:52
(Received via mailing list)
On Tue, Apr 22, 2008 at 2:05 AM, Tore Darell <toredarell@gmail.com>
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
This topic is locked and can not be replied to.