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