⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printing-advanced.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Advanced Printer Setup</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Printing" href="printing.html" /><link rel="PREVIOUS" title="Basic Setup" href="printing-intro-setup.html" /><link rel="NEXT" title="Using Printers" href="printing-using.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="printing-intro-setup.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 9 Printing</td><td width="10%" align="right" valign="bottom"><a href="printing-using.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="PRINTING-ADVANCED" name="PRINTING-ADVANCED">9.4 Advanced PrinterSetup</a></h1><p>This section describes filters for printing specially formatted files, header pages,printing across networks, and restricting and accounting for printer usage.</p><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-ADVANCED-FILTER-INTRO"name="PRINTING-ADVANCED-FILTER-INTRO">9.4.1 Filters</a></h2><p>Although <b class="APPLICATION">LPD</b> handles network protocols, queuing, accesscontrol, and other aspects of printing, most of the <span class="emphasis"><iclass="EMPHASIS">real</i></span> work happens in the <span class="emphasis"><iclass="EMPHASIS">filters</i></span>. Filters are programs that communicate with theprinter and handle its device dependencies and special requirements. In the simpleprinter setup, we installed a plain text filter--an extremely simple one that should workwith most printers (section <ahref="printing-intro-setup.html#PRINTING-TEXTFILTER">Installing the Text Filter</a>).</p><p>However, in order to take advantage of format conversion, printer accounting, specificprinter quirks, and so on, you should understand how filters work. It will ultimately bethe filter's responsibility to handle these aspects. And the bad news is that most of thetime <span class="emphasis"><i class="EMPHASIS">you</i></span> have to provide filtersyourself. The good news is that many are generally available; when they are not, they areusually easy to write.</p><p>Also, FreeBSD comes with one, <tt class="FILENAME">/usr/libexec/lpr/lpf</tt>, thatworks with many printers that can print plain text. (It handles backspacing and tabs inthe file, and does accounting, but that is about all it does.) There are also severalfilters and filter components in the FreeBSD Ports Collection.</p><p>Here is what you will find in this section:</p><ul><li><p>Section <a href="printing-advanced.html#PRINTING-ADVANCED-FILTERS">How FiltersWork</a>, tries to give an overview of a filter's role in the printing process. Youshould read this section to get an understanding of what is happening ``under the hood''when <b class="APPLICATION">LPD</b> uses filters. This knowledge could help youanticipate and debug problems you might encounter as you install more and more filters oneach of your printers.</p></li><li><p><b class="APPLICATION">LPD</b> expects every printer to be able to print plain text bydefault. This presents a problem for <span class="TRADEMARK">PostScript</span>&reg; (orother language-based printers) which cannot directly print plain text. Section <ahref="printing-advanced.html#PRINTING-ADVANCED-IF-CONVERSION">Accommodating Plain TextJobs on <span class="TRADEMARK">PostScript</span> Printers</a> tells you what you shoulddo to overcome this problem. You should read this section if you have a <spanclass="TRADEMARK">PostScript</span> printer.</p></li><li><p><span class="TRADEMARK">PostScript</span> is a popular output format for manyprograms. Some people even write <span class="TRADEMARK">PostScript</span> code directly.Unfortunately, <span class="TRADEMARK">PostScript</span> printers are expensive. Section<a href="printing-advanced.html#PRINTING-ADVANCED-PS">Simulating <spanclass="TRADEMARK">PostScript</span> on Non <span class="TRADEMARK">PostScript</span>Printers</a> tells how you can further modify a printer's text filter to accept and print<span class="TRADEMARK">PostScript</span> data on a <span class="emphasis"><iclass="EMPHASIS">non <span class="TRADEMARK">PostScript</span></i></span> printer. Youshould read this section if you do not have a <span class="TRADEMARK">PostScript</span>printer.</p></li><li><p>Section <a href="printing-advanced.html#PRINTING-ADVANCED-CONVFILTERS">ConversionFilters</a> tells about a way you can automate the conversion of specific file formats,such as graphic or typesetting data, into formats your printer can understand. Afterreading this section, you should be able to set up your printers such that users can type<tt class="COMMAND">lpr -t</tt> to print troff data, or <tt class="COMMAND">lpr -d</tt>to print <b class="APPLICATION">TeX</b> DVI data, or <tt class="COMMAND">lpr -v</tt> toprint raster image data, and so forth. I recommend reading this section.</p></li><li><p>Section <a href="printing-advanced.html#PRINTING-ADVANCED-OF">Output Filters</a> tellsall about a not often used feature of <b class="APPLICATION">LPD</b>: output filters.Unless you are printing header pages (see <ahref="printing-advanced.html#PRINTING-ADVANCED-HEADER-PAGES">Header Pages</a>), you canprobably skip that section altogether.</p></li><li><p>Section <a href="printing-advanced.html#PRINTING-ADVANCED-LPF">lpf: a Text Filter</a>describes <tt class="COMMAND">lpf</tt>, a fairly complete if simple text filter for lineprinters (and laser printers that act like line printers) that comes with FreeBSD. If youneed a quick way to get printer accounting working for plain text, or if you have aprinter which emits smoke when it sees backspace characters, you should definitelyconsider <tt class="COMMAND">lpf</tt>.</p></li></ul><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> A copy of the various scripts described below can be found in the <ttclass="FILENAME">/usr/share/examples/printing</tt> directory.</p></blockquote></div><div class="SECT3"><h3 class="SECT3"><a id="PRINTING-ADVANCED-FILTERS"name="PRINTING-ADVANCED-FILTERS">9.4.1.1 How Filters Work</a></h3><p>As mentioned before, a filter is an executable program started by <bclass="APPLICATION">LPD</b> to handle the device-dependent part of communicating with theprinter.</p><p>When <b class="APPLICATION">LPD</b> wants to print a file in a job, it starts a filterprogram. It sets the filter's standard input to the file to print, its standard output tothe printer, and its standard error to the error logging file (specified in the <varclass="LITERAL">lf</var> capability in <tt class="FILENAME">/etc/printcap</tt>, or <ttclass="FILENAME">/dev/console</tt> by default).</p><p>Which filter <b class="APPLICATION">LPD</b> starts and the filter's arguments dependon what is listed in the <tt class="FILENAME">/etc/printcap</tt> file and what argumentsthe user specified for the job on the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> command line.For example, if the user typed <tt class="COMMAND">lpr -t</tt>, <bclass="APPLICATION">LPD</b> would start the troff filter, listed in the <varclass="LITERAL">tf</var> capability for the destination printer. If the user wanted toprint plain text, it would start the <var class="LITERAL">if</var> filter (this is mostlytrue: see <a href="printing-advanced.html#PRINTING-ADVANCED-OF">Output Filters</a> fordetails).</p><p>There are three kinds of filters you can specify in <ttclass="FILENAME">/etc/printcap</tt>:</p><ul><li><p>The <span class="emphasis"><i class="EMPHASIS">text filter</i></span>, confusinglycalled the <span class="emphasis"><i class="EMPHASIS">input filter</i></span> in <bclass="APPLICATION">LPD</b> documentation, handles regular text printing. Think of it asthe default filter. <b class="APPLICATION">LPD</b> expects every printer to be able toprint plain text by default, and it is the text filter's job to make sure backspaces,tabs, or other special characters do not confuse the printer. If you are in anenvironment where you have to account for printer usage, the text filter must alsoaccount for pages printed, usually by counting the number of lines printed and comparingthat to the number of lines per page the printer supports. The text filter is startedwith the following argument list:</p><p><tt class="COMMAND">filter-name</tt> [-c] -w<var class="REPLACEABLE">width</var>-l<var class="REPLACEABLE">length</var> -i<var class="REPLACEABLE">indent</var> -n <varclass="REPLACEABLE">login</var> -h <var class="REPLACEABLE">host</var> <varclass="REPLACEABLE">acct-file</var></p>where <div class="VARIABLELIST"><dl><dt><var class="OPTION">-c</var></dt><dd><p>appears if the job is submitted with <tt class="COMMAND">lpr -l</tt></p></dd><dt><var class="REPLACEABLE">width</var></dt><dd><p>is the value from the <var class="LITERAL">pw</var> (page width) capability specifiedin <tt class="FILENAME">/etc/printcap</tt>, default 132</p></dd><dt><var class="REPLACEABLE">length</var></dt><dd><p>is the value from the <var class="LITERAL">pl</var> (page length) capability, default66</p></dd><dt><var class="REPLACEABLE">indent</var></dt><dd><p>is the amount of the indentation from <tt class="COMMAND">lpr -i</tt>, default 0</p></dd><dt><var class="REPLACEABLE">login</var></dt><dd><p>is the account name of the user printing the file</p></dd><dt><var class="REPLACEABLE">host</var></dt><dd><p>is the host name from which the job was submitted</p></dd><dt><var class="REPLACEABLE">acct-file</var></dt><dd><p>is the name of the accounting file from the <var class="LITERAL">af</var>capability.</p></dd></dl></div><br /><br /></li><li><p>A <span class="emphasis"><i class="EMPHASIS">conversion filter</i></span> converts aspecific file format into one the printer can render onto paper. For example, ditrofftypesetting data cannot be directly printed, but you can install a conversion filter forditroff files to convert the ditroff data into a form the printer can digest and print.Section <a href="printing-advanced.html#PRINTING-ADVANCED-CONVFILTERS">ConversionFilters</a> tells all about them. Conversion filters also need to do accounting, if youneed printer accounting. Conversion filters are started with the following arguments:</p><p><tt class="COMMAND">filter-name</tt> -x<var class="REPLACEABLE">pixel-width</var>-y<var class="REPLACEABLE">pixel-height</var> -n <var class="REPLACEABLE">login</var> -h<var class="REPLACEABLE">host</var> <var class="REPLACEABLE">acct-file</var></p>where <var class="REPLACEABLE">pixel-width</var> is the value from the <varclass="LITERAL">px</var> capability (default 0) and <varclass="REPLACEABLE">pixel-height</var> is the value from the <varclass="LITERAL">py</var> capability (default 0).<br /><br /></li><li><p>The <span class="emphasis"><i class="EMPHASIS">output filter</i></span> is used onlyif there is no text filter, or if header pages are enabled. In my experience, outputfilters are rarely used. Section <ahref="printing-advanced.html#PRINTING-ADVANCED-OF">Output Filters</a> describe them.There are only two arguments to an output filter:</p><p><tt class="COMMAND">filter-name</tt> -w<var class="REPLACEABLE">width</var> -l<varclass="REPLACEABLE">length</var></p>which are identical to the text filters <var class="OPTION">-w</var> and <varclass="OPTION">-l</var> arguments.<br /><br /></li></ul><p>Filters should also <span class="emphasis"><i class="EMPHASIS">exit</i></span> withthe following exit status:</p><div class="VARIABLELIST"><dl><dt>exit 0</dt><dd><p>If the filter printed the file successfully.</p></dd><dt>exit 1</dt><dd><p>If the filter failed to print the file but wants <b class="APPLICATION">LPD</b> to tryto print the file again. <b class="APPLICATION">LPD</b> will restart a filter if it exitswith this status.</p></dd><dt>exit 2</dt><dd><p>If the filter failed to print the file and does not want <bclass="APPLICATION">LPD</b> to try again. <b class="APPLICATION">LPD</b> will throw outthe file.</p></dd></dl></div><p>The text filter that comes with the FreeBSD release, <ttclass="FILENAME">/usr/libexec/lpr/lpf</tt>, takes advantage of the page width and lengtharguments to determine when to send a form feed and how to account for printer usage. Ituses the login, host, and accounting file arguments to make the accounting entries.</p><p>If you are shopping for filters, see if they are LPD-compatible. If they are, theymust support the argument lists described above. If you plan on writing filters forgeneral use, then have them support the same argument lists and exit codes.</p></div><div class="SECT3"><h3 class="SECT3"><a id="PRINTING-ADVANCED-IF-CONVERSION"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -