From owner-svn-doc-all@FreeBSD.ORG Fri Apr 11 13:48:55 2014 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 80ACE158; Fri, 11 Apr 2014 13:48:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C3301BDF; Fri, 11 Apr 2014 13:48:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3BDmtVi059131; Fri, 11 Apr 2014 13:48:55 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3BDmt6t059130; Fri, 11 Apr 2014 13:48:55 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201404111348.s3BDmt6t059130@svn.freebsd.org> From: Warren Block Date: Fri, 11 Apr 2014 13:48:55 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r44529 - head/en_US.ISO8859-1/books/handbook/printing X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Apr 2014 13:48:55 -0000 Author: wblock Date: Fri Apr 11 13:48:55 2014 New Revision: 44529 URL: http://svnweb.freebsd.org/changeset/doc/44529 Log: A from-scratch rewrite of the Printing chapter, designed to address issues with the old chapter. It adds a quick-start section, simplifies setup, vastly reduces the section on shared printers in schools and businesses, and provides a framework that allows the addition of other printing systems. Reviewed by: freebsd-doc and IRC, no objections Modified: head/en_US.ISO8859-1/books/handbook/printing/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/printing/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/printing/chapter.xml Fri Apr 11 02:10:56 2014 (r44528) +++ head/en_US.ISO8859-1/books/handbook/printing/chapter.xml Fri Apr 11 13:48:55 2014 (r44529) @@ -1,5033 +1,1142 @@ - - Printing - - SeanKellyContributed by - - + + + + Printing + - JimMockRestructured and updated by + + + Warren + Block + Originally contributed by + - + Putting information on paper is a vital function, despite many + attempts to eliminate it. Printing has two basic components. The + data must be delivered to the printer, and must be in a form that + the printer can understand. + + + Quick Start + + Basic printing can be set up quickly. The printer must be + capable of printing plain ASCII text. For + printing to other types of files, see + . + + + + Create a directory to store files while they are being + printed: + + &prompt.root; mkdir -p /var/spool/lpd/lp +&prompt.root; chown daemon:daemon /var/spool/lpd/lp +&prompt.root; chmod 770 /var/spool/lpd/lp + + + + As root, + create /etc/printcap with these + contents: + + lp:\ + :lp=/dev/unlpt0:\ + :sh:\ + :mx#0:\ + :sd=/var/spool/lpd/lp:\ + :lf=/var/log/lpd-errs: + + + + This line is for a printer connected to a + USB port. + + For a printer connected to a parallel or + printer port, use: + + :lp=/dev/lpt0:\ + + For a printer connected directly to a network, + use: + + :lp=:rm=network-printer-name:rp=raw:\ + + Replace + network-printer-name with the + DNS host name of the network + printer. + + + + + + Enable lpd by editing + /etc/rc.conf, adding this line: + + lpd_enable="YES" + + Start the service: + + &prompt.root; service lpd start +Starting lpd. + - - Synopsis + + Print a test: - LPD spooling system - printing + &prompt.root; printf "1. This printer can print.\n2. This is the second line.\n" | lpr + + + If both lines do not start at the left border, but + stairstep instead, see + . + - &os; can be used to print with a wide variety of printers, - from the oldest impact printer to the latest laser printers, - and everything in between, allowing you to produce high-quality - printed output from the applications you run. - - &os; can also be configured to act as a print server on a - network; in this capacity &os; can receive print jobs from a - variety of other computers, including other &os; computers, - &windows; and &macos; hosts. &os; will ensure that one job - at a time is printed, and can keep statistics on which users - and machines are doing the most printing, produce - banner pages showing whose printout is whose, - and more. - - After reading this chapter, you will know: - - - - How to configure the &os; print spooler. - - - - How to install print filters, to handle special print - jobs differently, including converting incoming documents - to print formats that your printers understand. - - - - How to enable header, or banner pages on your - printout. - - - - How to print with printers connected to other - computers. - - - - How to print with printers connected directly to the - network. - - - - How to control printer restrictions, including limiting - the size of print jobs, and preventing certain users from - printing. - - - - How to keep printer statistics, and account for printer - usage. - - - - How to troubleshoot printing problems. - - - - Before reading this chapter, you should: - - - - Know how to configure and install a new kernel - (). - - + Text files can now be printed with + lpr. Give the filename on the command + line, or pipe output directly into + lpr. + + &prompt.user; lpr textfile.txt +&prompt.user; ls -lh | lpr + + - - Introduction + + Printer Connections - In order to use printers with &os; you may set them up to - work with the Berkeley line printer spooling system, also known - as the LPD spooling system, or just - LPD. It is the standard printer - control system in &os;. This chapter introduces - LPD and will guide you through its - configuration. - - If you are already familiar with - LPD or another printer spooling - system, you may wish to skip to section Basic Setup. - - LPD controls everything about - a host's printers. It is responsible for a number of - things: - - - - It controls access to attached printers and printers - attached to other hosts on the network. - - - - It enables users to submit files to be printed; these - submissions are known as jobsprint jobs. - - - - It prevents multiple users from accessing a printer at - the same time by maintaining a queue - for each printer. - - - - It can print header pages (also - known as banner or - burst pages) so users can easily find - jobs they have printed in a stack of printouts. - - - - It takes care of communications parameters for printers - connected on serial ports. - - - - It can send jobs over the network to a - LPD spooler on another - host. - - - - It can run special filters to format jobs to be printed - for various printer languages or printer - capabilities. - - - - It can account for printer usage. - - - - Through a configuration file - (/etc/printcap), and by providing the - special filter programs, you can enable the - LPD system to do all or some subset - of the above for a great variety of printer hardware. + Printers are connected to computer systems in a variety of + ways. Small desktop printers are usually connected directly to + computer's USB port. Older printers are + connected to a parallel or printer port. Some + printers are directly connected to a network, making it easy for + multiple computers share them. A few printers use a much less + common serial port connection. - - Why You Should Use the Spooler + &os; can communicate with all of these types of + printers. - The spooler still provides benefit on a single-user system - and should be used because: + + + USB - - LPD prints jobs in the - background; you do not have to wait for data to be copied - to the printer. + USB printers can be connected to + any available USB port on the + computer. + + When &os; detects a USB printer, + two device entries are created: + /dev/ulpt0 and + /dev/unlpt0. Data sent to either + device will be relayed to the printer. After each print + job, ulpt0 resets the + USBport. Resetting the port can cause + problems with some printers, so the + unlpt0 device is used instead. + unlpt0 does not reset the USB port at + all. + - - LPD can conveniently run - a job to be printed through filters to add date/time - headers or convert a special file format (such as a &tex;&tex; - DVI file) into a format the printer will understand. - You will not have to do these steps manually. - + + Parallel (IEEE-1284) - Many free and commercial programs that provide a print - feature usually expect to talk to the spooler on your - system. By setting up the spooling system, you will more - easily support other software you may later add or already - have. + The parallel port device is + /dev/lpt0. This device appears + whether a printer is attached or not, it is not + autodetected. + + Vendors have largely moved away from these + legacy ports, and many computers no longer + have them. Adapters can be used to connect a parallel + printer to a USB port. With such an + adapter, the printer can be treated as if it were actually + a USB printer. Devices called + print servers can also be used to + connect parallel printers directly to a network. - - - - - - Basic Setup - - To use printers with the LPD - spooling system, you will need to set up both your printer - hardware and the LPD software. This - document describes two levels of setup: - - - - See section Simple - Printer Setup to learn how to connect a printer, - tell LPD how to communicate with - it, and print plain text files to the printer. - - - - See section Advanced - Printer Setup to learn how to print a variety of - special file formats, to print header pages, to print across - a network, to control access to printers, and to do printer - accounting. - - - - - Simple Printer Setup - - This section tells how to configure printer hardware - and the LPD software to use the - printer. It teaches the basics: + - - - Section Hardware - Setup gives some hints on connecting the printer - to a port on your computer. - + + Serial (RS-232) - Section Software - Setup shows how to set up the - LPD spooler configuration - file (/etc/printcap). + Serial ports are another legacy port, rarely used for + printers except in certain niche applications. Cables, + connectors, and required wiring vary widely. + + For serial ports built into a motherboard, the serial + device name is /dev/cuau0 or + /dev/cuau1. Serial + USB adapters can also be used, and + these will appear as + /dev/cuaU0. + + Several communication parameters must be known to + communicate with a serial printer. The most important are + baud rate and + parity. Values vary, but typical + serial printers often use a baud rate of 9600 and no + parity. - - - If you are setting up a printer that uses a network - protocol to accept data to print instead of a computer's local - interfaces, see Printers With - Networked Data Stream Interfaces. - - Although this section is called Simple Printer - Setup, it is actually fairly complex. Getting the - printer to work with your computer and the - LPD spooler is the hardest part. - The advanced options like header pages and accounting are - fairly easy once you get the printer working. - - - Hardware Setup - - This section tells about the various ways you can - connect a printer to your PC. It talks about the kinds of - ports and cables, and also the kernel configuration you may - need to enable &os; to speak to the printer. - - If you have already connected your printer and have - successfully printed with it under another operating system, - you can probably skip to section Software Setup. - - - Ports and Cables - - Printers sold for use on PC's today generally come - with one or more of the following three interfaces: - - - - Serialprintersserial interfaces, also known - as RS-232 or COM ports, use a serial port - on your computer to send data to the printer. Serial - interfaces are common in the computer industry and - cables are readily available and also easy to - construct. Serial interfaces sometimes need special - cables and might require you to configure somewhat - complex communications options. Most PC serial ports - have a maximum transmission rate of 115200 bps, - which makes printing large graphic print jobs with - them impractical. - - - - Parallelprintersparallel interfaces use a - parallel port on your computer to send data to the - printer. Parallel interfaces are common in the PC - market and are faster than RS-232 serial. Cables are - readily available but more difficult to construct by - hand. There are usually no communications options - with parallel interfaces, making their configuration - exceedingly simple. - - Parallel interfaces are sometimes known as - Centronicscentronicsparallel printers interfaces, named after the - connector type on the printer. - - - - USBprintersUSB interfaces, named for the Universal Serial - Bus, can run at even faster speeds than parallel or - RS-232 serial interfaces. Cables are simple and - cheap. USB is superior to RS-232 Serial and to - Parallel for printing, but it is not as well supported - under &unix; systems. A way to avoid this problem is - to purchase a printer that has both a USB interface - and a Parallel interface, as many printers do. - - - - In general, Parallel interfaces usually offer just - one-way communication (computer to printer) while serial - and USB gives you two-way. Newer parallel ports (EPP and - ECP) and printers can communicate in both directions under - &os; when a IEEE-1284-compliant cable is used. - - PostScript - - Two-way communication to the printer over a parallel - port is generally done in one of two ways. The first - method uses a custom-built printer driver for &os; that - speaks the proprietary language used by the printer. This - is common with inkjet printers and can be used for - reporting ink levels and other status information. The - second method is used when the printer supports - &postscript;. - - &postscript; jobs are actually programs sent to the - printer; they need not produce paper at all and may return - results directly to the computer. &postscript; also uses - two-way communication to tell the computer about problems, - such as errors in the &postscript; program or paper jams. - Your users may be appreciative of such information. - Furthermore, the best way to do effective accounting with - a &postscript; printer requires two-way communication: - you ask the printer for its page count (how many pages - it has printed in its lifetime), then send the user's job, - then ask again for its page count. Subtract the two - values and you know how much paper to charge to the - user. - - - - Parallel Ports - - To hook up a printer using a parallel interface, - connect the Centronics cable between the printer and the - computer. The instructions that came with the printer, - the computer, or both should give you complete - guidance. - - Remember which parallel port you used on the computer. - The first parallel port is - ppc0 to &os;; - the second is ppc1, and so on. The - printer device name uses the same scheme: - /dev/lpt0 for - the printer on the first parallel ports etc. - - - - Serial Ports - - To hook up a printer using a serial interface, connect - the proper serial cable between the printer and the - computer. The instructions that came with the printer, - the computer, or both should give you complete - guidance. - - If you are unsure what the proper serial - cable is, you may wish to try one of the - following alternatives: - - - - A modem cable connects each - pin of the connector on one end of the cable straight - through to its corresponding pin of the connector on - the other end. This type of cable is also known as a - DTE-to-DCE cable. - - - - A null-modem cablenull-modem cable connects - some pins straight through, swaps others (send data to - receive data, for example), and shorts some internally - in each connector hood. This type of cable is also - known as a DTE-to-DTE cable. - - - - A serial printer cable, - required for some unusual printers, is like the - null-modem cable, but sends some signals to their - counterparts instead of being internally - shorted. - - - - baud rate - parity - flow control - protocol - You should also set up the communications parameters - for the printer, usually through front-panel controls or - DIP switches on the printer. Choose the highest - bps (bits per second, sometimes - baud rate) that both your computer - and the printer can support. Choose 7 or 8 data bits; - none, even, or odd parity; and 1 or 2 stop bits. Also - choose a flow control protocol: either none, or XON/XOFF - (also known as in-band or - software) flow control. Remember these - settings for the software configuration that - follows. - - - - - Software Setup - - This section describes the software setup necessary - to print with the LPD spooling - system in &os;. - - Here is an outline of the steps involved: - - - - Configure your kernel, if necessary, for the port - you are using for the printer; section Kernel Configuration - tells you what you need to do. - - - - Set the communications mode for the parallel port, - if you are using a parallel port; section Setting the - Communication Mode for the Parallel Port gives - details. - - - - Test if the operating system can send data to the - printer. Section Checking Printer - Communications gives some suggestions on how to - do this. - - - - Set up LPD for the - printer by modifying the file - /etc/printcap. You will find out - how to do this later in this chapter. - - - - - Kernel Configuration - - The operating system kernel is compiled to work with - a specific set of devices. The serial or parallel - interface for your printer is a part of that set. - Therefore, it might be necessary to add support for an - additional serial or parallel port if your kernel is not - already configured for one. - - To find out if the kernel you are currently using - supports a serial interface, type: - - &prompt.root; grep sioN /var/run/dmesg.boot - - Where N is the number of - the serial port, starting from zero. If you see output - similar to the following: - - sio2 at port 0x3e8-0x3ef irq 5 on isa -sio2: type 16550A - - then the kernel supports the port. - - To find out if the kernel supports a parallel - interface, type: - - &prompt.root; grep ppcN /var/run/dmesg.boot - - Where N is the number of - the parallel port, starting from zero. If you see output - similar to the following: - - ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0 -ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode -ppc0: FIFO with 16/16/8 bytes threshold - - then the kernel supports the port. - - You might have to reconfigure your kernel in order - for the operating system to recognize and use the parallel - or serial port you are using for the printer. - - To add support for a serial port, see the section on - kernel configuration. To add support for a parallel port, - see that section and the section that - follows. - - - - - Setting the Communication Mode for the Parallel - Port - - When you are using the parallel interface, you can - choose whether &os; should use interrupt-driven or polled - communication with the printer. The generic printer - device driver (&man.lpt.4;) on &os; - uses the &man.ppbus.4; system, which controls the port - chipset with the &man.ppc.4; driver. - - - - The interrupt-driven method - is the default with the GENERIC kernel. With this - method, the operating system uses an IRQ line to - determine when the printer is ready for data. - - - - The polled method directs the - operating system to repeatedly ask the printer if it is - ready for more data. When it responds ready, the kernel - sends more data. - - - - The interrupt-driven method is usually somewhat faster - but uses up a precious IRQ line. Some newer HP printers - are claimed not to work correctly in interrupt mode, - apparently due to some (not yet exactly understood) timing - problem. These printers need polled mode. You should use - whichever one works. Some printers will work in both - modes, but are painfully slow in interrupt mode. - - You can set the communications mode in two ways: by - configuring the kernel or by using the &man.lptcontrol.8; - program. - - To set the communications mode by configuring - the kernel: - - - - Edit your kernel configuration file. Look for - an ppc0 entry. If you are setting up - the second parallel port, use ppc1 - instead. Use ppc2 for the third - port, and so on. - - - - If you want interrupt-driven mode, edit the - following line: - - hint.ppc.0.irq="N" - - in the /boot/device.hints - file and replace N with - the right IRQ number. The kernel configuration file - must also contain the &man.ppc.4; driver: - - device ppc - - - - If you want polled mode, remove in your - /boot/device.hints file, the - following line: - - hint.ppc.0.irq="N" - - In some cases, this is not enough to put the - port in polled mode under &os;. Most of - time it comes from &man.acpi.4; driver, this latter - is able to probe and attach devices, and therefore, - control the access mode to the printer port. You - should check your &man.acpi.4; configuration to - correct this problem. - - - - - - Save the file. Then configure, build, and install - the kernel, then reboot. See kernel configuration - for more details. - - - - To set the communications mode with - &man.lptcontrol.8;: - - - - Type: - - &prompt.root; lptcontrol -i -d /dev/lptN - - to set interrupt-driven mode for - lptN. - - - - Type: - - &prompt.root; lptcontrol -p -d /dev/lptN - - to set polled-mode for - lptN. - - - - You could put these commands in your - /etc/rc.local file to set the mode each - time your system boots. See &man.lptcontrol.8; for more - information. - - - - Checking Printer Communications - - Before proceeding to configure the spooling system, you - should make sure the operating system can successfully send - data to your printer. It is a lot easier to debug printer - communication and the spooling system separately. - - To test the printer, we will send some text to it. For - printers that can immediately print characters sent to them, - the program &man.lptest.1; is perfect: it generates all 96 - printable ASCII characters in 96 lines. - - PostScript - For a &postscript; (or other language-based) printer, we - will need a more sophisticated test. A small &postscript; - program, such as the following, will suffice: - - %!PS -100 100 moveto 300 300 lineto stroke -310 310 moveto /Helvetica findfont 12 scalefont setfont -(Is this thing working?) show -showpage - - The above &postscript; code can be placed into a file - and used as shown in the examples appearing in the following - sections. - - PCL - - When this document refers to a printer language, it - is assuming a language like &postscript;, and not Hewlett - Packard's PCL. Although PCL has great functionality, you - can intermingle plain text with its escape sequences. - &postscript; cannot directly print plain text, and that - is the kind of printer language for which we must make - special accommodations. - - - - Checking a Parallel Printer - - This section tells you how to check if &os; can - communicate with a printer connected to a parallelprintersparallel - port. - - To test a printer on a parallel - port: - - - - Become root with - &man.su.1;. - - - - Send data to the printer. - - - - If the printer can print plain text, then use - &man.lptest.1;. Type: - - &prompt.root; lptest > /dev/lptN - - Where N is the - number of the parallel port, starting from - zero. - - - - If the printer understands &postscript; or - other printer language, then send a small program - to the printer. Type: - - &prompt.root; cat > /dev/lptN - - Then, line by line, type the program - carefully as you cannot edit - a line once you have pressed - RETURN or - ENTER. When you have finished - entering the program, press - CONTROL+D, or whatever your - end of file key is. - - Alternatively, you can put the program in a - file and type: - - &prompt.root; cat file > /dev/lptN - - Where file is the - name of the file containing the program you want - to send to the printer. - - - - - - You should see something print. Do not worry if the - text does not look right; we will fix such things - later. - - - - Checking a Serial Printer - - - printers - serial - - This section tells you how to check if &os; can - communicate with a printer on a serial port. - - To test a printer on a serial - port: - - - - Become root with - &man.su.1;. - - - - Edit the file /etc/remote. - Add the following entry: - - printer:dv=/dev/port:br#bps-rate:pa=parity - - bits-per-second - serial port - parity - Where port is the - device entry for the serial port - (ttyu0, ttyu1, - etc.), bps-rate is the - bits-per-second rate at which the printer - communicates, and parity - is the parity required by the printer (either - even, odd, - none, or - zero). - - Here is a sample entry for a printer connected via - a serial line to the third serial port at - 19200 bps with no parity: - - printer:dv=/dev/ttyu2:br#19200:pa=none - - - - Connect to the printer with &man.tip.1;. - Type: - - &prompt.root; tip printer - - If this step does not work, edit the file - /etc/remote again and try using - /dev/cuaaN - instead of - /dev/ttyuN. - - - - Send data to the printer. - - - - If the printer can print plain text, then use - &man.lptest.1;. Type: - - &prompt.user; $lptest - - - - If the printer understands &postscript; or - other printer language, then send a small program - to the printer. Type the program, line by line, - very carefully as backspacing - or other editing keys may be significant to the - printer. You may also need to type a special - end-of-file key for the printer so it knows it - received the whole program. For &postscript; - printers, press - CONTROL+D. - - Alternatively, you can put the program in a - file and type: - - &prompt.user; >file - - Where file is the - name of the file containing the program. After - &man.tip.1; sends the file, press any required - end-of-file key. - - - - - *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***