[comp.lang.postscript] print barcode

frei@rubmez.UUCP (Matthias Frei ) (05/05/88)

Hy anybody,

Did anybody write a PostScript-Procedure generating barcodes ?
What standards are there, and how to deal with them ?

If you have any experiences in that subject, please mail to me.

Thanks

	Matthias Frei
	Mikroelektronikzentrum (A)
	Ruhr Universitaet Bochum, West Germany
	4630 Bochum 1, Postfach 102148
	E-mail  UUCP:  ...!uunet!unido!rubmez!frei

edwards@bgsuvax.UUCP (Bruce Edwards) (05/10/88)

In article <123@rubmez.UUCP>, frei@rubmez.UUCP (Matthias Frei ) writes:
> Hy anybody,
> 
> Did anybody write a PostScript-Procedure generating barcodes ?
> What standards are there, and how to deal with them ?
> 
> If you have any experiences in that subject, please mail to me.
> 
> Thanks
> 
> 	Matthias Frei
> 	Mikroelektronikzentrum (A)
> 	Ruhr Universitaet Bochum, West Germany
> 	4630 Bochum 1, Postfach 102148
> 	E-mail  UUCP:  ...!uunet!unido!rubmez!frei

I have written a stand alone program on the Mac which will generate
a UPC barcode with automatic calculation of checksum digit and proper
location of human readable characters (although they are in Helvetica
rather than OCR-B because I've not been able to find an OCR-B font).
And one line of centered text under barcode if desired.

The output can be chosen from one of the following;

1. Dump the screen (crudest, but readable even when generated on dot matrix)
   Or save the screen as a MacPaint file.

2. Send directly to Postscript device (resolution only limited by device)
   Output file pure PostScript.

3. Generate an ADOBE Illustrator file. Which you can double click on
   and be up in Illustrator with your barcode. We then use it as the
   basis upon which to build a packaging or pricing label around, adding
   additional text, graphics, and a border.

We then print the ADOBE file on an L-300 on negative film and make the
plate from that. The resultant label with it's automatically produced
barcode is indistinguishable from a Film Master purchased from an
outside vendor. We save a lot on Film Masters this way and you can
produce any UPC barcode in about 30 seconds. The final product, a
flexographically printed label scans 100% verifiable (that is if the
press operator doesn't fall asleep and screw up the impression).

There are very stringent requirement for the production of UPC barcodes. 
The best place to get information about them is from.

Uniform Code Council, Inc.
7051 Corporate Way Suite 201
Dayton, OH. 45459-4294

If you would like a copy of my program for the Mac please send 
name
address and $15.00 to;

Ken Jenkins
Century Marketing Corp.
12836 South Dixie Highway
Bowling Green, OH. 43402
(419) 354-2591 if you have questions

I will send you a disk with the program on it.
The $15 is not to make me rich, it's for the disk, envelope, postage & hassle.


Disclaimer: I am participating as a guest of Bruce Edwards. My name
            is Ken Jenkins. Bruce is generally amused with my ramblings
            but does not necessarily agree with them.

            'These are only the shadowlands.' C.S. Lewis 
      ----------------------------------------------------------------- 
        Ken Jenkins as guest of edwards@bgsu
        
        CSNET: edwards@bgsu
      ARPANET: edwards%bgsu@csnet-relay
         UUCP: cbosgd!osu-cis!bgsuvax!edwards 

bph_cwjb@jhunix.HCF.JHU.EDU (William J. Bogstad) (05/14/88)

In article <123@rubmez.UUCP> frei@rubmez.UUCP (Matthias Frei ) writes:
>Hy anybody,
>
>Did anybody write a PostScript-Procedure generating barcodes ?
>What standards are there, and how to deal with them ?
>
>If you have any experiences in that subject, please mail to me.

	This was short enough and of perhaps general enough interest
that I am posting it.  I obtained it off of the net early last year.

				Bill Bogstad

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by bill on Mon Apr  6 18:23:24 EST 1987
# Contents:  ORIGIN upc upc.pro
 
echo x - ORIGIN
sed 's/^@//' > "ORIGIN" <<'@//E*O*F ORIGIN//'
@From: patwood@unirot.UUCP (Patrick Wood)
Newsgroups: net.sources,comp.text
Subject: upc fonts (long -- contains font listing)
Keywords: upc barcode postscript font
Date: 28 Mar 87 05:27:32 GMT
Organization: Public Access Unix, Piscataway, NJ

I hope this doesn't get screwed up and posted twice...

The following shar is a PostScript UPC font and a shell program for
generating UPC labels.  Since I don't yet have a barcode reader, I'm
interested in knowing whether these fellows work.  The bar codes look
correct to the naked eye, but we all know that means nothing to a bar
code reader.  If anyone out there can, let me know if this all works.
If not, please send me your modifications or post to the net.

Pat Wood
{ihnp4,harpo,seismo}!bellcore!phw5!phw
@//E*O*F ORIGIN//
chmod u=rw,g=r,o=r ORIGIN
 
echo x - upc
sed 's/^@//' > "upc" <<'@//E*O*F upc//'
#!/bin/sh
# upc -- print upc code with PostScript
# usage:  upc prod code-5 code-5
# prod is the product type (zero for store items)
# code-5 is a five digit code (needs two of these)

# Copyright (C) 1986 by Pipeline Associates, Inc.
# Permission is granted to use and distribute as long as this copyright
# notice remains intact and it is distributed free of charge.

UPCFONT=./upc.pro
X=1	# x coordinate of lower right corner (in inches)
Y=1	# x coordinate of lower right corner (in inches)

# calculate checksum
sum=`echo "$2
$3
$2
$3" | sed "
	1s/\(.\)\(.\)\(.\)\(.\)\(.\)/a=$1 + \2 + \4/
	2s/\(.\)\(.\)\(.\)\(.\)\(.\)/b=\1 + \3 + \5/
	3s/\(.\)\(.\)\(.\)\(.\)\(.\)/c=\1 + \3 + \5/
	4s/\(.\)\(.\)\(.\)\(.\)\(.\)/s=(a+b)*3+c+\2+\4;(10-(s%10))%10/" | bc`

cat $UPCFONT
echo "$X 72 mul $Y 72 mul translate /UPC findfont 50 scalefont setfont
0 0 moveto
(| |$1$2 | | ) show
switch
($3$sum) show
switch
(| |) show
showpage"
@//E*O*F upc//
chmod u=rwx,g=rx,o=rx upc
 
echo x - upc.pro
sed 's/^@//' > "upc.pro" <<'@//E*O*F upc.pro//'
%%
%%  Universal Product Code font
%%  Copyright (C) 1986 by Pipeline Associates, Inc.
%%  Permission is granted to use and distribute as long as this copyright
%%  notice remains intact and it is distributed free of charge.
%%
/UPCFontDict 8 dict def
/workdict 25 dict def
%% load up drawing procedures
workdict begin
	/gray 0 def
	/d1 {
		1.3 setlinewidth
		1 0 moveto 1 100 lineto stroke
		2 0 translate
	} bind def
	/d2 {
		3.3 setlinewidth
		2 0 moveto 2 100 lineto stroke
		4 0 translate
	} bind def
	/d3 {
		5.3 setlinewidth
		3 0 moveto 3 100 lineto stroke
		6 0 translate
	} bind def
	/d4 {
		7.3 setlinewidth
		4 0 moveto 4 100 lineto stroke
		8 0 translate
	} bind def
	/cline1 {
		1 gray sub setgray
		d1
	} bind def
	/cline2 {
		1 gray sub setgray
		d2
	} bind def
	/cline3 {
		1 gray sub setgray
		d3
	} bind def
	/cline4 {
		1 gray sub setgray
		d4
	} bind def
	/line1 {
		gray setgray
		d1
	} bind def
	/line2 {
		gray setgray
		d2
	} bind def
	/line3 {
		gray setgray
		d3
	} bind def
	/line4 {
		gray setgray
		d4
	} bind def
end
/switch {
	workdict begin /gray 1 gray sub def end
	} def

UPCFontDict begin
/FontType 3 def
/FontMatrix [.01 0 0 .015 0 0] def
/FontBBox [0 0 10 100] def
/Encoding 128 array def
/Widths 128 array def

%% fill the Encoding array with the procs to run for each character
0 1 127 {Encoding exch /.notdef put} for
Encoding (0) 0 get /zero put
Encoding (1) 0 get /one put
Encoding (2) 0 get /two put
Encoding (3) 0 get /three put
Encoding (4) 0 get /four put
Encoding (5) 0 get /five put
Encoding (6) 0 get /six put
Encoding (7) 0 get /seven put
Encoding (8) 0 get /eight put
Encoding (9) 0 get /nine put
Encoding ( ) 0 get /space put
Encoding (|) 0 get /bar put

Widths (0) 0 get 14 put
Widths (1) 0 get 14 put
Widths (2) 0 get 14 put
Widths (3) 0 get 14 put
Widths (4) 0 get 14 put
Widths (5) 0 get 14 put
Widths (6) 0 get 14 put
Widths (7) 0 get 14 put
Widths (8) 0 get 14 put
Widths (9) 0 get 14 put
Widths ( ) 0 get 2 put
Widths (|) 0 get 2 put

%% define the procs
/CharProcs 20 dict def
CharProcs /.notdef {} put
CharProcs /zero {
	cline3 line2 cline1 line1
} put
CharProcs /one {
	cline2 line2 cline2 line1
} put
CharProcs /two {
	cline2 line1 cline2 line2
} put
CharProcs /three {
	cline1 line4 cline1 line1
} put
CharProcs /four {
	cline1 line1 cline3 line2
} put
CharProcs /five {
	cline1 line2 cline3 line1
} put
CharProcs /six {
	cline1 line1 cline1 line4
} put
CharProcs /seven {
	cline1 line3 cline1 line2
} put
CharProcs /eight {
	cline1 line2 cline1 line3
} put
CharProcs /nine {
	cline3 line1 cline1 line2
} put
CharProcs /space {
} put
CharProcs /bar {
	line1
} put
%% BuildChar is called by PS whenever a character is to be imaged out
%% of UPC
/BuildChar {
 workdict begin
  /char exch def
  /fontdict exch def
  /charname fontdict /Encoding get char get def
  /charproc fontdict /CharProcs get charname get def
  /charwidth fontdict /Widths get char get def
  charwidth 0 setcharwidth
  gsave
	charproc
  grestore
 end
} bind def
end
%% register font in postscript font machinery
/UPC UPCFontDict definefont pop
@//E*O*F upc.pro//
chmod u=rw,g=r,o=r upc.pro
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
     18    121    757 ORIGIN
     33    150    922 upc
    159    587   3078 upc.pro
    210    858   4757 total
!!!
wc  ORIGIN upc upc.pro | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
-- 
Bill Bogstad				bogstad@cs.jhu.edu
Work: (301)338-8019			bill@green.bph.jhu.edu

paul@torch.UUCP (Paul Andrews) (05/23/88)

In article <2117@bgsuvax.UUCP> edwards@bgsuvax.UUCP (Bruce Edwards) writes:
>In article <123@rubmez.UUCP>, frei@rubmez.UUCP (Matthias Frei ) writes:
>> ...Did anybody write a PostScript-Procedure generating barcodes ?
>
>I have written a stand alone program on the Mac which will generate
>If you would like a copy of my program for the Mac please send 
>name address and $15.00 to;
>

This sounds like a program I would want, however, the logistics of mailing
money overseas + the added cost would make your suggested method quite
difficult. It would be very useful, therefore, if you could post it to
comp.binaries.mac or somesuch.

Thanks.

- Paul