[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Tore Darell

4/21/2008 6:03:00 PM

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/t...

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....
7 Answers

Mikel Lindsaar

4/22/2008 10:14:00 AM

0

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

Tore Darell

4/23/2008 8:09:00 AM

0

On Apr 22, 12:13 pm, Mikel Lindsaar <raasd...@gmail.com> wrote:
> On Tue, Apr 22, 2008 at 4:05 AM, Tore Darell <toredar...@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

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&releas...

Tore

Foreero Ivan

4/23/2008 7:09:00 PM

0

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&releas...
>
> Tore

--
Posted via http://www.ruby-....

Foreero Ivan

4/25/2008 6:34:00 PM

0

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 <ivm...@gmail.com> 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 <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&releas...
>
> > Tore
>
> --
> Posted viahttp://www.ruby-....

Ramon Cahenzli

6/13/2008 6:15:00 AM

0

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...

Or straight in svn:

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

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-....

Tore Darell

7/12/2008 4:21:00 PM

0

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

Kevin Marsh

12/18/2008 11:40:00 PM

0

[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 <toredarell@gmail.com> wrote:

> 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
>
>