Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!rochester!bukys From: bukys@cs.rochester.edu (Liudvikas Bukys) Newsgroups: comp.lang.postscript Subject: Re: mail labels Keywords: postscript, mailing labels Message-ID: <1990Dec18.153331.1990@cs.rochester.edu> Date: 18 Dec 90 15:33:31 GMT References: <1763@chinacat.Unicom.COM> Reply-To: bukys@cs.rochester.edu (Liudvikas Bukys) Organization: University of Rochester Computer Science Dept Lines: 98 Here is a little shell&awk script which takes in label information, separated by blank lines, and outputs labels suitable for printing on the 3-across 11-down sheets commonly available these days. Liudvikas Bukys #!/bin/sh ############################################################################### # # label2ps -- convert label data to postscript, in 11 x 3 format # # to use this program: # # (1) Load the printer with label-paper, FACE DOWN # # (2) Type # # label2ps labelfile1 labelfile2 labelfile3 ... > labels.ps # lpr labels.ps # # (3) If some of the pages turned out bad, you can extract and print # a subset of pages. For example, if you want pages 3,4,5, and 9 # again, you can do this: # # psrev -s 3-5,9 labels.ps | lpr # ############################################################################### for f in "${@-'-'}" do cat "$f" echo "" done | sed -e 's/[\\()]/\\&/g' | awk ' BEGIN { print "%!PS-Adobe-1.0" print "%%Pages: (atend)" print "%%DocumentFonts: Helvetica Helvetica-BoldOblique" print "%%BoundingBox: 0 0 612 792" print "%%EndComments" print "/Helvetica findfont 9 scalefont setfont" print "/INIT {" print " /N 0 def" print " } def" print "/NEXT {" print "% N 32 ge { (page ?) PAGE } if" print " 0 792 moveto" print " 18 -22 rmoveto" print " N 11 idiv 204 mul N 11 mod -72 mul rmoveto" print " /N N 1 add def" print " } def" print "/LINE {" print " gsave show grestore" print " 0 -10 rmoveto" print " } def" print "/PAGE {" print " gsave" print " /Helvetica-BoldOblique findfont 8 scalefont setfont" print " 426 30 moveto" print " LINE" print " 0 -10 rmoveto" print " ('"`whoami` `date`"') LINE" print " grestore" print " showpage" print " INIT" print " } def" print "INIT" print "%%EndProlog" print "%%Page: 1 1" labels = 0 pages = 1 } { if ($0 == "") line = 0 else { if (line++ == 0) { if (labels%32 == 0 && labels != 0) { print "(" "page " pages ") PAGE" pages++ print "%%Page: " pages " " pages } print "NEXT" labels++ } print "(" $0 ") LINE" } } END { print "NEXT" print "(TOTAL OF " labels " LABELS PRINTED) LINE" print "(" "page " pages ") PAGE" print "%%Trailer" print "%%Pages: " pages }'