home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / DOC / HOWTO / OTHER_FO / SGML / PRINTIN1.GZ / Printing-Usage-HOWTO.sgml
Encoding:
SGML Document  |  1996-03-17  |  19.1 KB  |  509 lines

  1. <!--  TODO
  2.     - graphics printing
  3.     - fonts
  4.     - mpage
  5.     - lpc(8)
  6.   -->
  7.  
  8. <!--    The Linux Printing Usage HOWTO
  9.     v1.1 (c) 1995 Matt Foster
  10.         v1.11 (c) 1996 Mark Komarinski
  11.     Last revised 26 Aug 1995
  12.   -->
  13.  
  14. <!doctype linuxdoc system>
  15. <article>
  16. <title>The Linux Printing Usage HOWTO</title>
  17. <author>by Mark Komarinski <markk@auratek.com></author>
  18. <date>v1.11, 2 February 1996
  19.  
  20. <sect>Introduction
  21. <p>
  22. This document describes how to use the line printer spooling system provided
  23. with the Linux operating system.  This HOWTO is the supplementary document
  24. to the Linux Printing Setup HOWTO, which discusses the installation and
  25. setup of the Linux printing system.  The material presented in this HOWTO
  26. should be equally relevent for all flavors of the BSD operating system in
  27. addition to the Linux operating system.
  28.  
  29. <sect1>Linux Printing HOWTO History
  30. <p>
  31. This version of the Linux Printing HOWTO is a complete rewrite of the one
  32. originally written by Grant Taylor <grant@god.tufts.edu> and Brian
  33. McCauley <B.A.McCauley@bham.ac.uk>.  I have tried to keep with the
  34. coverage of material presented by Grant and Brian's HOWTO, but I have
  35. drastically modified the style of presentation and the depth of material
  36. covered.  I feel that this makes the HOWTO more complete and easier to
  37. read.  I can only hope that you agree.
  38.  
  39. <sect1>Version History
  40. <p>
  41. v1.11
  42.   <itemize>
  43.     <item>new maintainter!
  44.     <item>Added lpc info
  45.     <item>Added some info for troubleshooting
  46.     <item>A start on printing graphics files!
  47.   </itemize>
  48.  
  49. v1.1
  50.   <itemize>
  51.     <item>revised some of the wording
  52.     <item>developed section on PostScript printing
  53.     <item>attempted to clarify some of the examples 8-)
  54.     <item>fleshed the discussion of the basic Linux printing utilities
  55.   </itemize>
  56.  
  57. v1.0
  58.   <itemize>
  59.     <item>initial public release of the Printing Usage HOWTO
  60.   </itemize>
  61.  
  62. <sect1>Copyrights and Trademarks
  63. <p>
  64. Some names mentioned in this HOWTO are claimed as copyrights and/or
  65. trademarks of certain persons and/or companies.  These names appear
  66. in full or initial caps in this HOWTO.
  67. <p><p>
  68. <em>The Linux Printing Usage HOWTO v1.11 (c) 1996 Mark Komarinski.</em>
  69. <p><p>
  70. Unless otherwise stated, Linux HOWTO documents are copyrighted by their
  71. respective authors. Linux HOWTO documents may be reproduced and distributed
  72. in whole or in part, in any medium physical or electronic, as long as this
  73. copyright notice is retained on all copies. Commercial redistribution is
  74. allowed and encouraged; however, the author would like to be notified of any
  75. such distributions.
  76.  
  77. <p>
  78. All translations, derivative works, or aggregate works incorporating
  79. any Linux HOWTO documents must be covered under this copyright notice.
  80.  
  81. That is, you may not produce a derivative work from a HOWTO and impose
  82. additional restrictions on its distribution. Exceptions to these rules
  83. may be granted under certain conditions; please contact the Linux HOWTO
  84. coordinator at the address given below.
  85. <p>
  86. In short, we wish to promote dissemination of this information through as
  87. many channels as possible. However, we do wish to retain copyright on the
  88. HOWTO documents, and would like to be notified of any plans to redistribute
  89. the HOWTOs.
  90.  
  91. <p>
  92. If you have questions, please contact Greg Hankins, the Linux HOWTO
  93. coordinator, at <gregh@sunsite.unc.edu>. You may finger this address
  94. for phone number and additional contact information.
  95.  
  96.  
  97. <sect1>Downloading the Linux Printing HOWTOs
  98. <p>
  99. I recommend that if you want to print a copy of this HOWTO that you
  100. download the PostScript version.  It is formatted in a fashion that is
  101. aesthetically appealing and easier to read.  You can get the PostScript
  102. version from one of the many Linux distribution sites (such as SunSITE
  103. <ref id="ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/">).
  104.  
  105. <sect1>Feedback
  106. <p>
  107. Questions, comments, or corrections for this HOWTO may be directed to
  108. <markk@auratek.com>.
  109.  
  110. <sect1>Acknowledgments
  111. <p>
  112. Thanks go out to all of the people who took the time to read the alpha
  113. version of this HOWTO and respond with many helpful comments and
  114. suggestions---some of you may see your comments reflected in the version.
  115. <p>
  116. I would also like to thank Grant and Brian for the loads of information
  117. that they have given me during the transition of authorship.
  118.  
  119. <sect>Printing Under Linux
  120. <p>
  121. This section discusses how to print files, examine the print queue, remove
  122. jobs from the print queue, format files before printing them, and configure
  123. your printing environment.
  124.  
  125. <sect1>History of Linux Printing
  126. <p>
  127. The Linux printing system---the <em>lp</em> system---is a port of the source
  128. code written by the Regents of the University of California for the Berkeley
  129. Software Distribution version of the UNIX operating system.
  130.  
  131. <sect1>Printing a File Using <em>lpr</em>
  132. <p>
  133. By far, the most simplistic way to print in the Linux operating system is
  134. to send the file to be printed directly to the printing device.  One way
  135. to do this is to use the <em>cat</em> command.  As the <tt>root</tt> user,
  136. one could do something like
  137.  
  138. <tscreen><verb>
  139. # cat thesis.txt > /dev/lp
  140. </verb></tscreen>
  141.  
  142. In this case, <tt>/dev/lp</tt> is a symbolic link to the actual printing
  143. device---be it a dot-matrix, laser printer, typesetter, or plotter.  (See
  144. <em>ln</em>(1) for more information on symbolic links.)
  145. <p>
  146. For the purpose of security, only the <tt>root</tt> user and users in the
  147. same group as the print daemon are able to write directly to the printer.
  148. This is why commands such as <em>lpr</em>, <em>lprm</em>, and <em>lpq</em>
  149. have to be used to access the printer.
  150. <p>
  151. Because of this, users have to use <em>lpr</em> to print a file.  The
  152. <em>lpr</em> command takes care of all the initial work needed to print
  153. the file, and then it hands control over to another program, <em>lpd</em>,
  154. the line printing daemon.  The line printing daemon then tells the printer
  155. how to print the file.
  156. <p>
  157. When <em>lpr</em> is executed, it first copies the specified file to a
  158. certain directory (the spool directory) where the file remains until
  159. <em>lpd</em> prints it.  Once <em>lpd</em> is told that there is a file to
  160. print, it will spawn a copy of itself (what we programmers call forking). 
  161. This copy will print our file while the original copy waits for more
  162. requests.  This allows for multiple jobs to be queued at once.
  163. <p>
  164. The syntax of <em>lpr</em>(1) is a very familiar one,
  165.  
  166. <tscreen><verb>
  167. $ lpr [ options ] [ filename ... ]
  168. </verb></tscreen>
  169.  
  170. If <tt>filename</tt> is not specified, <em>lpr</em> expects input to come
  171. from standard input (usually the keyboard, or another program's output). 
  172. This enables the user to redirect a command's output to the print spooler. 
  173. As such,
  174.  
  175. <tscreen><verb>
  176. $ cat thesis.txt | lpr
  177. </verb></tscreen>
  178.  
  179. or,
  180.  
  181. <tscreen><verb>
  182. $ pr -l60 thesis.txt | lpr
  183. </verb></tscreen>
  184.  
  185. The <em>lpr</em> command accepts several command-line arguments that allow a
  186. user to control how it works.  Some of the most widely used arguments are:
  187. -<bf/P/printer specifies the printer to use, -<bf/h/ suppresses printing of
  188. the burst page, -<bf/s/ creates a symbolic link instead of copying the file
  189. to the spool directory (useful for large files), and -<bf/#/num
  190. specifies the number of copies to print.  An example interaction with
  191. <em>lpr</em> might be something like
  192.  
  193. <tscreen><verb>
  194. $ lpr -#2 -sP dj thesis.txt
  195. </verb></tscreen>
  196.  
  197. This command will create a symbolic link to the file <tt>thesis.txt</tt> in
  198. the spool directory for the printer named <em>dj</em>, where it would be
  199. processed by <em>lpd</em>.  It would then print a second copy of
  200. <tt>thesis.txt</tt>.
  201. <p>
  202. For a listing of all the options that <em>lpr</em> will recognize, see
  203. <em>lpr</em>(1).
  204.  
  205. <sect1>Viewing the Print Queue with <em>lpq</em>
  206. <p>
  207. To view the contents of the print queue, use the <em>lpq</em> command. 
  208. Issued without arguments, it returns the contents of the default printer's
  209. queue.
  210. <p>
  211. The returned output of <em>lpq</em> can be useful for many purposes.
  212.  
  213. <tscreen><verb>
  214. $ lpq
  215. lp is ready and printing
  216. Rank   Owner      Job  Files                            Total Size
  217. active mwf      31   thesis.txt            682048 bytes
  218. </verb></tscreen>
  219.  
  220. <sect1>Canceling a Print Job Using <em>lprm</em>
  221. <p>
  222. Another useful feature of any printing system is the ability to cancel a job
  223. that has been previously queued.  To do this, use <em>lprm</em>.
  224.  
  225. <tscreen><verb>
  226. $ lprm -
  227. </verb></tscreen>
  228.  
  229. The above command cancels all of the print jobs that are owned by the user
  230. who issued the command.  A single print job can be canceled by first getting
  231. the job number as reported by <em>lpq</em> and then giving that number to
  232. <em>lprm</em>.  For example,
  233.  
  234. <tscreen><verb>
  235. $ lprm 31
  236. </verb></tscreen>
  237.  
  238. would cancel job 31 (<tt>thesis.txt</tt>) on the default printer.
  239.  
  240. <sect1>Controlling the lpd program with <em>lpc</em>
  241. <p>
  242. The <em>lpc</em>(8) program is used to control the printers that lpd serves. 
  243. you can enable or disable a printer or its queues, rearrange entries within
  244. a queue, and get a status report on the printers and their queues.
  245. Lpc is mostly used in a setup where there are multiple printers hanging off
  246. one machine.
  247.  
  248. <tscreen><verb>
  249. $ lpc
  250. </verb></tscreen>
  251.  
  252. The above will start the lpc program.  By default, this enters you into
  253. an interactive mode, and you can begin issuing commands.  The other option
  254. is to issue an lpc command on the command line.
  255.  
  256. <tscreen><verb>
  257. $ lpc status all
  258. </verb></tscreen>
  259.  
  260. A list of the available commands are in the <em>lpd</em> man page, but here
  261. are a few of the major commands you'll want to know about.  Any commands
  262. marked with <em>option</em> can either be a printer name (lp, print, etc) or
  263. the keyword <tt>all</tt>, which means all printers. 
  264.  
  265. <itemize>
  266.   <item> disable <em>option</em> -  prevents any new printer job from being entered
  267.   <item> down <em>option</em> - disables all printing on the printer
  268.   <item> enable <em>option</em> - allow new jobs to enter the print queue
  269.   <item> quit (or exit) - leave lpc
  270.   <item> restart <em>option</em> - restarts lpd for that printer
  271.   <item> status <em>option</em> - print status of printer
  272.   <item> up <em>option</em> - enable everything and start a new lpd
  273. </itemize>
  274.  
  275. <sect>Miscellaneous Items
  276. <p>
  277. This section discusses some of the miscellaneous things that you may
  278. want to know about printing under Linux.
  279.  
  280. <sect1>Formatting Before Printing
  281. <p>
  282. Since most ASCII files are not formatted for printing, it is useful to
  283. format them in some way before they are actually printed.  This may include
  284. putting a title and page number on each page, setting the margins, double
  285. spacing, indenting, or printing a file in multiple columns.  A common way to
  286. do this is to use a print preprocessor such as <em>pr</em>.
  287.  
  288. <tscreen><verb>
  289. $ pr +4 -d -h"Ph.D. Thesis, 2nd Draft" -l60 thesis.txt | lpr
  290. </verb></tscreen>
  291.  
  292. In the above example, <em>pr</em> would take the file <tt>thesis.txt</tt>
  293. and skip the first three pages (+4), set the page length to sixty lines
  294. (-l60), double space the output (-d), and add the phrase "Ph.D. Thesis, 2nd
  295. Draft" to the top of each page (-h).  <em>Lpr</em> would then queue
  296. <em>pr</em>'s output.  See its on-line manual page for more information on
  297. using <em>pr</em>.
  298.  
  299. <sect1>The PRINTER Environment Variables
  300. <p>
  301. All of the commands in the Linux printing system accept the -<bf/P/ option.
  302. This option allows the user to specify which printer to use for output.  If
  303. a user doesn't specify which printer to use, then the default printer will
  304. be assumed as the output device.
  305. <p>
  306. Instead of having to specify a printer to use every time that you print, you
  307. can set the PRINTER environment variable to the name of the printer that you
  308. want to use.  This is accomplished in different ways for each shell.  For
  309. <em>bash</em> you can do this with
  310.  
  311. <tscreen><verb>
  312. $ PRINTER="printer_name"; export PRINTER
  313. </verb></tscreen>
  314.  
  315. and <em>csh</em>, you can do it with
  316.  
  317. <tscreen><verb>
  318. % setenv PRINTER "printer_name"
  319. </verb></tscreen>
  320.  
  321. These commands can be placed in your login scripts (.profile for <em>bash</em>,
  322. or .cshrc for <em>csh</em>), or issued on the command-line.  (See
  323. <em>bash</em>(1) and <em>csh</em>(1) for more information on environment
  324. variables.)
  325.  
  326. <sect1>Printing graphics files
  327. <p>
  328.  
  329. Printing graphics files through a printer usually depends on the kind of
  330. graphics you're converting, and the kind of printer you want to send to. Dot
  331. matrix is usually out of the question due to differences in the way
  332. dot-matrix handles graphics.  Your best bet in this situation is to see if
  333. your printer is compatable with an Epson or an IBM ProPrinter, then convert
  334. the graphics file to PostScript, then use Ghostscript (see next section) to
  335. print the graphics.
  336. <p>
  337. If you have a laser printer, things are a bit easier since many are
  338. compatable with PCL.  This now gives you a few options.  Some programs may
  339. output directly in PCL.  If not, programs like <em>NetPBM</em> can convert
  340. into PCL.  Last option is to use ghostscript (see next section).
  341. <p>
  342. Your absolutely best option is to install packages like NetPBM and Ghostscript
  343. then installing a magic filter to process the graphics files automagically.
  344.  
  345. <sect1>Printing PostScript files
  346. <p>
  347. Printing PostScript files on a printer that has a PostScript interpreter
  348. is simple; just use <em>lpr</em>, and the printer will take care of all
  349. of the details for you.  For those of us that don't have printers with
  350. PostScript capabilities, we have to resort to other means.  Luckily, there
  351. are programs available that can make sense of PostScript, and translate
  352. it into a language that most printers will understand.  Probably the most
  353. well known of these programs is Ghostscript.
  354. <p>
  355. Ghostscript's responsibility is to convert all of the descriptions in a
  356. PostScript file to commands that the printer will understand.  To print
  357. a PostScript file using Ghostscript, you might do something like
  358.  
  359. <tscreen><verb>
  360. $ gs -dSAFER -dNOPAUSE -sDEVICE=deskjet -sOutputFile=|lpr thesis.ps
  361. </verb></tscreen>
  362.  
  363. Notice in the above example that we are actually piping the output of
  364. Ghostscript to the <em>lpr</em> command by using the -<bf/sOutputFile/
  365. option.
  366.  
  367. Ghostview is an interface to Ghostscript for the X Window System.  It allows
  368. you to preview a PostScript file before you print it.  Ghostview and
  369. Ghostscript can both be swiped from <ref
  370. id="ftp://prep.ai.mit.edu/pub/gnu/">.
  371.  
  372. <sect1>Printing TeX files
  373. <p>
  374. One of the easiest ways to print TeX files is to convert them to PostScript
  375. and then print them using Ghostscript.  To do this, you first need to
  376. convert them from TeX to a format known as DVI (which stands for
  377. device-independent). You can do this with the <em>tex</em>(1) command.  Then
  378. you need to convert the DVI file to a PostScript file using <em>dvips</em>. 
  379. All of this would look like the following when typed in.
  380.  
  381. <tscreen><verb>
  382. $ tex thesis.tex
  383. $ dvips thesis.dvi
  384. </verb></tscreen>
  385.  
  386. Now you are ready to print the resulting PostScript file as described above.
  387.  
  388. <sect1>Printing <tt>troff</tt> formatted files
  389. <p>
  390.  
  391. <tscreen><verb>
  392. $ groff -Tascii thesis.tr | lpr
  393. </verb></tscreen>
  394.  
  395. or, if you prefer,
  396.  
  397. <tscreen><verb>
  398. $ groff thesis.tr > thesis.ps
  399. </verb></tscreen>
  400.  
  401. and then print the PostScript file as described above.
  402.  
  403. <sect>Answers to Frequently Asked Questions
  404. <p><p>
  405. Q1.  How do I prevent the staircase effect?
  406. <p>
  407. A1.  The staircase effect is caused by the way some printers expect lines to
  408. be terminated.  Some printers want lines that end with a
  409. carriage-return/line-feed sequence (DOS-style) instead of the line-feed
  410. sequence used for UNIX-type systems.  The easiest way to fix this is to see
  411. if your printer can switch between the two styles somehow---either by
  412. flipping a DIP switch, or by sending an escape sequence at the start of each
  413. print job.  To do the latter, you need to create a filter (see Q2 and
  414. [Foster95b]).
  415.  
  416. A quick fix is to use a filter on the command-line.  An example of this
  417. might be
  418.  
  419. <tscreen><verb>
  420. $ cat thesis.txt | todos | lpr
  421. </verb></tscreen>
  422.  
  423. <p>
  424. Q2.  What is a filter?
  425. <p>
  426. A2.  A filter is a program that reads from standard input (<em>stdin</em>),
  427. performs some action on this input, and writes to standard output
  428. (<em>stdout</em>).  Filters are used for a lot of things, including text
  429. processing.
  430. <p><p>
  431. Q3.  What is a <em>magic</em> filter?
  432. <p>
  433. A3.  A magic filter is a filter that performs an action based on a file's
  434. type.  For example, if the file is a plain, text file, it would simply print
  435. the file using the normal methods.  If the file is a PostScript file, or any
  436. other format, it would print it using another method (ghostscript).  Two
  437. examples of this is magicfilter and APSfilter.  One caveat of these filters
  438. is that the appropriate programs have to be installed before you install
  439. the filter.
  440.  
  441. <sect>Troubleshooting
  442. <p>
  443. This section covers some common things that can go wrong with your printing
  444. system.
  445. <p>
  446. If your printer doesn't work:
  447. <itemize>
  448.    <item>Do other print jobs work? (application)
  449.    <item>Is lpd running? (check it using lpc) (print controller)
  450.    <item>Can root send something directly to the printer? (print services)
  451.    <item>Can you print from DOS? (cable/printer problem?)
  452. </itemize>
  453. Answering these questions can help find a solution.
  454.  
  455. Send other suggestions for this section to <markk@auratek.com>.
  456.  
  457. <sect>References
  458. <p>
  459. This is a section of references on the Linux printing system.  I have
  460. tried to keep the references section of this HOWTO as focused as
  461. possible.  If you feel that I have forgotten a significant reference
  462. work, please do not hesitate to contact me.
  463. <p>
  464. Before you post your question to a USENET group, consider the following:
  465. <itemize>
  466.   <item>Is the printer accepting jobs?  (Use <em>lpc</em>(8) to verify.)
  467.   <item>Is the answer to your question covered in this HOWTO, or the Printing
  468. Setup HOWTO?
  469. </itemize>
  470. <p>
  471. If any of the above are true, you may want to think twice before you post
  472. your question.  And, when you do finally post to a newsgroup, try to include
  473. pertinent information.  Try not to just say something like, "I'm having
  474. trouble with lpr, please help." These types of posts will most definitely be
  475. ignored by many.  Also try to include the kernel version that you're
  476. running, how the error occured, and, if any, the specific error message that
  477. the system returned.
  478.  
  479. <descrip>
  480. <tag>Foster, Matt.  <em>Linux Printing Setup HOWTO</em></tag> the supplement
  481. to this HOWTO; covers setting up, and configuring the print software
  482. <p>
  483. <tag>Welsh, Matt.  <em>Linux Installation and Getting Started</em></tag> an
  484. excellent introductory text for the beginning Linux user
  485. <p>
  486. <tag>On-Line Manual Pages</tag>
  487.   <itemize>
  488.     <item><em>cat</em>(1)  concatenate and print files
  489.     <item><em>dvips</em>(1)  convert a TeX DVI file to PostScript
  490.     <item><em>ghostview</em>(1)  view PostScript documents using Ghostscript
  491.     <item><em>groff</em>(1)  front-end for the groff document formatting system
  492.     <item><em>gs</em>(1)  Ghostscript interpreter/viewer
  493.     <item><em>lpc</em>(8)  line printer control program
  494.     <item><em>lpd</em>(8)  line printer spooler daemon
  495.     <item><em>lpq</em>(1)  spool queue examination program
  496.     <item><em>lpr</em>(1)  off-line printer
  497.     <item><em>lprm</em>(1)  remove jobs from the line printer spooling queue
  498.     <item><em>pr</em>(1)  convert text files for printing
  499.     <item><em>tex</em>(1)  text formatting and typesetting
  500.   </itemize>
  501. <p>
  502. <tag>USENET newsgroups</tag>
  503.   <itemize>
  504.     <item><tt>comp.os.linux.*</tt>  a plethora of information on Linux
  505.     <item><tt>comp.unix.*</tt>  discussions relating to the UNIX operating system
  506.   </itemize>
  507. </descrip>
  508. </article>
  509.