2 FreeBSD handbook中文版 11 打印 高级打印机设置 B.Header Pages( 三 )


#
page_width=612
page_height=792
border=72
#
第43 页if [ $# -ne 3 ]; then
exit 1
fi
#
#
user=$1
host=$2
job=$3
date=‘date‘
#
#
exec cat <%!PS
%
%
save
%
%
$border $border moveto
FreeBSD 使用手册
echo “Usage: ‘basename $0‘ ” 1>&2
# Save these, mostly for readability in the PostScript, below.
# Send the PostScript code to stdout.
% Make sure we do not interfere with user"s job that will follow
% Make a thick, unpleasant border around the edge of the paper.
$page_width $border 2 mul sub 0 rlineto
0 $page_height $border 2 mul sub rlineto
第44 页%
%
($user) show
%
%
/y 200 def
[ (Job:) (Host:) (Date:) ] {
forall
/y 200 def
[ ($job) ($host) ($date) ] {
FreeBSD 使用手册
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
% Now show the boring particulars
/Helvetica findfont 14 scalefont setfont
200 y moveto show /y y 18 sub def }
/Helvetica-Bold findfont 14 scalefont setfont
270 y moveto show /y y 18 sub def
} forall
%
% That is it
%
restore
第45 页showpage
EOF
现在,每个转换用过滤程序以及文字过滤程序可以在打印前先呼叫这个script 打印出
FreeBSD 使用手册
header page 然后再打印工作的内容 。我们修改之前提过的DVI 转换用过滤程序使它可以打
印header page:
#!/bin/sh
#
# psdf - DVI to PostScript printer filter
# Installed in /usr/local/libexec/psdf
#
# Invoked by lpd when user runs lpr -d
#
orig_args=”$@”
fail() {
echo “$@” 1>&2
exit 2
}
while getopts “x:y:n:h:” option; do
case $option in
x|y) # Ignore
n) login=$OPTARG
h) host=$OPTARG
*) echo “LPD started ‘basename $0‘ wrong.” 1>&2
exit 2

esac
done
[ “$login” ] || fail “No login name”
第46 页FreeBSD 使用手册
[ “$host” ] || fail “No host name”
( /usr/local/libexec/make-ps-header $login $host “DVI File”
/usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args
注意这个过滤程序如何从参数中取出使用者名称及机器名称 。虽然这个过滤程序使用了
一些不同的参数(请阅读过滤程序的运作方式这一节),不过同样的技巧也可以应用在其它
不同的过滤程序上 。
不过就如我们前面所提到的,这个方式虽然很简单,但是却让lpr 命令无法“不打印
header page”(即-h 参数无效) 。如果使用者想要少花些钱(如果打印header pages 要收费的
话),那么它们将无法做到 。因为每个过滤程序都会为每个工作打印header page 。
如果要允许使用者可以自己选择是否打印header pager,你得使用统计打印Header
Pages 这里介绍的技巧:写一个可以判断由LPD 产生的header page 的输出用过滤程序,并
由它输出PostScript 打印机可以处理的资料 。这么一来,如果使用者以lpr -h 送出工作,
LPD 将不会产生header page,且你的输出用过滤程序也不会 。否则,你的输出用过滤程序
将要根据LPD 送出的资料然后以适当PostScript 码将header page 送给打印机处理 。
如果你的PostScript 打印机是接在串行端口上,那么你可以使用lprps 里提供的输出用
过滤程序,psof,这个过滤程序会做上述的动作 。注意,psof 这个过滤程序将不会为header
pages 计费 。
11.4.3 网络打印
FreeBSD 支持网络打印:将工作送给远程的打印机处理 。网络打印有两大类型:
1. 访问远程机器所安装的打印机 。你在某一台机器上的串口或并口上接了一台打印机,然

推荐阅读