[comp.lang.postscript] Looking for PS program to generate barcodes

tom@dvnspc1.Dev.Unisys.COM (Tom Albrecht) (04/25/89)

I'm looking for a PostScript program to generate UPC-style barcodes.

Any pointers would be appreciated.


-- 
Tom Albrecht

mjj@stda.jhuapl.edu (Marshall Jose) (04/26/89)

Tom,
     This came over the network some time ago and I saved it.  It seemed
to work, though it's not an integral postscript program; rather, it uses
a sh-script and a prologue file.  Hope it will do.

--- rend here ---- rend here ---- rend here ---- rend here ---- rend here --

# To recover, type "sh archive"
echo restoring upc
sed 's/^X//' > upc <<\XxXxXxXxXx-EOF-XxXxXxXxXx
X#!/bin/sh
X# upc -- print upc code with PostScript
X# usage:  upc prod code-5 code-5
X# prod is the product type (zero for store items)
X# code-5 is a five digit code (needs two of these)
X
X# Copyright (C) 1986 by Pipeline Associates, Inc.
X# Permission is granted to use and distribute as long as this copyright
X# notice remains intact and it is distributed free of charge.
X
XUPCFONT=./upc.pro
XX=1	# x coordinate of lower right corner (in inches)
XY=1	# x coordinate of lower right corner (in inches)
X
X# calculate checksum
Xsum=`echo "$2
X$3
X$2
X$3" | sed "
X	1s/\(.\)\(.\)\(.\)\(.\)\(.\)/a=$1 + \2 + \4/
X	2s/\(.\)\(.\)\(.\)\(.\)\(.\)/b=\1 + \3 + \5/
X	3s/\(.\)\(.\)\(.\)\(.\)\(.\)/c=\1 + \3 + \5/
X	4s/\(.\)\(.\)\(.\)\(.\)\(.\)/s=(a+b)*3+c+\2+\4;(10-(s%10))%10/" | bc`
X
Xcat $UPCFONT
Xecho "$X 72 mul $Y 72 mul translate /UPC findfont 50 scalefont setfont
X0 0 moveto
X(| |$1$2 | | ) show
Xswitch
X($3$sum) show
Xswitch
X(| |) show
Xshowpage"
XxXxXxXxXx-EOF-XxXxXxXxXx
echo restoring upc.pro
sed 's/^X//' > upc.pro <<\XxXxXxXxXx-EOF-XxXxXxXxXx
X%%
X%%  Universal Product Code font
X%%  Copyright (C) 1986 by Pipeline Associates, Inc.
X%%  Permission is granted to use and distribute as long as this copyright
X%%  notice remains intact and it is distributed free of charge.
X%%
X/UPCFontDict 8 dict def
X/workdict 25 dict def
X%% load up drawing procedures
Xworkdict begin
X	/gray 0 def
X	/d1 {
X		1.3 setlinewidth
X		1 0 moveto 1 100 lineto stroke
X		2 0 translate
X	} bind def
X	/d2 {
X		3.3 setlinewidth
X		2 0 moveto 2 100 lineto stroke
X		4 0 translate
X	} bind def
X	/d3 {
X		5.3 setlinewidth
X		3 0 moveto 3 100 lineto stroke
X		6 0 translate
X	} bind def
X	/d4 {
X		7.3 setlinewidth
X		4 0 moveto 4 100 lineto stroke
X		8 0 translate
X	} bind def
X	/cline1 {
X		1 gray sub setgray
X		d1
X	} bind def
X	/cline2 {
X		1 gray sub setgray
X		d2
X	} bind def
X	/cline3 {
X		1 gray sub setgray
X		d3
X	} bind def
X	/cline4 {
X		1 gray sub setgray
X		d4
X	} bind def
X	/line1 {
X		gray setgray
X		d1
X	} bind def
X	/line2 {
X		gray setgray
X		d2
X	} bind def
X	/line3 {
X		gray setgray
X		d3
X	} bind def
X	/line4 {
X		gray setgray
X		d4
X	} bind def
Xend
X/switch {
X	workdict begin /gray 1 gray sub def end
X	} def
X
XUPCFontDict begin
X/FontType 3 def
X/FontMatrix [.01 0 0 .015 0 0] def
X/FontBBox [0 0 10 100] def
X/Encoding 128 array def
X/Widths 128 array def
X
X%% fill the Encoding array with the procs to run for each character
X0 1 127 {Encoding exch /.notdef put} for
XEncoding (0) 0 get /zero put
XEncoding (1) 0 get /one put
XEncoding (2) 0 get /two put
XEncoding (3) 0 get /three put
XEncoding (4) 0 get /four put
XEncoding (5) 0 get /five put
XEncoding (6) 0 get /six put
XEncoding (7) 0 get /seven put
XEncoding (8) 0 get /eight put
XEncoding (9) 0 get /nine put
XEncoding ( ) 0 get /space put
XEncoding (|) 0 get /bar put
X
XWidths (0) 0 get 14 put
XWidths (1) 0 get 14 put
XWidths (2) 0 get 14 put
XWidths (3) 0 get 14 put
XWidths (4) 0 get 14 put
XWidths (5) 0 get 14 put
XWidths (6) 0 get 14 put
XWidths (7) 0 get 14 put
XWidths (8) 0 get 14 put
XWidths (9) 0 get 14 put
XWidths ( ) 0 get 2 put
XWidths (|) 0 get 2 put
X
X%% define the procs
X/CharProcs 20 dict def
XCharProcs /.notdef {} put
XCharProcs /zero {
X	cline3 line2 cline1 line1
X} put
XCharProcs /one {
X	cline2 line2 cline2 line1
X} put
XCharProcs /two {
X	cline2 line1 cline2 line2
X} put
XCharProcs /three {
X	cline1 line4 cline1 line1
X} put
XCharProcs /four {
X	cline1 line1 cline3 line2
X} put
XCharProcs /five {
X	cline1 line2 cline3 line1
X} put
XCharProcs /six {
X	cline1 line1 cline1 line4
X} put
XCharProcs /seven {
X	cline1 line3 cline1 line2
X} put
XCharProcs /eight {
X	cline1 line2 cline1 line3
X} put
XCharProcs /nine {
X	cline3 line1 cline1 line2
X} put
XCharProcs /space {
X} put
XCharProcs /bar {
X	line1
X} put
X%% BuildChar is called by PS whenever a character is to be imaged out
X%% of UPC
X/BuildChar {
X workdict begin
X  /char exch def
X  /fontdict exch def
X  /charname fontdict /Encoding get char get def
X  /charproc fontdict /CharProcs get charname get def
X  /charwidth fontdict /Widths get char get def
X  charwidth 0 setcharwidth
X  gsave
X	charproc
X  grestore
X end
X} bind def
Xend
X%% register font in postscript font machinery
X/UPC UPCFontDict definefont pop
XxXxXxXxXx-EOF-XxXxXxXxXx

----------------------------------------------------------
Marshall Jose  WA3VPZ
mjj@aplvax.jhuapl.edu  ||  ...mimsy!aplcen!aplvax!mjj

jad@dayton.UUCP (J. Deters) (04/27/89)

In article <493@dvnspc1.Dev.Unisys.COM> tom@dvnspc1.Dev.Unisys.COM (Tom Albrecht) writes:
>
>I'm looking for a PostScript program to generate UPC-style barcodes.
>Any pointers would be appreciated.
>-- 
>Tom Albrecht

Tom, I tried to mail you a copy of the barcodes but mail bounced at shamash.
If you can send me a different path, I can try again.  If there is enough
other interest, I could post it.  I have UPC (scammed off the net about a
year or so ago) and 3of9 interleave (my own) available.

-j
jad@DHDSC.MN.ORG
"I'd like to get some sleep before I travel,
  but if you got a warrant, I guess you're gonna come in." - the dead

edwards@bgsuvax.UUCP (Ken Jenkins) (05/03/89)

I have noticed a few postings here requesting information about
UPC barcode generation.

I have written a program for the Mac which includes the following
features:

* On screen display of barcode and interactive Mac'ish interface.
* Calculates checksum automatically
* Allows you to select the presence and position (mid or bottom)
  of type digit and checksum digit.
* Allows printing directly to PS printer or will save the barcode
  as a grouped object in a double-clickable (as they say) Adobe
  Illustrator file. You may then build around it.
* Will use Adobe's OCR-B font if installed on your system for
  human readable digits (as per UPC specs).
* Allows for selection of half-height bars

We use it to generate an Illustrator file containing the bar code.
Then we build a label around it, produce a film negative on an
L-300 and make a flexographic printing plate from it.

If anyone is interested it would probably be more expedient to
contact me directly as I'm not very active here.

Ken Jenkins
c/o Century Marketing Corp.
    419-354-2591


Disclaimer: My name is Ken Jenkins and I am here as a guest of Bruce Edwards
            to whom this account belongs. Although he may be interested or even
            amused by my ramblings, he should not be held accountable for them 
            in any way.  
-------------------------------------------------------------------------------
"In the late Devouring Period, fish became obnoxious. Animals without
 backbones hid from each other or fell down." --Firesign Theater
-------------------------------------------------------------------------------
Ken Jenkins (as a guest of Bruce Edwards)    CSNET: edwards@bgsu.edu
                                           ARPANET: edwards@andy.bgsu.edu
                                              UUCP: ..!osu-cis!bgsuvax!edwards