%! % % % (C) Copyright 1990 by Woody Baker % Rt.1 Box I % Manor, Tx. 78653 % % this code may be used for personal use, as long as this header % remains intact but may not be used % as part of a commercial package. All commercial rights reserved. % % % code to print usps barcode. % checkdigit computation is the sum of the digits, rounded up to % the next even multiple of 10. % % You MUST print this on the envelope within certain very specific areas. % The x and y coordinate MUST have the following relationship with the % RIGHT LOWER CORNER of the envelope. % x can be no further from the right edge than 4" and no closer than % 3 1/4. The y coordinate MUST be 1/4 inch up from the bottom of the % envelope, +/- 1/16 th inch. The x coordinates' wide lea-way is % to accomodate shifting of inserts containing POSTNET codes which appear % through windows in the envelope. For printed barcodes on envelopes % the post office prefers 3 7/8 to 4 inches. % request Publication 25 (A Guide to Business Mail Preparation) from % your local Post Office. Be sure to ask for the template that accompanies % the book. % /inches {72 mul} def /barwidth .020 inches def % MUST NOT CHANGE /long .125 inches def % MUST NOT CHANGE /short .050 inches def % MUST NOT CHANGE /nextx .0475 inches def % MUST NOT CHANGE % % one of the recommended fonts for OCR labels. 10/14 is one of the % recommended settings. % /Helvetica findfont 10 scalefont setfont /linehite 14 def % /digarray [ { lbar lbar sbar sbar sbar % digit 0 } { sbar sbar sbar lbar lbar % digit 0 } { sbar sbar lbar sbar lbar % digit 2 } { sbar sbar lbar lbar sbar % digit 3 } { sbar lbar sbar sbar lbar % digit 4 } { sbar lbar sbar lbar sbar % digit 5 } { sbar lbar lbar sbar sbar % digit 6 } { lbar sbar sbar sbar lbar % digit 7 } { lbar sbar sbar lbar sbar % digit 8 } { lbar sbar lbar sbar sbar % digit 9 } ] def % % sbar does a short bar, and alters the current point accordingly % % /sbar { barwidth setlinewidth % always make sure it is correct width currentpoint % remember where we are currentpoint short add lineto % do the bar exch nextx add exch moveto % advance the current point } def % % lbar does a tall bar and alters the current point accordingly % /lbar { barwidth setlinewidth % always make sure it is correct width currentpoint % remember where we are currentpoint long add lineto % do the bar exch nextx add exch moveto % advance the current point } def % % routine takes a string of numbers (no hyphens in the first cut) % an orientation flag (1=Landscape) and an x and y coordinate % % % x y orientation (numberstring) % % check digit computation 10 sum 10 mod sub computes the remainder % from a divide by 10, and then subtracts that from 10 to generate % a digit, which if added back to sum would round it up to the next even % multiple of 10 % /dobar { /msg exch def % get all parameters from the stack. /orient exch def moveto % relative to origin of mail piece /sum 0 def gsave orient 1 eq { 90 rotate 0 -612 translate } if lbar % starting marker msg % process the message. { 48 sub dup % convert the digit to binary sum add /sum exch def % update the checksum /digval exch def % have the binary digit digarray digval get exec % draw the digit. } forall digarray 10 sum 10 mod sub % compute check digit get exec lbar % ending marker stroke grestore } def % % routine takes x y array of strings and does an address block % for an envelope. Prefered is ALL UPPERCASE % [(WOODY BAKER) (RR 1 BOX I) (MANOR TX 78653)] % NOTE: the City State and Zip MUST be the last line, and in that order. % it is preferable NOT to use punctuation. If the last line won't fit, it % is permitted to put the ZIPCODE on the line under that, all by itself. % you should provide that decision, when constructing the array of strings. % % In addition, since this is HELVETICA, and it is Proportional, it % is a wise idea to put 2 spaces down rather than 1 for separation. The % USPS states that there should be at least 1 full space or 1 em space % between the characters, and at least 2 points additional % leading between the lines, 4 points is better for a 10 pt font. % % bottom line of RETURN address no lower that 2 3/4" from bottom edge % of envelope. Mailto address should fit within a rectangle that extends % from 5/8 " from the bottom, to 2 1/4" up from the bottom of the mail piece. % /address { /stringaray exch def /ycoord exch def /xcoord exch def xcoord stringaray length % get number of lines linehite mul ycoord add moveto % adaptively find the top line. stringaray { currentpoint linehite sub exch pop xcoord exch moveto show } forall } def % % example code for testing % 100 120 [(WOODY BAKER) (RR 1 BOX I) (MANOR TX 78653-0102)] address 100 100 0 (786530102) dobar % 200 200 1 (1234567890) dobar showpage