#!/bin/awk -f # # NAME: # face_labels # # PEDIGREE: # Motivated by Bradley C. Spatz, bcs@ufl.edu # Code: 08/12/90 - Brian Bartholomew - bb@beach.cis.ufl.edu # # PURPOSE: # Prints out address labels from a face file, a'la USENIX. # Designed for Avery Laser-Printable stock # 5160. # # USAGE: # face_labels face_file | lpr -Ppostscript_printer # # BUGS: # I could not get documentation on the face file format, so # the code I have written is based on the format that we have # in house. As an example, here is the first part of one of # our face files: # # FirstName: Bradley # LastName: Spatz # E-mail: bcs@ufl.edu # Telephone: 904/338-0513 # Company: University of Florida # Address1: 2236 NW 11th Avenue # Address2: # CityStateZip: Gainesville, FL 32605 # Date: Jan 23 1990 # PicData: 108 128 8 # Image: 96 128 8 # # 15181A141310141313130F0C090D1012111013121112110F11110C # 0C0F0E0E0F0E0D0E0C0B0C0A080C0D0B0D0D0B0A0B0909090A1118 # 1717191A15141615171E1E201E1A17140F0E1317100907080A090B # # # If your face file has other data lines than these, you will # have to add a line to the awk script to process or discard # it. Another problem I expect has to do with the hex image # data. Right now, the awk regex matches lines that only # appear to contain packed hex data, either uppercase or # lower. It is conceivable that some comment or data line # might match this as well, causing errors. The data lines # should be in the same order as shown here, else the text # placement on the label will be badly off. I am not sure # what information is carried in the "Image:" line; the # "PicData:" line describes the actual image contained in our # files, so that is what I have used. The image-depth number # in the "PicData:" line is used, but other settings of it # have not been tried; in particular, if an image is other # than 1 or 8 bits deep, the edges of the scan lines must be # padded out to a full byte, or else Postscript will be upset. # The Postscript was built to auto-scale the image to fit # height-wise on the label, with the assumptions that the # pixels are square; it will work better if the image is # taller than it is wide. # # In short, this is a working prototype, but not a finished, # polished anything. Executor emptor. # BEGIN { print "%!" print "" print "%" print "% Postscript output from: face_labels" print "%" print "% Motivated by Bradley C. Spatz, bcs@ufl.edu" print "% PostScript 08/12/90 - Brian Bartholomew, bb@beach.cis.ufl.edu" print "%" print "% Prints out 30 address labels from a face file, a'la USENIX." print "% Designed for Avery Laser-Printable stock # 5160." print "%" print "% You can uncomment the do_outline line at the bottom, if" print "% you wish to check the alignment of the Postscript with the" print "% labels before you print. Leave it out for the final run," print "% as it will make a mess on the label edges when it" print "% unavoidably doesn't line up perfectly." print "%" print "" print "/do_outline {" print "\tgsave" print "\ttranslate" print "\t1.3 0 translate\t\t% middle bottom of label" print "\t0 0 moveto" print "\t1.3 0 1.3 1 0.09 arcto" print "\t4 {pop} repeat" print "\t1.3 1 -1.3 1 0.09 arcto" print "\t4 {pop} repeat" print "\t-1.3 1 -1.3 0 0.09 arcto" print "\t4 {pop} repeat" print "\t-1.3 0 0 0 0.09 arcto" print "\t4 {pop} repeat" print "\tclosepath" print "\tstroke" print "\tgrestore" print "} bind def" print "" print "" print "/do_text {" print "\tgsave" print "\ttranslate" print "\tgsave" print "\t1 0.8 translate" } # # Now we define the label guts, by reading from the face file. # Note that some of the fields are order-dependent, and the image # should be roughly square; better if it is taller than it is wide. # /^FirstName/ { print "\t0 0 moveto" print "\t/Helvetica-Bold findfont 8 72 div scalefont setfont" printf ("\tgsave (%s ) show\n", $2) } /^LastName:/ { printf ("\t(%s %s %s) show grestore\n", $2, $3, $4) print "\t/Helvetica findfont 8 72 div scalefont setfont" } /^E-mail:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s) show grestore\n", $2, $3, $4) } /^Telephone:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s) show grestore\n", $2, $3, $4) } /^Company:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s %s %s %s) show grestore\n", \ $2, $3, $4, $5, $6, $7) } /^Address1:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s %s %s %s) show grestore\n", \ $2, $3, $4, $5, $6, $7) } /^Address2:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s %s %s %s) show grestore\n", \ $2, $3, $4, $5, $6, $7) } /^CityStateZip:/ { print "\t0 -0.1111 rmoveto" printf ("\tgsave (%s %s %s %s %s %s) show grestore\n", \ $2, $3, $4, $5, $6, $7) } /^Date:/ {} # Throw it away /^PicData:/ { print "\tgrestore" print "\t0.15 0.9 translate" printf ("\t0.8 %d mul %d div 0.8 scale\n", $2, $3) printf ("\t%d %d %d [ %d 0 0 %d 0 %d ]\n", \ $2, $3, $4, $2, $3, $3) print "\t{ <" } /^Image:/ {} # Throw it away /^[0123456789ABCDEFabcdef]*$/ { printf ("\t%s\n", $0) } # # Finish off the procedure, and print the labels in a nested loop. # END { print "\t> } image" print "\tgrestore" print "} bind def" print "" print "" print "%" print "% Now print the labels in a doubly-nested loop." print "%" print "" print "72 72 scale" print "0.2 0.5 translate" print "0 setgray" print "1 300 div setlinewidth" print "/Helvetica findfont 8 72 div scalefont setfont" print "" print "0 2.75 7.25 {" print "\t/x exch def" print "\t0 1 9 {" print "\t\t/y exch def" print "\t\t% x y do_outline" print "\t\tx y do_text" print "\t} for" print "} for" print "" print "" print "showpage" }