🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #2293

Re: Printing Barcodes

#2293
From: Woody Baker Eagle Signal
Date: Wed, 06 Jun 1990 03:13
218 lines
4529 bytes
In article <1004@io.tegra.COM>, phillips@tegra.COM (Steve Phillips) writes:
> In article <9208@teda.UUCP> bob@teda.UUCP (Bob Armstrong) writes:
> >
> >  Can someone direct me to a font or program for printing code 39 (3 of 9)
> >barcodes ?  Postscript output is best, but I would take anything (maybe
> >Epson ?).
> >
> >  Note that code39 is not the same as UPC barcodes (the ones you see in
> >grocery stores)...
> >

Here is a UPC barcode routine for what it is worth.
Please don't use it to create stick on barcodes for products down at your
local grocery store.  Besides being illegal , it is not nice to mess up
the inventory control by making the cash register record a 1 lb box of
something, when it is a 2 lb box.

%%
%%  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
Technical Details
Message-ID: <1303@chinacat.Unicom.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!texbell!chinacat!woody
References: <9208@teda.UUCP> <1004@io.tegra.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!texbell!chinacat!woody
From: woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal)
Newsgroups: comp.lang.postscript
Subject: Re: Printing Barcodes
Summary: here is one.
Keywords: barcode code39 3 of 9
Message-ID: <1303@chinacat.Unicom.COM>
Date: 6 Jun 90 03:13:57 GMT
References: <9208@teda.UUCP> <1004@io.tegra.COM>
Organization: a guest of Unicom Systems Development, Austin
Lines: 218