/share/examples/printing/make-ps-header
https://bitbucket.org/freebsd/freebsd-head/ · Shell · 79 lines · 53 code · 8 blank · 18 comment · 1 complexity · 85aded538d08916addb2c6f44b3530e9 MD5 · raw file
- #!/bin/sh
- #
- # make-ps-header - make a PostScript header page on stdout
- # Installed in /usr/local/libexec/make-ps-header
- #
- #
- # These are PostScript units (72 to the inch). Modify for A4 or
- # whatever size paper you are using:
- #
- page_width=612
- page_height=792
- border=72
- #
- # Check arguments
- #
- if [ $# -ne 3 ]; then
- echo "Usage: `basename $0` <user> <host> <job>" 1>&2
- exit 1
- fi
- #
- # Save these, mostly for readability in the PostScript, below.
- #
- user=$1
- host=$2
- job=$3
- date=`date`
- #
- # Send the PostScript code to stdout.
- #
- exec cat <<EOF
- %!PS
- %
- % Make sure we do not interfere with user's job that will follow
- %
- save
- %
- % Make a thick, unpleasant border around the edge of the paper.
- %
- $border $border moveto
- $page_width $border 2 mul sub 0 rlineto
- 0 $page_height $border 2 mul sub rlineto
- currentscreen 3 -1 roll pop 100 3 1 roll setscreen
- $border 2 mul $page_width sub 0 rlineto closepath
- 0.8 setgray 10 setlinewidth stroke 0 setgray
- %
- % Display user's login name, nice and large and prominent
- %
- /Helvetica-Bold findfont 64 scalefont setfont
- $page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto
- ($user) show
- %
- % Now show the boring particulars
- %
- /Helvetica findfont 14 scalefont setfont
- /y 200 def
- [ (Job:) (Host:) (Date:) ] {
- 200 y moveto show /y y 18 sub def
- } forall
- /Helvetica-Bold findfont 14 scalefont setfont
- /y 200 def
- [ ($job) ($host) ($date) ] {
- 270 y moveto show /y y 18 sub def
- } forall
- %
- % That is it
- %
- restore
- showpage
- EOF