Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / share / examples / printing / make-ps-header
1 #!/bin/sh
2 #
3 #  make-ps-header - make a PostScript header page on stdout
4 #  Installed in /usr/local/libexec/make-ps-header
5 #
6
7 #
8 #  These are PostScript units (72 to the inch).  Modify for A4 or
9 #  whatever size paper you are using:
10 #
11 page_width=612
12 page_height=792
13 border=72
14
15 #
16 #  Check arguments
17 #
18 if [ $# -ne 3 ]; then
19     echo "Usage: `basename $0` <user> <host> <job>" 1>&2
20     exit 1
21 fi
22
23 #
24 #  Save these, mostly for readability in the PostScript, below.
25 #
26 user=$1
27 host=$2
28 job=$3
29 date=`date`
30
31 #
32 #  Send the PostScript code to stdout.
33 #
34 exec cat <<EOF
35 %!PS
36
37 %
38 %  Make sure we do not interfere with user's job that will follow
39 %
40 save
41
42 %
43 %  Make a thick, unpleasant border around the edge of the paper.
44 %
45 $border $border moveto
46 $page_width $border 2 mul sub 0 rlineto
47 0 $page_height $border 2 mul sub rlineto
48 currentscreen 3 -1 roll pop 100 3 1 roll setscreen
49 $border 2 mul $page_width sub 0 rlineto closepath
50 0.8 setgray 10 setlinewidth stroke 0 setgray
51
52 %
53 %  Display user's login name, nice and large and prominent
54 %
55 /Helvetica-Bold findfont 64 scalefont setfont
56 $page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto
57 ($user) show
58
59 %
60 %  Now show the boring particulars
61 %
62 /Helvetica findfont 14 scalefont setfont
63 /y 200 def
64 [ (Job:) (Host:) (Date:) ] {
65         200 y moveto show /y y 18 sub def
66 } forall
67
68 /Helvetica-Bold findfont 14 scalefont setfont
69 /y 200 def
70 [ ($job) ($host) ($date) ] {
71         270 y moveto show /y y 18 sub def
72 } forall
73
74 %
75 %  That is it
76 %
77 restore
78 showpage
79 EOF