| FreeBSD handbook中文版11 打印(2)高级打印机设置 A.过滤器 |
 |
作者: 来源: 日期:2007-6-22 12:25:57 点击次数: |
|
这里有一个例子:下面的script 是给Hewlett Packard DeskJet 500 打印机用的文字 过滤程序。如果是其它的打印机,将gs (Ghostscript)命令的-sDEVICE 参数换成你能使用 的设备即可。(你可以用gs -h 这个命令得到目前系统安装的Ghostscript 支持哪些设备)。 第27 页FreeBSD 使用手册 #!/bin/sh # # ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 # Installed in /usr/local/libexec/hpif # # Treat LF as CR+LF: # printf “\033&k2G” || exit 2 # # Read first two characters of the file # read first_line first_two_chars=‘expr “$first_line” : ‘\(..\)’‘ if [ “$first_two_chars” = “%!” ]; then # # It is PostScript; use Ghostscript to scan-convert and print it. # # note that PostScript files are actually interpreted programs, # and those programs are allowed to write to stdout, which will # mess up the printed output. So, we redirect stdout to stderr # and then make descriptor 3 go to stdout, and have Ghostscript # write its output there. Exercise for the clever reader: # capture the stderr output from Ghostscript and mail it back to # the user originating the print job. # exec 3>&1 1>&2 /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \ 第28 页sOutputFile=/dev/fd/3 - && exit 0 · # /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ && exit 0 else # # Plain text or HP/PCL, so just print it directly; print a form # at the end to eject the last page. # echo $first_line && cat && printf “\033&l0H” && exit 0 fi exit 2 最后,你需要用if 关键词指定这个过滤程序: :if=/usr/local/libexec/hpif: 这么一来,你可以输入lpr plain.text 和lpr whatever.ps 而这两者应该都要可以正 确打印。 11.4.1.4 转换用的过滤程序 在完成上面简单的打印机设置这一节所介绍的设置后,下面要做的就是为我们还想要 使用的文件格式(除了ASCII 纯文本外)安装转换用的过滤程序。 11.4.1.4.1 为什么要安装转换用的过滤器? 转换用的过滤程序让打印不同格式的文件变得很简单。举例来说,如果我们常常用TeX 来产生文件,但是我们的打印机是PostScript 的。因此我们不能直接将由TeX 产生的DVI 文件由打印机打出,而要先转换成PostScript 的格式才能输出。这些转换的命令如下: % dvips seaweed-analysis.dvi % lpr seaweed-analysis.ps 如果我们安装了DVI 文件的转换程序,那么我们每次要打印时就可以省去自己转换格式 的动作,而交由LPD 自己转。因此,我们要打印DVI 文件时只要这一步就可以了: % lpr -d seaweed-analysis.dvi FreeBSD 使用手册 第29 页FreeBSD 使用手册 只要在使用LPD 时加上-d 参数,LPD 就会将DVI 文件转换后再正确的打出。输出格式及 转换的参数这一节里有详细的列出转换用的参数。 对于每一个转换用的参数,我们必需为打印机安装合适的转换用过滤程序,同时在 /etc/printcap 文件里指定该过滤程序。转换用的过滤程序和文字过滤程序很相似(请阅读 安装文字过滤程序这一节),除了它不是打印纯文本而是将文件转换成打印机可以处理的格 上一篇:FreeBSD handbook中文版11 打印(1)基本设置 下一篇:FreeBSD handbook中文版11 打印(3)使用打印机 |
|
|
 |
| 北京总部: 4006-505-808 |
| 天 津 部: 4006-505-808 |
| 上 海 部: 4006-505-808 |
| 深 圳 部: 4006-505-808 |
| 广 州 部: 4006-505-808 |
| 重 庆 部: 4006-505-808 |
| 南 京 部: 4006-505-808 |
| 其它地区: 4006-505-808 | |
|
 |
|