xref: /freebsd/share/examples/printing/make-ps-header (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
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#
11page_width=612
12page_height=792
13border=72
14
15#
16#  Check arguments
17#
18if [ $# -ne 3 ]; then
19    echo "Usage: `basename $0` <user> <host> <job>" 1>&2
20    exit 1
21fi
22
23#
24#  Save these, mostly for readability in the PostScript, below.
25#
26user=$1
27host=$2
28job=$3
29date=`date`
30
31#
32#  Send the PostScript code to stdout.
33#
34exec cat <<EOF
35%!PS
36
37%
38%  Make sure we do not interfere with user's job that will follow
39%
40save
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
470 $page_height $border 2 mul sub rlineto
48currentscreen 3 -1 roll pop 100 3 1 roll setscreen
49$border 2 mul $page_width sub 0 rlineto closepath
500.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%
77restore
78showpage
79EOF
80