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