#!/bin/bash # # Plop - print labels on printer # $Id:$ # (C) 2002 Henk Kloepping # # Create a (series of) sheet(s) with address labels from # a text file. This script assumes you use Avery A4 # labelsheets, with 3 columns and 8 rows. However, the # techniques used here are suitable for other types of # sheets too. YMMV. # # Syntax: plop -r inputfile # ----------------- CONFIGURATION SECTION ----------------- # # Plop accepts a comma delimited input file by default, but # it can be changed. However, do not use the '+' if you want # to be able to use special characters # SEP=, # You can twiddle around with the positioning of the texts: # PUSH_DOWN=5 # the amount of points to push texts down PUSH_RIGHT=5 # the amount of points to push texts right # # --------------- CONFIGURATION SECTION ENDS --------------- # Generic fail function # fail() { echo "Failed: " $* >&2 exit 1 } # This function print the PostScript header and sets the # standard font. The Time-Roman fond is universally available # on all Postscript printers. # header() { cat << EOF1 %!PS-Adobe-1.0 % Created by `basename $0` on `date` % A4 594 x 842 high /Time-Roman findfont 12 scalefont setfont EOF1 } # To be able to create overstrikes I created a special Postscript # dictionary entry. It expects the two characters to be on the stack. # It will determine the width of both characters and calculates the # offset needed to print the narrowest character in the exact middle # of the widest character. It will then print the narrowest character # in the middle of the space needed for the widest character, reposition # on the start coordinates of the widest character and returns, leaving # the widest charachter on stack for future 'show' (printing). # # to use it, you can simply issue e.g. # # (o) (") mix show # # For convenience sake, there are also dictionary entries for # cedille, tilde, umlaut, aigu, grave, caret, and ohje, that allow e.g. # # (o) cedille show # symbolmaker() { cat <0 ) { pc=split(label[m,lali],part,"+") printf "%d %d moveto ",pos[1]+pr,pos[lali+1]-pd if (pc==1) { printf "(%s) show ",part[1]; } else { for(n=1;n1) { printf "(%s) show ",substr(part[n],1,lp-1),lp; } clf=substr(part[n],lp,1); crt=substr(part[n+1],1,1); # Do we need ^+n which prints a superscript n? # How do we overstrike with a plus? if (clf=="\\" && crt=="\\") { # \+\ plus printf "(+) show " } else if (clf=="s" && crt=="s") { # s+s ringeless printf "(\\373) show " } else if (clf=="\~" && crt=="\"") { # ~+" hi-double printf "(\\272) show " } else if (clf=="\_" && crt=="\"") { # _+" low-double printf "(\\271) show " } else if (crt=="\"") { # x umlaut printf "(%s) umlaut show ",clf } else if (crt=="\;") { # x cedille printf "(%s) cedille show ",clf } else if (crt=="\~") { # x tilde printf "(%s) tilde show ",clf } else if (crt=="\/") { # x aigu printf "(%s) aigu show ",clf } else if (crt=="\\") { # x grave printf "(%s) grave show ",clf } else if (crt=="\^") { # x caret printf "(%s) caret show ",clf } else if (crt=="\o") { # x o printf "(%s) ohje show ",clf } else { # overstrike. printf "(%s) (%s) mix show ",clf,crt } part[n+1]=substr(part[n+1],2); } if (length(part[n])>0) printf "(%s) show ",part[n]; } printf "\n"; } } } }' echo "showpage"