writing barcodes to a window using only clientside javascript

D

dan

I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
<img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode. The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it. This should be free software
(gpl or other free license). It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.

Thanks in advance for any info or advice about this, or even a good
way to google for an existing free software solution.

dan
 
R

RobG

I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
<img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode. The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it. This should be free software
(gpl or other free license). It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.

Thanks in advance for any info or advice about this, or even a good
way to google for an existing free software solution.


It depends on what you want, there are dozens of different types of
bar codes[1]


I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
<img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode. The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it. This should be free software
(gpl or other free license). It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.

Thanks in advance for any info or advice about this, or even a good
way to google for an existing free software solution.

dan

I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
<img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode. The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it. This should be free software
(gpl or other free license). It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.

Thanks in advance for any info or advice about this, or even a good
way to google for an existing free software solution.

dan

I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
<img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode. The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it. This should be free software
(gpl or other free license). It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.


Support for multiple browsers should be trivial, however there are
dozens of different types of bar codes [1]. If you want just one type
of 2D bar code, then likely it won't take much to write a function to
generate them using div elements to create a graphic. If you want to
support multiple bar code types, life gets more difficult. Which one
(s) do you want?

1. <URL: http://www.makebarcode.com/specs/barcodechart.html >
 
D

dan

Support for multiple browsers should be trivial, however there are
dozens of different types of bar codes [1]. If you want just one type
of 2D bar code, then likely it won't take much to write a function to
generate them using div elements to create a graphic. If you want to
support multiple bar code types, life gets more difficult. Which one
(s) do you want?

1. <URL:http://www.makebarcode.com/specs/barcodechart.html>

Hi Rob,

Thanks for your post.

You are right, i should have mentioned which code i'm interested in.

It is 128 (linear, not 2d).

I don't know how hard it would be to handcraft software to do this,
but i would like to use a piece of free software (free as in
freedom) which already exists.

In fact, i am already doing this---i'm using the gnu apparatus
http://www.gnu.org/software/barcode/
I am using it through PHP-Barcode:
http://www.ashberg.de/php-barcode/

It is free software, and very high quality.

However, in order to use it, i have to have a separate piece of
server software running.

I would like to generate all in one process without having
to call out to any external program.

If i can avoid writing any new code i would like to do so. New
code means new errors and new debugging. So if a free software
solution already exists, i would like to use it.

Since genbarcode does exist (C code), i imagine that there may
very well be a piece of pure javascript code which also
exists as free software.

That's why i would appreciate any pointers to a piece of
free-as-in-freedom javascript which draws barcodes.

Thanks in advance if you or anybody else can point me to
such a piece of code.

dan
 
D

dan

I can't believe you asked that!

I'll give you a clue, it involves typing the words
javascript barcode
into the google search box!

http://lmgtfy.com/?q=javascript+barcode

Hi Captain,

I really like your demo of searching for javascript and barcode in
google.

It is slick. Make that "Slick!!!".

Unfortunately, even your slick way of doing it provides THREE MILLION
hits.

As far as i can tell, 99.9% of them (or maybe all of them) are for
proprietary products.

I already have a mixed language solution made entirely of free
software. (But what i would like is a one-language solution.)

Adding search terms like "gnu" or "free software" helps some, but
tends to just produce pages that list both free and proprietary
products (of which the javascript ones are not free).

But in any event, thanks for that demo, which shows that you're
far more connected to this world than i am.

And if you know of any free-as-in-freedom pure-javascript barcode
generation software, please inform me of it. Even in a plain,
boring, humdrum URL type of way.

dan

PS: Just for reference, the packages i am using are very high
quality. I should have mentioned them for reference:

http://www.gnu.org/software/barcode/
http://www.ashberg.de/php-barcode/

And i only need this to work for code 128, and only on firefox 3.
 
C

Captain Paralytic

Hi Captain,

I really like your demo of searching for javascript and barcode in
google.

It is slick.  Make that "Slick!!!".

Unfortunately, even your slick way of doing it provides THREE MILLION
hits.

As far as i can tell, 99.9% of them (or maybe all of them) are for
proprietary products.
And what was wrong with the very first hit? It seems to do precisely
what you asked for in your post.
 
D

dan

And what was wrong with the very first hit? It seems to do precisely
what you asked for in your post.

Well, the very first hit is like 99.9% (or maybe 100%??) of the
others:
it is not free-as-in-freedom software.

I have a solution now of 100% free-as-in-freedom software, but it is
mixed language: i would like to go to a pure client-side solution,
using only free-as-in-freedom software.

However, i certainly appreciate your feedback, and your slick demo.
As i say, you are really connected to this milieu.

And if you can point to a free-as-in-freedom software solution
(see http://www.gnu.org/philosophy/free-sw.html from the
awesome Free Software Foundation [http://www.fsf.org/])
i would appreciate it.

dan
 
D

dan


Carlos --- thank you so much.

It wasn't the first hit on mine --- i got one of those ID Automation
things.

Now, this is EAN, and i want code 128, but the idea is exactly right:
the
page draws the graphics without having to do a GET from something
else.

If somebody knows of a 128, please let me know, but i can look at this
anyway to see if i can adapt it.

Thanks again!

dan
 
B

Bart Van der Donck

dan said:
I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Right now i'm creating the the barcodes by essentially
generating html snippets of the form
  <img src="http://path/to/gnubarcode/based/software?code=.....">
i.e., i'm essentially serving the barcodes from another script.

But this is pretty unsatisfactory because it forces a pure
clientside routine to have to go out and rely on some web server
to get an image of a barcode.  The clients are all running on
machines that have plenty of horsepower for generating barcodes.

So i'm looking for some javascript library that can take a string
and generate a barcode for it.  This should be free software
(gpl or other free license).  It only has to work on firefox 3, i.e.,
i'm not aiming for great portability here---in fact, i know
essentially all the machines it will run on.

Thanks in advance for any info or advice about this, or even a good
way to google for an existing free software solution.

I don't know if this is suitable for you, but the Google Charts API
provides in barcodes, albeit in the QR-encoding:
http://code.google.com/intl/nl-NL/apis/chart/types.html#qrcodes

Example (QR) barcode for "some text":
http://chart.apis.google.com/chart?chs=300x300&cht=qr&chl=some text

Code-128 is unfortunately (still?) not possible; I posted a request to
the 'Google Chart API' group in 2008:
http://groups.google.com/group/google-chart-api/browse_frm/thread/491481359b8829d1/
http://groups.google.com/group/google-chart-api/msg/76fbf3b46083aa6b?hl=en
 
D

Dr J R Stockton

In comp.lang.javascript message <e3aa9fd1-88c1-431c-8ee5-4ab1e9ef7ba4@k1
9g2000prh.googlegroups.com>, Thu, 21 May 2009 22:51:08, dan
I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Presumably you can write the desired string, as text, to an ordinary
control; and you know or can discover what the representation of each
character, as a pattern of wide and narrow black and white, is in your
code; and you know how to calculate the check characters; and you know
how to write an HTML string to a new window.

In other words, you know how to do the entire job yourself with pencil
and paper and maybe a reducing photocopier. You just want to automate
it.

IMHO, you have perhaps about a dozen different characters to code;
possibly about a hundred if you are coding ordinary text.

In either case, using Windows Paint, you can quite easily generate a
dozen, or a hundred, little files each showing a single character in
bar-code. Give these files names something like char1XYZ.gif (think
about the type of graphic) where XYZ is the code number for the
character. That assumes the characters have codes in 000 to 999 decimal.

Take your input string, append the check characters, call that St :

var Out = ""
for (var J=0 ; J<St.length ; J++) {
Ch = 1000 + St.charCodeAt(J)
Out += '<img src="bars/char' + Ch + '.gif">' }
and write Out to your new window.

Usually, some bars are longer; either stretch them by giving the image a
height, or provide also stretched versions.


Images can be avoided by computing the stripes; use a row of tall divs
with widths given by looking up the wide/narrow black/white pattern for
each character, which could be encoded as "BWbwBw" (upper case broad,
lower narrow; B=black, W=white).

For something vaguely similar, look at
<URL:http://www.merlyn.demon.co.uk/js-misc1.htm#BC> and press the Chart
button - there, it is the heights which vary.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
R

RobG

I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

Some bar codes are implemented as fonts, so depending on your
environment, it might be as simple as specifying an appropriate font-
family and the characters. Of course that will only work if you know
your clients have the correct font.

At least some are free:

<URL: http://www.barcodesinc.com/free-barcode-font/ >
 
D

Dr J R Stockton

In comp.lang.javascript message <e3aa9fd1-88c1-431c-8ee5-4ab1e9ef7ba4@k1
9g2000prh.googlegroups.com>, Thu, 21 May 2009 22:51:08, dan
I have to write a little javascript code that throws up a window with
some text and barcodes in it (which can later be printed out).

You need also to specify which particular form of bar coding you want.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top