Thread View: comp.lang.postscript
6 messages
6 total messages
Started by Robert Cray
Fri, 23 Oct 1992 17:31
Zip Code "Bar Codes"
Author: Robert Cray
Date: Fri, 23 Oct 1992 17:31
Date: Fri, 23 Oct 1992 17:31
9 lines
797 bytes
797 bytes
Does anyone have postscript code that will generate the zip+4 bar code for a zip-code? Actually I have the postscript code to generate the bar code, what I don't know is the format of the thing, i.e. what is the formula to convert a particular zip code into the 0's and 1's that make up the bar code. Thanks, --robert -- robert@cs.unlv.edu
Re: Zip Code "Bar Codes"
Author: Mike Slade
Date: Thu, 29 Oct 1992 16:53
Date: Thu, 29 Oct 1992 16:53
7 lines
784 bytes
784 bytes
Check with your favorite local post office. They can supply you with a booklet that gives all the gory details. The code is the easy; the pain is getting where they want it on the envelope. Michael Slade slade.wbst128@xerox.com
Re: Zip Code "Bar Codes"
Author: Gregory Lee Silvus
Date: Thu, 29 Oct 1992 17:44
Date: Thu, 29 Oct 1992 17:44
38 lines
1793 bytes
1793 bytes
In article <1992Oct23.173146.20984@unlv.edu> robert@unlv.edu (Robert Cray) writes: Does anyone have postscript code that will generate the zip+4 bar code for a zip-code? Actually I have the postscript code to generate the No, I don't, but I did sit down and figure out the bar code. The long strokes are "1s" and the short are "0s". The things listed at the top are observations that may be obvious to some, but important nonetheless. If you write a program to generate these, please mail it to me, or post it. Thanks, gReg Zip Code Bar Code 1. The Zip Code Bar Code resides below all mailing information, although this constraint is being relaxed. 2. The bar code is a distance 2 code capable of detecting one error per number in the string. 3. The Zip Code is preceded and followed by a single tall stroke. 4. The last digit in the bar code is the number required to make the Zip Code sum to a mod 10 number. 5. Each code word contains exactly two long strokes and three short strokes. 6. The code appears to be both rotational and linear. 0 11000 1 00011 2 00101 3 00110 4 01001 5 01010 6 01100 7 10001 8 10010 9 10100
Re: Zip Code "Bar Codes"
Author: R. Matthew Emerson
Date: Thu, 29 Oct 1992 19:37
Date: Thu, 29 Oct 1992 19:37
62 lines
2630 bytes
2630 bytes
In article <SILVUS.92Oct29124450@vauxhall.ece.cmu.edu> silvus@vauxhall.ece.cmu.edu (Gregory Lee Silvus) writes:
>In article <1992Oct23.173146.20984@unlv.edu> robert@unlv.edu (Robert Cray) writes:
> Does anyone have postscript code that will generate the zip+4 bar code
> for a zip-code? Actually I have the postscript code to generate the
>
>
>Zip Code Bar Code
>
>1. The Zip Code Bar Code resides below all mailing information,
> although this constraint is being relaxed.
>2. The bar code is a distance 2 code capable of detecting one
> error per number in the string.
>3. The Zip Code is preceded and followed by a single tall stroke.
>4. The last digit in the bar code is the number required
> to make the Zip Code sum to a mod 10 number.
>5. Each code word contains exactly two long strokes and three short
> strokes.
>6. The code appears to be both rotational and linear.
>
>0 11000
>1 00011
>2 00101
>3 00110
>4 01001
>5 01010
>6 01100
>7 10001
>8 10010
>9 10100
A while back, Michael Post (msp2@ellis.uchicago.edu) posted an explaination
of the zip-bar-code too. I fooled around for a little while and wrote the
following code to draw the codes. It's *very* simplistic, but that's ok.
-matt
/long { currentpoint % save current location
0 10 rlineto stroke
moveto
5 0 rmoveto % set up for next line
} def
/short { currentpoint % save current location
0 3 rlineto stroke
moveto
5 0 rmoveto % set up for next line
} def
/zero { long long short short short } def
/one { short short short long long } def
/two { short short long short long } def
/three { short short long long short } def
/four { short long short short long } def
/five { short long short long short } def
/six { short long long short short } def
/seven { long short short short long } def
/eight { long short short long short } def
/nine { long short long short short } def
10 10 moveto
long seven seven zero zero six zero long
Re: Zip Code "Bar Codes"
Author: Tod McQuillin
Date: Thu, 29 Oct 1992 23:45
Date: Thu, 29 Oct 1992 23:45
189 lines
6536 bytes
6536 bytes
robert@unlv.edu (Robert Cray) writes:
> Does anyone have postscript code that will generate the zip+4 bar code
> for a zip-code?
I don't know if you already have my version, but the one I originally
posted last year (which, much to my surprise was distributed as a
sample ghostscript file!) had a bug in it whereby zip codes beginning
with 0 were not printed. Here is the new version with this bug fixed.
(Many thanks to Brent Carruth for pointing out my error.)
--- Cut Here ---
%!PS
% Postscript program to address a business-size envelope in accordance
% with US Postal Service guidelines, including the 52-bit POSTNET barcode
% Use of this program can help your mail arrive up to 2 days faster!
% Note: A barcode will only be printed if the last word of the last line of
% the address is a 9-digit zipcode.
% by Tod McQuillin
% tm8t+@andrew.cmu.edu
% 10-Oct-1991
% Copyright (C) 1991 Tod McQuillin
% Revised 29-Oct-1992
% This is version 1.1, incorporating patches courtesy of Brent Carruth
% (BLCARR01@ulkyvx.louisville.edu)
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
/inch {72 mul} def
/cm {inch 2.54 div} def
% LWIDTH and LHEIGHT define letter size paper. The envelope will be printed
% centered in this area, flush with the top of the page. This works great
% with a HP III printer; your mileage may vary
/LWIDTH 8.5 inch def
/LHEIGHT 11 inch def
% EHEIGHT and EWIDTH define the com10 size envelope. They're supposed to be
% 9.5 x 4.25 inches, but the ones I had were only 10.5 cm tall. Change these
% values to suit your envelopes -- the program will work with any envelopes
% provided these values are set appropriately.
/EHEIGHT 10.5 cm def
/EWIDTH 9.5 inch def
/interline { % define default leading
POINTSIZE 1.2 mul
} def
/fontset { % fontname pointsize => -
exch findfont exch dup /POINTSIZE exch def scalefont setfont
} def
/defleading { % define leading for nl
/LEADING interline def
} def
/nl { % print string and move to start of next line
dup stringwidth pop exch show neg LEADING neg rmoveto
} def
/addressfont { % set font for address
/gillsans 14 fontset defleading
} def
/returnfont { % set font for return address
/gillsans 12 fontset defleading
} def
/envelope { % translate and rotate coordinate system to match com10
LWIDTH EHEIGHT sub 2 div EHEIGHT add LHEIGHT EWIDTH sub translate
90 rotate
0 3 32 div inch translate % fudge factor for my printer - change or remove
} def
/returnaddress { % Print the return address
gsave
returnfont
% This positions the return address .25 inches from upper left of envelope
.25 inch EHEIGHT .25 inch sub POINTSIZE 3 64 div inch sub sub moveto
{nl} forall
grestore
} def
/address { % Print the address
gsave
addressfont
4 inch 2.25 inch moveto % Magic numbers conform to USPS guidelines
dup % save the address
{nl} forall
dup length 1 sub get % Get the last line of the address
mark
{ exch dup /str exch def % Tokenise the line and save remainder in str
token not {exit} if
/barcodestring str def
} loop % Get the last word of the last line
type cvlit /marktype ne {barcodestring barcode} if
cleartomark
grestore
} def
/barcodebits [ % From "A Guide to Business Mail Preparation"
(11000) %0 % USPS Brochure/Pamphlet
(00011) %1
(00101) %2
(00110) %3
(01001) %4
(01010) %5
(01100) %6
(10001) %7
(10010) %8
(10100) %9
] def
/bit1 { % Draw a 1 bit of the POSTNET Barcode
0 .125 inch rlineto
1 inch 21 div .125 inch neg rmoveto
} bind def
/bit0 { % Draw a 0 bit of the POSTNET Barcode
0 .05 inch rlineto
1 inch 21 div .05 inch neg rmoveto
} bind def
/dodigit { % Do a complete digit of the barcode
barcodebits exch get {
2 mod 1 eq
{bit1}
{bit0}
ifelse
/BITS BITS 1 add def
} forall
} def
/barcode { % Do a complete barcode
gsave
/CHECKSUM 0 def
/BITS 0 def
% More magic numbers to conform to USPS guidelines
EWIDTH 3.9375 inch sub .25 inch moveto
bit1
{
(0) 0 get sub dup dup 0 ge exch 9 le and {
dup /CHECKSUM exch CHECKSUM add def
dodigit
} if
} forall
CHECKSUM 10 mod neg 10 add dup 10 eq {pop 0} if
dodigit
bit1
BITS 50 eq {.02 inch setlinewidth stroke} if
% if you want 5 digit zip codes barcoded as well, make the previous line be
% BITS 50 eq BITS 30 eq or {.02 inch setlinewidth stroke} if
% I don't think it's a good idea to barcode a 5-digit zip. Kinda defeats
% the purpose.
grestore
} def
% Note that if you print your own barcode, you need not follow the address font
% guidelines since the only use of the OCR machines is to print barcodes.
/tod [ % That's me!
(Tod N. McQuillin)
(25 Dilworth Street)
(Apartment 2)
(Pittsburgh, PA 15211-1913)
] def
/addressee [
(Joe Random)
(123 Anystreet)
(Pittsburgh, PA 15212-3011)
] def
envelope
tod returnaddress
addressee address
showpage
%--- Cut Here ---
Screen dumper for Level 2 Postscript
Author: Jack Yao
Date: Wed, 11 Nov 1992 02:16
Date: Wed, 11 Nov 1992 02:16
13 lines
783 bytes
783 bytes
Hi: Does anyone out there know how to get a color postscript screen dumper for X window.(Level 2 Postscript). I have tried xwd | xpr -device ps but it gave me B&W image Thanks in advance Jack yaot@dtrl.ee.washington.edu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads