Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

the proper way of barcode rendering/printing

by AlexTape (Monk)
on Sep 12, 2011 at 10:33 UTC ( #925443=perlquestion: print w/replies, xml ) Need Help??
AlexTape has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, actual i look for a proper way to generate and print dynamic barcodes. i found a view modules @cpan but most of them are quite complex. the output should be "code93" plus printable. i thought of generate with HTML::Barcode but iīm not able to print the bc out of the browser. i explicit donīt want to use images! because the printing runs over an invoked session of a texteditor e.g. notepad/editor. (or you got a better idea to use the windows printer environment?) the barcodes should be generated on the fly and printed with some other information on a brother gx430t. i suppose that i probably can use the internal module of the printer to gernerate barcodes directly but the plaintext interaction between windows e.g. perl and the printer is still inscrutable to me. probably you can enlight my mind. :-)
$perlig =~ s/pec/cep/g if 'errors expected';
  • Comment on the proper way of barcode rendering/printing

Replies are listed 'Best First'.
Re: the proper way of barcode rendering/printing
by Corion (Pope) on Sep 12, 2011 at 10:39 UTC

    I highly doubt that you can use notepad.exe to print any graphics.

    Have you looked at creating the barcodes using (La)Teχ? There certainly are latex code93 barcode packages on the CTAN and you could create the barcode as text file then and use LaTeχ to create the appropriate representation. Note that, one way or the other, your barcode will have to become an image, as likely your printer only understands bitmaps anyway.

      I never tried notepad but I used to print barcodes from MS Word. If a code93 font is installed in Windows then notepad should be able print barcodes. This link claims to give you a free download of the font in a zip file but it is actually an installer for a demo program and required a re-boot. I think the fonts I used to have were from a barcode reader manufacturer.

      Update: I just printed some code 93 from Notepad.

      at frist i appreciate that notepad.exe is not able to print graphix.
      so there is no perl module that can create a barcode as plaintext? why it is not possible to print a html::barcode barcode to a regular printer? itīs based on "table" - is there an option to force that printing?

      $perlig =~ s/pec/cep/g if 'errors expected';

        The best HTML renderers are arguably web browsers. Find out how to render and print an HTML page on your operating system if you insist on using the HTML representation of a barcode.

        Most likely, both, Internet Explorer and Firefox can be started from the command line to automatically print an HTML file without further interaction.

        so there is no perl module that can create a barcode as plaintext?

        Barcodes are not plaintext

        why it is not possible to print a html::barcode barcode to a regular printer?

        Not printing backgrounds is an ink saving feature of browsers , learn to work yours ;)

Re: the proper way of barcode rendering/printing
by Khen1950fx (Canon) on Sep 12, 2011 at 12:17 UTC
    Here's a script that I used for Code93:
    #!/usr/bin/perl use strict; use warnings; use GD::Barcode::Code93; my $oGdBar; $oGdBar = GD::Barcode->new('Code93', 'text'); binmode(STDOUT); print "Content-Type: image/png\n\n"; open OUT, '>', 'Code93.png'; print OUT $oGdBar->plot->png; close OUT; undef $oGdBar;
Re: the proper way of barcode rendering/printing
by afoken (Abbot) on Sep 12, 2011 at 15:28 UTC

    Options to generate barcodes:

    • Use barcode fonts. Some are free, some cost money. You get a font file (often TTF) that displays ASCII digits, letters, and some interpunctation characters as barcode fragments. You have to add start and end sequences and check digits manually. On a system lacking the fonts, you see either plaintext or just junk. This may also happen if you print to a printer with a driver that prefers printer fonts over system fonts.
    • Create a vector graphic (postscript, svg, ...), composed of white and black bars of different widths. You need several bars for each character, sometimes the bar pattern also depends on the position in the bar code or on other characters. And you may need extra bars around and inside the bar code. Barcode Writer in Pure PostScript is an example for this, with the nifty trick that can run on the printer instead of the host computer.
    • Create a bitmap graphic instead of a vector graphic. GD::Barcode is an old and not very clean example for such a generator.
    • Use a printer that can render barcodes natively. Note that that won't help you with your browser problem.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://925443]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-06-20 23:43 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.