chris@ee.ucla.edu (Christian Valcke) (05/19/89)
After getting the nice PS-calendar generator from the net, I was wondering if anyone has (or know where I can find) a program to make mailing labels for postscript? thanks ARPA: chris@ee.ucla.edu UUCP: {hermix,ucla-se}!ucla-an!chris Christian Valcke UCLA Dept. of Anesthesiology BH-951; LA, CA 90024 (213)206-5681
sam@uokmax.UUCP (incubus) (05/21/89)
In article <41@ucla-an.UUCP>, chris@ee.ucla.edu (Christian Valcke) writes: > After getting the nice PS-calendar generator from the net, > I was wondering if anyone has (or know where I can find) a program > to make mailing labels for postscript? I haven't done much with postscript, but here's a little program with a shell script front end which works well enough for me. The only problem, I suspect, is that the printer does too much work. I'm sure there's a more efficient way to fit the best size font onto a label than what I've done, but there we are. This is for printing onto 8.5" X 11" sheets with 11 rows by 3 columns of labels. ------------------------------ cut here -------------------------------- #!/bin/csh -fe # # This is a shell script for printing address labels. The command # prompts for all input. If the first argument is 'autofeed', # then manual feed (the default) is turned off. All other flags # are passed to the lpr command. If no flags are given, the # default flags are given. # # For multiple instances of labels, you may give several instances # of rows and columns, separated by spaces. For example, # # enter rows for label 1 # (hit return to quit) # rows: 2 3 4 5 6 # enter cols for label 1 # cols: 1 2 set noglob set default = "-Pps" set allRows = "" set allCols = "" set allLabels = "" @ ln = 0 if ("$#argv" != "0") then # yes, this is nasty... if ("$argv[1]" == "autofeed") then set feeder = "noManual" shift else set feeder = "" endif else set feeder = "" endif while (1) @ ln = $ln + 1 echo enter rows for label $ln echo \(hit return to quit\) echo -n "rows: " set rows = ( $< ) if ( "$#rows" == "0" ) break foreach i ( $rows ) @ n = $i if (($n < 1 ) || ($n > 11)) then echo "$i - invalid" exit 1 endif end set rows = "[ $rows ]" echo echo columns for label $ln echo -n "cols: " set cols = ( $< ) foreach i ( $cols ) @ n = $i if (($n < 1 ) || ($n > 3)) then echo "$i - invalid" exit 1 endif end set cols = "[ $cols ]" set labels = "" echo enter label $ln echo \(blank line when done\) while (1) echo -n ": " set label = ( $< ) if ("$#label" == "0") break set labels = "$labels ($label)" end set labels = "[ $labels ]" set allRows = "$allRows $rows" set allCols = "$allCols $cols" set allLabels = "$allLabels $labels" end set allRows = "[ $allRows ]" set allCols = "[ $allCols ]" set allLabels = "[ $allLabels ]" if ("$#argv" == "0") then set flags = "$default" else set flags = "$*" endif if ($ln < 2) exit 0 lpr $flags << slashStarEof %! % % This is the postscript code for printing address labels. The % function showLabel will print a label for a given row an column. % An example is this: % % 3 2 [ % (Harry Fink) % (President, United States) % (1600 Pennsylvania) % (Bethany, OK 73008) % ] showLabel % % This will print the label in row 3, column 2. This will choose % the largest possible font for the given margins, etc. The % first line of a given label is treated specially; it is printed % in the font defined as bigFont, and its size is the size of the % other lines multiplied by deltaBig. All other lines are in % littleFont. % % The functions showSquare and showSeveral are for making it easy % for a shell script to print several labels. /height 72 def /width 8.5 3 div 72 mul def /xmargin 36 def % ceiling of twice the value of pathbbox of default /ymargin 16 def % clippath, with allowances for width /deltaBig 1.25 def /bigFont /Times-BoldItalic findfont def /littleFont /Times-Bold findfont def /buffy (x) def /reCalc true def statusdict /manualfeed true put /noManual { statusdict /manualfeed false put } def /labelbbox { /urx 0 def /ury 0 def /llx 0 def /lly 0 def 0 0 moveto labelLine { { buffy exch 0 exch put currentpoint newpath moveto buffy true charpath flattenpath pathbbox dup ury gt { /ury exch def } { pop } ifelse dup urx gt { /urx exch def } { pop } ifelse dup lly lt { /lly exch def } { pop } ifelse dup llx lt { /llx exch def } { pop } ifelse } forall littleFont p scalefont setfont 0 currentpoint exch pop p sub moveto } forall } bind def /showLabel { % row col [ (line1) (line2) ... ] showLabel - gsave /labelLine exch def /col exch 1 sub def /row exch 1 sub def reCalc { gsave /p height ymargin sub deltaBig labelLine length add 1 sub div ceiling def { bigFont p deltaBig mul floor scalefont setfont labelbbox urx llx sub width xmargin sub lt ury lly sub height ymargin sub lt and { exit } if /p p 1 sub def } loop grestore } if col width mul row height mul 11 72 mul exch sub height sub translate width urx llx sub sub 2 div height ury lly sub sub 2 div translate llx neg lly neg translate bigFont p deltaBig mul floor scalefont setfont 0 0 moveto labelLine { show 0 currentpoint exch pop p sub moveto littleFont p scalefont setfont } forall grestore } bind def /showSquare { % [ rows ] [ cols ] [ label ] showSquare - /ssLabel exch def /ssCols exch def /ssRows exch def ssRows { ssCols { exch dup 3 -1 roll ssLabel showLabel /reCalc false def } forall pop } forall /reCalc true def } bind def /showSeveral { % [[rows] ...] [[cols] ...] [label ...] showSeveral - /sevLabel exch def /sevCols exch def /sevRows exch def 1 1 sevCols length { /i exch 1 sub def sevRows i get sevCols i get sevLabel i get showSquare } for } bind def $allRows $allCols $allLabels showSeveral $feeder showpage slashStarEof ------------------------------ cut here -------------------------------- -- sam falkner ...!sun!texsun\ +------------------------------+ >!uokmax!sam | if it bleeds, we can kill it | ...!att!occrsh/ +------------------------------+