🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #1812

Re: Barcodes in Postscript

#1812
From: Mats-Olof Sander
Date: Tue, 18 Aug 1992 18:07
130 lines
4307 bytes
henry@trilithon.mpk.ca.us (Henry McGilton) writes:

>In article <1992Aug17.165203.16627@mtu.edu> cdh@mtu.edu (Chris Hooper) writes:
>    *  I'd like to be able to print barcodes (specifically code
>    *  3 of 9) using postscript.  If anyone out there has heard
>    *  of this being successfully done in the past, please email me.
>You can obtain complete fonts of bar codes and postal
>codes in a variety of different formats from an outfit called

>    Bear Rock Technologies
>    6069 Enterprise Drive
>    Diamond Springs
>    California 95619
>    
>    
>        ........  Henry

I picked up this piece of PS-code from the net and have tried it out to
full satisfaction.
Mats-Olof
++++++++++++++++++++++++++++++++++++++++++++
The attached will load a postscript routine for printing code 3/9
barcodes.

Sample usage:

        /inch {72 mul} def
        (*TEST BARCODE*) 1 inch .015 inch barcode

will print a 1 inch tall barcode with .015 inch bars (about 4
characters/inch)
at the current position.  The asterisks around the barcode text are
required
start/stop characters.

Bill Neisius
bill@solaria.hac.com

-------------------------------------------------------------------------
%!
% print barcode at current location:   (string) barheight barwidth
barcode
% W V Neisius (bill@solaria.hac.com) - January 1992
%
serverdict begin 0 exitserver
/barcode {
/chars (1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *) def
/bars   [ 00 17 18 03 20 05 06 24 09 10 12 00 ] def
/spaces [ 00 02 04 08 01 07 11 13 14          ] def

% height, width
/bwidth exch def
/bheight exch def

% string
/bstring exch def

/ilen bstring length def
/indx 0 def
/clen chars length def

% loop
{
        indx ilen ge {exit} if
        /wchar bstring indx 1 getinterval def
        indx 1 add /indx exch def

        /cndx 0 def

        % getchr
        {
                cndx clen ge {
                                % getother
                                /bndx 11 def
                                /sndx 8 def
                                wchar ($) eq {/sndx 5 def} if
                                wchar (/) eq {/sndx 6 def} if
                                wchar (+) eq {/sndx 7 def} if
                                exit
                             } if
                /cchar chars cndx 1 getinterval def
                cndx 1 add /cndx exch def
                cchar wchar eq {
                                % getbar
                                /sndx cndx 1 sub 10 div 1 add cvi def
                                /bndx cndx sndx 1 sub 10 mul sub def
                                exit
                               } if
        } loop

        % getbarx

        /bar bars bndx get def
        /space spaces sndx get def

        % barcode
        5 {
                /btemp bar 2 div cvi def
                /btemp bar btemp 2 mul sub def
                /bar bar 2 div cvi def
                btemp 0 eq {/btemp 1 def} {/btemp 3 def} ifelse

                /stemp space 2 div cvi def
                /stemp space stemp 2 mul sub def
                /space space 2 div cvi def
                stemp 0 eq {/stemp 1 def} {/stemp 3 def} ifelse

                % dobars
                % narrowbar
                % widebar
                0 bheight rlineto
                bwidth btemp mul 0 rlineto
                0 bheight neg rlineto
                bwidth btemp mul neg 0 rlineto
                currentpoint fill moveto
                bwidth btemp mul 0 rmoveto

                % dospace
                % narrowspc
                % widespace
                bwidth stemp mul 0 rmoveto

        } repeat

        bwidth 2 mul 0 rmoveto

} loop

} def
++++++++++++++++++++++++++++++++++
Technical Details
Message-ID: <moj.714161261@risken>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!mips!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!seunet!volvo!risken!moj
References: <1992Aug17.165203.16627@mtu.edu> <1992Aug18.051216.4736@trilithon.mpk.ca.us>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!mips!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!seunet!volvo!risken!moj
From: moj@risken.vd.volvo.se (Mats-Olof Sander)
Newsgroups: comp.lang.postscript
Subject: Re: Barcodes in Postscript
Message-ID: <moj.714161261@risken>
Date: 18 Aug 92 18:07:41 GMT
References: <1992Aug17.165203.16627@mtu.edu> <1992Aug18.051216.4736@trilithon.mpk.ca.us>
Sender: news@vd.volvo.se
Lines: 130