writing barcodes to a window using only clientside javascript

Discussion in 'Javascript' started by dan, May 22, 2009.

  1. dan

    dan Guest

    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
    dan, May 22, 2009
    #1
    1. Advertising

  2. dan

    RobG Guest

    On May 22, 3:51 pm, dan <> wrote:
    > 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]


    <URL: On May 22, 3:51 pm, dan <> wrote:
    > 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


    <URL: On May 22, 3:51 pm, dan <> wrote:
    > 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


    On May 22, 3:51 pm, dan <> wrote:
    > 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 >


    --
    Rob
    RobG, May 22, 2009
    #2
    1. Advertising

  3. On 22 May, 06:51, dan <> wrote:
    > Thanks in advance for any info or advice about this, or even a good
    > way to google for an existing free software solution.

    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
    Captain Paralytic, May 22, 2009
    #3
  4. dan

    dan Guest

    > 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



    On May 21, 11:42 pm, RobG <> wrote:
    > On May 22, 3:51 pm, dan <> wrote:


    > > 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, May 22, 2009
    #4
  5. dan

    dan Guest

    On May 22, 7:28 am, Captain Paralytic <> wrote:
    > On 22 May, 06:51, dan <> wrote:> Thanks in advance for any info or advice about this, or even a good
    > > way to google for an existing free software solution.

    >
    > 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.
    dan, May 22, 2009
    #5
  6. On 22 May, 15:45, dan <> wrote:
    > On May 22, 7:28 am, Captain Paralytic <> wrote:
    >
    > > On 22 May, 06:51, dan <> wrote:> Thanks in advance for any info or advice about this, or even a good
    > > > way to google for an existing free software solution.

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

    And what was wrong with the very first hit? It seems to do precisely
    what you asked for in your post.
    Captain Paralytic, May 22, 2009
    #6
  7. dan

    dan Guest

    On May 22, 8:29 am, Captain Paralytic <> wrote:
    > On 22 May, 15:45, dan <> wrote:
    >
    > > On May 22, 7:28 am, Captain Paralytic <> wrote:

    >
    > > > On 22 May, 06:51, dan <> wrote:> Thanks in advance for any info or advice about this, or even a good
    > > > > way to google for an existing free software solution.

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

    >
    > 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
    dan, May 22, 2009
    #7
  8. dan

    Carlos JP Guest

    On May 22, 4:41 pm, dan <> wrote:
    > Well, the very first hit is like 99.9% (or maybe 100%??) of the
    > others:
    > it is not free-as-in-freedom software.
    >

    Did you see this first hit? http://www.parkscomputing.com/barcode.html
    Carlos JP, May 22, 2009
    #8
  9. dan

    dan Guest

    On May 22, 8:52 am, Carlos JP <> wrote:
    > On May 22, 4:41 pm, dan <> wrote:> Well, the very first hit is like 99.9% (or maybe 100%??) of the
    > > others:
    > > it is not free-as-in-freedom software.

    >
    > Did you see this first hit?http://www.parkscomputing.com/barcode.html


    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
    dan, May 22, 2009
    #9
  10. dan wrote:

    > 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

    --
    Bart
    Bart Van der Donck, May 23, 2009
    #10
  11. In comp.lang.javascript message <e3aa9fd1-88c1-431c-8ee5-4ab1e9ef7ba4@k1
    9g2000prh.googlegroups.com>, Thu, 21 May 2009 22:51:08, dan
    <> posted:

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

    --
    (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF3 Op9 Sf3
    news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr J R Stockton, May 23, 2009
    #11
  12. In comp.lang.javascript message <
    rlyn.invalid>, Sat, 23 May 2009 21:47:22, Dr J R Stockton
    <> posted:

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


    Slightly later in that page there is now a demonstration of something
    like a UPC bar code. Before actual use, it needs to be checked against
    the true UPC specification.

    --
    (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
    Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
    Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
    Dr J R Stockton, May 24, 2009
    #12
  13. dan

    RobG Guest

    On May 22, 3:51 pm, dan <> wrote:
    > 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/ >


    --
    Rob
    RobG, May 25, 2009
    #13
  14. In comp.lang.javascript message <e3aa9fd1-88c1-431c-8ee5-4ab1e9ef7ba4@k1
    9g2000prh.googlegroups.com>, Thu, 21 May 2009 22:51:08, dan
    <> posted:

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

    --
    (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk BP7, Delphi 3 & 2006.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
    <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
    NOT <URL:http://support.codegear.com/newsgroups/>: news:borland.* Guidelines
    Dr J R Stockton, May 26, 2009
    #14
    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. MDB

    Barcodes

    MDB, Jan 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    C.C. \(aka Me\)
    Jan 27, 2006
  2. Dale
    Replies:
    3
    Views:
    511
    Adam Szczeblewski
    Nov 13, 2003
  3. lalalala

    Barcodes

    lalalala, May 24, 2006, in forum: Java
    Replies:
    6
    Views:
    511
    Oliver Wong
    May 30, 2006
  4. Josh

    Reportlab and Barcodes

    Josh, Feb 8, 2005, in forum: Python
    Replies:
    8
    Views:
    6,884
Loading...

Share This Page