[comp.lang.postscript] Full sheet address label program

mireley@eecae.UUCP (John Mireley) (03/21/89)

Is there a postcript program available that takes as input
a file of one line, delimited addresses, that would print
these in three columns and positioned on an 8.5x11 page, to make use
of a full sheet of Avery address labels designed for copiers.

I have been using pr with Adobe's enscript to do this. I end up wasting
a line of labels at the bottom plus it's a pain to figure out
what to set pr's l flag to. There is also a lot of space in the
left margin that is wasted.

John Mireley

bukys@cs.rochester.edu (Liudvikas Bukys) (03/22/89)

In article <15294@eecae.UUCP> mireley@eecae.UUCP (John Mireley) writes:
>Is there a postcript program available that takes as input
>a file of one line, delimited addresses, that would print
>these in three columns and positioned on an 8.5x11 page, to make use
>of a full sheet of Avery address labels designed for copiers.

Here is a shell script that takes as input a bunch of labels,
with newlines at the ends of lines, and a blank line between labels.

--------------------------------CUT-HERE---------------------------------------

#!/bin/sh
###############################################################################
#
# label2ps -- convert label data to postscript, in 11 x 3 format
# by Liudvikas Bukys	<bukys@cs.rochester.edu>	October 7, 1988
#
###############################################################################

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
	}'

--------------------------------CUT-HERE---------------------------------------