home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / PRINTING.000 < prev    next >
Text File  |  1999-11-04  |  52KB  |  1,519 lines

  1.   The Linux Printing HOWTO
  2.   Grant Taylor <gtaylor+pht@picante.com>
  3.   v3.17, 6 June 1998
  4.  
  5.   This is the Linux Printing HOWTO, a collection of information on how
  6.   to generate, preview, print and fax anything under Linux (and other
  7.   Unices in general).
  8.   ______________________________________________________________________
  9.  
  10.   Table of Contents
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   1. Introduction
  68.  
  69.      1.1 History
  70.      1.2 Copyright
  71.  
  72.   2. How to print
  73.  
  74.   3. Kernel printer devices
  75.  
  76.      3.1 The lp device
  77.      3.2 The parport device (kernels >= 2.1.33)
  78.      3.3 Serial devices
  79.  
  80.   4. Supported Printers
  81.  
  82.      4.1 Printer-specific notes
  83.  
  84.   5. Which spooling software?
  85.  
  86.   6. How it works, basic
  87.  
  88.   7. How to set things up, basic
  89.  
  90.      7.1 Traditional lpd configuration
  91.      7.2 File Permissions
  92.  
  93.   8. Getting Printing Software
  94.  
  95.   9. Vendor Solutions
  96.  
  97.      9.1 Red Hat
  98.      9.2 Other Distributions
  99.  
  100.   10. Ghostscript.
  101.  
  102.      10.1 Invoking Ghostscript
  103.      10.2 Ghostscript output tuning
  104.         10.2.1 Output location and size
  105.         10.2.2 Gamma, dotsizes, etc.
  106.  
  107.   11. How to print to a printer over the network
  108.  
  109.      11.1 To a Unix/lpd host
  110.         11.1.1 With
  111.         11.1.2 With
  112.      11.2 To a Win95, WinNT, LanManager, or Samba printer
  113.      11.3 To a NetWare Printer
  114.      11.4 To an EtherTalk (Apple) printer
  115.      11.5 To an HP or other ethernet printer
  116.         11.5.1 To older HPs
  117.      11.6 Running an
  118.      11.7 From Windows.
  119.      11.8 From an Apple.
  120.      11.9 From Netware.
  121.  
  122.   12. Windows-only printers
  123.  
  124.      12.1 The Ghostscript Windows redirector
  125.      12.2 The pbm2ppa program
  126.  
  127.   13. How to print to a fax machine.
  128.  
  129.      13.1 Using a faxmodem
  130.      13.2 Using the Remote Printing Service
  131.  
  132.   14. How to generate something worth printing.
  133.      14.1 Markup languages
  134.      14.2 WYSIWYG Word Processors
  135.  
  136.   15. On-screen previewing of printable things.
  137.  
  138.      15.1 PostScript
  139.      15.2 TeX dvi
  140.      15.3 Adobe PDF
  141.  
  142.   16. Serial printers under lpd
  143.  
  144.      16.1 Setting up in printcap
  145.      16.2 Older serial printers that drop characters
  146.  
  147.   17. Credits
  148.  
  149.  
  150.  
  151.   ______________________________________________________________________
  152.  
  153.   1.  Introduction
  154.  
  155.   The Printing HOWTO should contain everything you need to know to help
  156.   you set up printing services on your Linux box(en).  As life would
  157.   have it, it's a bit more complicated than in the point-and-click world
  158.   of Microsoft and Apple, but it's also a bit more flexible and
  159.   certainly easier to administer for large LANs.
  160.  
  161.   This document is structured so that most people will only need to read
  162.   the first half or so.  Most of the more obscure and situation-
  163.   dependant information in here is in the last half, and can be easily
  164.   located in the Table of Contents, whereas most of the information
  165.   through section 9 or 10 is probably needed by most people.
  166.  
  167.   Since version 3.x is a complete rewrite, much information from
  168.   previous editions has been lost.  This is by design, as the previous
  169.   HOWTOs were so large as to be 60 typeset pages, and had the narrative
  170.   flow of a dead turtle.  If you do not find the answer here, you are
  171.   encouraged to a) scan the previous version at the Printing HOWTO Home
  172.   Page <http://www.picante.com/~gtaylor/pht/> and b) drop me a note
  173.   saying what ought to be here but isn't.
  174.  
  175.   The Printing HOWTO Home Page <http://www.picante.com/~gtaylor/pht/> is
  176.   a good place to find the latest version; it is also, of course,
  177.   distributed from SunSite (sunsite.unc.edu) and your friendly local LDP
  178.   mirror.
  179.  
  180.  
  181.   1.1.  History
  182.  
  183.   This is the third generation, which is to say the third complete
  184.   rewrite, of the Printing HOWTO.  The history of the PHT may be
  185.   chronicled thusly:
  186.  
  187.   1. I wrote the printing-howto in 1992 in response to too many printing
  188.      questions in comp.os.linux, and posted it.  This predated the HOWTO
  189.      project by a few months and was thus the first FAQlet called a
  190.      `howto'.  This edition was in plain ascii.
  191.  
  192.   2. After joining the HOWTO project, the Printing-HOWTO was merged with
  193.      an Lpd FAQ by Brian McCauley <B.A.McCauley@bham.ac.uk>; we
  194.      continued to co-author the PHT for two years or so.  At some point
  195.      we incorporated the work of Karl Auer <Karl.Auer@anu.edu.au>.  This
  196.      generation of the PHT was in TeXinfo, and available in PS, HTML,
  197.      Ascii, and Info.
  198.  
  199.   3. After letting the PHT rot and decay for over a year, and an
  200.      unsuccessful attempt at getting someone else to maintain it, this
  201.      rewrite happened.  This generation of the PHT is in Linuxdoc-SGML
  202.      (now known as the Sgml-tools package).
  203.  
  204.   1.2.  Copyright
  205.  
  206.   This document is Copyright (c) 1997 by Grant Taylor.  Please copy and
  207.   distribute it widely, but do not modify the text or omit my name.
  208.  
  209.   2.  How to print
  210.  
  211.   If you've already got lpd setup to print to your printer, or your
  212.   system administrator already did so, or your vendor did so for you,
  213.   then all you need to do is learn how to use the lpr command.  The
  214.   Printing Usage HOWTO <http://sunsite.unc.edu/LDP/HOWTO/Printing-Usage-
  215.   HOWTO.html> covers this, and a few other queue manipulation commands
  216.   you should probably know.
  217.  
  218.   If, however, you have a new system or new printer, then you'll have to
  219.   set up printing services one way or another before you can print.
  220.   Read on!
  221.  
  222.  
  223.   3.  Kernel printer devices
  224.  
  225.   3.1.  The lp device
  226.  
  227.   The Linux kernel (<=2.1.32), assuming you have compiled in or loaded
  228.   the lp device (the output of cat /proc/devices should include the
  229.   device lp), provides one or more of /dev/lp0, /dev/lp1, and /dev/lp2.
  230.   These are NOT assigned dynamically, rather, each corresponds to a
  231.   specific hardware I/O address.  This means that your first printer may
  232.   be lp0 or lp1 depending on your hardware.  Just try both.
  233.  
  234.   A few users have reported that their bidirectional lp ports aren't
  235.   detected if they use an older unidirectional printer cable.  Check
  236.   that you've got a decent cable.
  237.  
  238.   One cannot run the plip and lp drivers at the same time on any given
  239.   port.  You can, however, have one or the other driver loaded at any
  240.   given time either manually, or by kerneld with version 2.x (and later
  241.   1.3.x) kernels.  By carefully setting the interrupts and such, you can
  242.   supposedly run plip on one port and lp on the other.  One person did
  243.   so by editing the drivers; I eagerly await a success report of someone
  244.   doing so with only a clever command line.
  245.  
  246.   There is a little utility called tunelp floating about with which you,
  247.   as root, can tune the Linux lp device's interrupt usage, polling rate,
  248.   and other options.
  249.  
  250.   When built in to some 1.3.x and later kernels, the kernel will accept
  251.   an lp= option to set interrupts and io addresses:
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.   When the lp driver is built in to the kernel, you may use the
  266.   LILO/LOADLIN command line to set the port addresses and interrupts
  267.   that the driver will use.
  268.  
  269.   Syntax:      lp=port0[,irq0[,port1[,irq1[,port2[,irq2]]]]]
  270.  
  271.   For example:   lp=0x378,0   or   lp=0x278,5,0x378,7 **
  272.  
  273.   Note that if this feature is used, you must specify *all* the ports
  274.   you want considered, there are no defaults.  You can disable a
  275.   built-in driver with lp=0.
  276.  
  277.  
  278.  
  279.  
  280.   When loaded as a module in version 2 and late-model 1.3.x kernels, it
  281.   is possible to specify io addresses and interrupt lines on the insmod
  282.   command line (or in /etc/conf.modules so as to affect kerneld) using
  283.   the usual syntax.  The parameters are io=port0,port1,port2 and
  284.   irq=irq0,irq1,irq2.  Read ye the man page for insmod for more
  285.   information on this.
  286.  
  287.  
  288.   **For those of you who (like me) can never find the standard port
  289.   numbers when you need them, they are as in the second example above.
  290.   The other port (lp0) is at 0x3bc.  I've no idea what interrupt it
  291.   usually uses.
  292.  
  293.  
  294.   The source code for the Linux parallel port driver is in
  295.   /usr/src/linux/drivers/char/lp.c.
  296.  
  297.  
  298.   3.2.  The parport device (kernels >= 2.1.33)
  299.  
  300.   Beginning with kernel 2.1.33 (and available as a patch for kernel
  301.   2.0.30), the lp device is merely a client of the new parport device.
  302.   The addition of the parport device corrects a number of the problems
  303.   that plague the old lp device driver - it can share the port with
  304.   other drivers, it dynamically assigns available parallel ports to
  305.   device numbers rather than enforcing a fixed correspondence between
  306.   I/O addresses and port numbers, and so forth.
  307.  
  308.   The advent of the parport device has enabled a whole flock of new
  309.   parallel-port drivers for things like Zip drives, Backpack CD-ROMs and
  310.   disks, and so forth.  Some of these are also available in versions for
  311.   kernels 2.0.x; look around on the web.
  312.  
  313.  
  314.   I'll cover the parport driver more completely when I find myself using
  315.   one, but in the meantime you can read the file
  316.   Documentation/parport.txt in your kernel sources, or look at the
  317.   parport web site <http://www.cyberelk.demon.co.uk/parport.html>.
  318.  
  319.  
  320.  
  321.   3.3.  Serial devices
  322.  
  323.   Serial devices are usually called something like /dev/ttyS1 under
  324.   Linux.  The utility stty will allow you to interactively view or set
  325.   the settings for a serial port; setserial will allow you to control a
  326.   few extended attributes and configure IRQs and I/O addresses for non-
  327.   standard ports.  Further discussion of serial ports under Linux may be
  328.   found in the Serial-HOWTO <http://sunsite.unc.edu/mdw/HOWTO/Serial-
  329.   HOWTO.html>.
  330.  
  331.   When using a slow serial printer with flow control, you may find that
  332.   some of your print jobs get truncated.  This may be due to the serial
  333.   port, whose default behavior is to purge any untransmitted characters
  334.   from its buffer 30 seconds after the port device is closed.  The
  335.   buffer can hold up to 4096 characters, and if your printer uses flow
  336.   control and is slow enough that it can't accept all the data from the
  337.   buffer within 30 seconds after printing software has closed the serial
  338.   port, the tail end of the buffer's contents will be lost.  If the
  339.   command cat file > /dev/ttyS2 produces complete printouts for short
  340.   files but truncated ones for longer files, you may have this
  341.   condition.
  342.  
  343.  
  344.   The 30 second interval can be adjusted through the "closing_wait"
  345.   commandline option of setserial (version 2.12 and later).  A machine's
  346.   serial ports are usually initialized by a call to setserial in the
  347.   rc.serial boot file.  The call for the printing serial port can be
  348.   modified to set the closing_wait at the same time as it sets that
  349.   port's other parameters.
  350.  
  351.  
  352.  
  353.   4.  Supported Printers
  354.  
  355.   The Linux kernel mostly supports any printer that you can plug into a
  356.   serial or parallel port, but there are things to look out for, and
  357.   printers that you won't be able to use, even though they can
  358.   (electrically speaking) communicate with Linux.  Primary among these
  359.   incompatible printers are those that rely on the "Windows Printing
  360.   System".  (They're often vaguely labelled "for Windows", or called
  361.   "GDI" printers.)  These printers do not work with Linux.  They haven't
  362.   any "smarts" at all, and rely on the computer CPU to do most of the
  363.   work that has been traditionally done by the printer's CPU.
  364.   Unfortunately, this work can only be done by the vendor-supplied
  365.   drivers, which only run under Windows.  So don't buy one to use with
  366.   Linux.  (Note that if you already have one, there are roundabout ways
  367.   to get Linux to print to one, but they're rather awkward and I've
  368.   never tried it myself.  See Section 12 of this document for more
  369.   discussion of Windows-only printers.)
  370.  
  371.  
  372.   As for what printers do work with Linux, the best choice is to buy a
  373.   printer with native PostScript support.  Nearly all Unix software that
  374.   produces printable output produces it in PostScript, so obviously it'd
  375.   be nice to get a printer that supports PostScript directly.
  376.   Unfortunately, PostScript support is scarce outside the laser printer
  377.   domain, and is sometimes a costly add-on.
  378.  
  379.  
  380.   Failing the (larger) budget necessary to buy a PostScript printer, you
  381.   can use any printer supported by Ghostscript, the free PostScript
  382.   interpreter used in lieu of actual printer PostScript support.  The
  383.   Ghostscript Home Page <http://www.cs.wisc.edu/~ghost/> has a list of
  384.   supported printers and information on the status of new and
  385.   experimental drivers.  Please help improve the Ghostscript printer
  386.   support page by reporting your successes and failures as it asks.
  387.  
  388.  
  389.  
  390.   Adobe now has a new printer language called "PrintGear".  I think it's
  391.   a greatly simplified binary format language with some PostScript
  392.   heritage but no PostScript compatibility.  And I haven't heard of
  393.   Ghostscript supporting it.  But some PrintGear printers seem to
  394.   support another language like PCL, and these printers will work with
  395.   Linux.
  396.  
  397.   4.1.  Printer-specific notes
  398.  
  399.   This section is and will always be incomplete.  But whatever
  400.   information I do put here should always be correct, so here goes:
  401.  
  402.  
  403.      Canon BJ-10ex
  404.         One report suggests that the Canon works much better in Epson LQ
  405.         mode (as set by a dip switch).  Apparently output was
  406.         intermittent or wrong in Canon mode.  OTOH, there is much
  407.         explicit Canon support in Ghostscript, so this might have been a
  408.         fluke.
  409.  
  410.  
  411.      Lexmark
  412.         Lexmark (once part of IBM, I think) makes many printers; many of
  413.         them, however, are Windows-only printers:
  414.  
  415.      ╖  Color Jetprinter 1000
  416.  
  417.      ╖  Color Jetprinter 1020 (non Business Edition)
  418.  
  419.      ╖  Color Jetprinter 2030
  420.  
  421.      ╖  Color Jetprinter 2050
  422.  
  423.      ╖  Color Jetprinter 2070
  424.  
  425.      ╖  Color Jetprinter 7000
  426.  
  427.      ╖  Color Jetprinter 7200
  428.  
  429.      ╖  Winwriter 100
  430.  
  431.      ╖  Winwriter 150c
  432.  
  433.      ╖  Winwriter 200
  434.  
  435.  
  436.  
  437.   5.  Which spooling software?
  438.  
  439.   Until recently, the choice for Linux users was simple - everyone ran
  440.   the same old lpd lifted mostly verbatim out of BSD's Net-2 code.  Even
  441.   today, most vendors ship this software.  But this is beginning to
  442.   change.  SVR4-like systems including Sun's Solaris come with a
  443.   completely different print spooling package, centered around lpsched.
  444.   And there are signs that some Linux vendors will shift to providing
  445.   LPRng, a far less ancient print spooling implementation that is freely
  446.   available.  LPRng is far easier to administer for large installations
  447.   and has a less frightfully haphazard codebase than does stock lpd.  It
  448.   can even honestly claim to be secure - there are no SUID binaries, and
  449.   it supports authentication via PGP or Kerberos.
  450.  
  451.  
  452.   For the moment, even in light of the new options, lpd is probably fine
  453.   for most Linux users.  While it isn't the snazziest system, it works
  454.   fine once set up, and it is well understood and extensively documented
  455.   in third-party Unix books.
  456.  
  457.  
  458.   If you'd like more information on LPRng, check out the LPRng Web Page
  459.   <http://www.astart.com/lprng/LPRng.html>.  Future versions of this
  460.   HOWTO will include information on using both LPRng and regular lpd.
  461.  
  462.  
  463.   6.  How it works, basic
  464.  
  465.  
  466.   In order to get printing working well, you need to understand how the
  467.   lpd system works.
  468.  
  469.   Lpd stands for Line Printer Daemon, and refers in different contexts
  470.   to both the daemon and the whole collection of programs which run
  471.   print spooling.  These are:
  472.  
  473.  
  474.      lpd
  475.         The spooling daemon.  One of these runs to control everything on
  476.         a machine, AND one is run per printer while the printer is
  477.         printing.
  478.  
  479.      lpr
  480.         The user spooling command.  Lpr contacts lpd and injects a new
  481.         print job into the spool.
  482.  
  483.      lpq
  484.         Lists the jobs in a print queue.
  485.  
  486.      lpc
  487.         The Lpd system control command.  With lpc you can stop, start,
  488.         reorder, etc, the print queues.
  489.  
  490.      lprm
  491.         lprm will remove a job from the print spool.
  492.  
  493.   So how does it fit together?  Well, when the system boots, lpd is run.
  494.   It scans the file /etc/printcap to learn which printers it will be
  495.   managing spools for.  Each time someone runs lpr, lpr contacts lpd
  496.   through the named socket /dev/printer, and feeds lpd both the file to
  497.   print and some information about who is printing and how to print it.
  498.   Lpd then prints the file on the appropriate printer in turn.
  499.  
  500.   The lp system was originally designed when most printers were line
  501.   printers - that is, people mostly printed plain ascii.  As it turns
  502.   out, only a little extra scripting is needed to make lpd work quite
  503.   well for today's print jobs, which are often in PostScript, or text,
  504.   or dvi, or...
  505.  
  506.  
  507.   7.  How to set things up, basic
  508.  
  509.   7.1.  Traditional lpd configuration
  510.  
  511.   The minimal setup for lpd rsults in a system that can queue files and
  512.   print them.  It will not pay any attention to wether or not your
  513.   printer will understand them, and will probably not let you produce
  514.   attractive output.  Nevertheless, it is the first step to
  515.   understanding, so read on!
  516.  
  517.   Basically, to add a print queue to lpd, you must add an entry in
  518.   /etc/printcap, and make the new spool directory under /var/spool/lpd.
  519.  
  520.   An entry in /etc/printcap looks like:
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.   # LOCAL djet500
  530.   lp|dj|deskjet:\
  531.           :sd=/var/spool/lpd/dj:\
  532.           :mx#0:\
  533.           :lp=/dev/lp0:\
  534.           :sh:
  535.  
  536.  
  537.  
  538.  
  539.   This defines a spool called lp, dj, or deskjet, spooled in the direc¡
  540.   tory /var/spool/lpd/dj, with no per-job maximum size limit, which
  541.   prints to the device /dev/lp0, and which does not have a banner page
  542.   (with the name of the person who printed, etc) added to the front of
  543.   the print job.
  544.  
  545.   Go now and read the man page for printcap.
  546.  
  547.   The above looks very simple, but there a catch - unless I send in
  548.   files a DeskJet 500 can understand, this DeskJet will print strange
  549.   things.  For example, sending an ordinary Unix text file to a deskjet
  550.   results in literally interpreted newlines, and gets me:
  551.  
  552.  
  553.        This is line one.
  554.                         This is line two.
  555.                                          This is line three.
  556.  
  557.  
  558.  
  559.  
  560.   ad nauseam.  Printing a PostScript file to this spool would get a
  561.   beautiful listing of the PostScript commands, printed out with this
  562.   "staircase effect", but no useful output.
  563.  
  564.   Clearly more is needed, and this is the purpose of filtering.  The
  565.   more observant of you who read the printcap man page might have
  566.   noticed the spool attributes if and of.  Well, if, or the input
  567.   filter, is just what we need here.
  568.  
  569.   If we write a small shell script called filter that adds carriage
  570.   returns before newlines, the staircasing can be eliminated.  So we
  571.   have to add in an if line to our printcap entry above:
  572.  
  573.  
  574.        lp|dj|deskjet:\
  575.                :sd=/var/spool/lpd/dj:\
  576.                :mx#0:\
  577.                :lp=/dev/lp0:\
  578.                :if=/var/spool/lpd/dj/filter:\
  579.                :sh:
  580.  
  581.  
  582.  
  583.  
  584.   A simple filter script might be:
  585.  
  586.  
  587.        #!perl
  588.        # The above line should really have the whole path to perl
  589.        # This script must be executable: chmod 755 filter
  590.        while(<STDIN>){chop $_; print "$_\r\n";};
  591.        # You might also want to end with a form feed: print "\f";
  592.  
  593.  
  594.  
  595.   If we were to do the above, we'd have a spool to which we could print
  596.   regular Unix text files and get meaningful results.  (Yes, there are
  597.   four million better ways to write this filter, but few so illustra¡
  598.   tive.  You are encouraged to do this more efficiently.)
  599.  
  600.   The only remaining problem is that printing plain text is really not
  601.   too hot - surely it would be better to be able to print PostScript and
  602.   other formatted or graphic types of output.  Well, yes, it would, and
  603.   it's easy to do.  The method is simply an extention of the above
  604.   linefeed-fixing filter.  If you write a filter than can accept
  605.   arbitrary file types as input and produce DeskJet-kosher output for
  606.   each case, then you've got a clever print spooler indeed!
  607.  
  608.   Such a filter is called a magic filter.  Don't bother writing one
  609.   yourself unless you print strange things - there are a good many
  610.   written for you already on the net.  APS Filter is among the best, or
  611.   your Linux distribution may have a printer setup tool that makes this
  612.   all really easy.
  613.  
  614.  
  615.   7.2.  File Permissions
  616.  
  617.   By popular demand, I include below a listing of the permissions on
  618.   interesting files on my system.  There are a number of better ways to
  619.   do this, ideally using only SGID binaries and not making everything
  620.   SUID root, but this is how my system came out of the box, and it works
  621.   for me.  (Quite frankly, if your vendor can't even ship a working lpd
  622.   you're in for a rough ride).
  623.  
  624.  
  625.        -r-sr-sr-x   1 root     lp    /usr/bin/lpr*
  626.        -r-sr-sr-x   1 root     lp    /usr/bin/lprm*
  627.        -rwxr--r--   1 root     root  /usr/sbin/lpd*
  628.        -r-xr-sr-x   1 root     lp    /usr/sbin/lpc*
  629.        drwxrwxr-x   4 root     lp    /var/spool/lpd/
  630.        drwxr-xr-x   2 root     lp    /var/spool/lpd/lp/
  631.  
  632.  
  633.  
  634.  
  635.   Lpd must currently be run as root so that it can bind to the low-
  636.   numbered lp service port.  It should probably become UID lp.lp or
  637.   something after binding, but I don't think it does.  Bummer.
  638.  
  639.  
  640.   8.  Getting Printing Software
  641.  
  642.   Many prewritten filter packages (and other printer-related software)
  643.   are available from SunSite
  644.   <ftp://sunsite.unc.edu/pub/Linux/system/printing/>.  Such utilities as
  645.   psutils, a2ps, mpage, dvitodvi, flpr, etc can all be found there.
  646.  
  647.  
  648.   For a while, there were several packages out there all trying to make
  649.   printer configuration easier.  They probably all still exist, but one
  650.   of the best and most up-to-date is Andreas Klemm's APS Filter package,
  651.   which has a menu-driven printcap configurator and handles practically
  652.   any type of input imaginable.  If your vendor doesn't ship a nice
  653.   printer setup tool, APS Filter is the way to go.
  654.  
  655.  
  656.   9.  Vendor Solutions
  657.  
  658.   This section is, by definition, incomplete.  Feel free to send in
  659.   details of your favourite distribution.
  660.  
  661.   9.1.  Red Hat
  662.  
  663.   Red Hat has a GUI printer administration tool (in the control panel)
  664.   which can add remote printers and printers on local devices.  It lets
  665.   you choose a ghostscript-supported printer type and Unix device file
  666.   to print to, then installs a print queue in /etc/printcap and writes a
  667.   short PostScript-and-ascii magic filter based around gs and nenscript.
  668.   This solution works fairly well, and is trivial to setup for common
  669.   cases.
  670.  
  671.  
  672.   9.2.  Other Distributions
  673.  
  674.   Please send me info on what other distributions do!
  675.  
  676.  
  677.   10.  Ghostscript.
  678.  
  679.   Ghostscript is an incredibly significant program for Linux printing.
  680.   Most printing software under Unix generates PostScript, which is
  681.   typically a $100 option on a printer.  Ghostscript, however, is free,
  682.   and will generate the language of your printer from PostScript.  When
  683.   tied in with your lpd input filter, it gives you a virtual PostScript
  684.   printer and simplifies life immensely.
  685.  
  686.   Ghostscript is available in two forms.  The commercial version of
  687.   Ghostscript, called Aladdin Ghostscript, may be used freely for
  688.   personal use but may not be distributed by commercial Linux
  689.   distributions.  It is generally a year or so ahead of the free
  690.   Ghostscript; at the moment, for example, it supports Adobe Acrobat's
  691.   Portable Document Format, while the older Ghostscripts do not.
  692.  
  693.   The free version of Ghostscript is GNU Ghostscript, and is simply an
  694.   aged version of Aladdin ghostscript kindly given to GNU.  (Kudos to
  695.   Aladdin for this arrangement; more software vendors should support
  696.   free software in this way).
  697.  
  698.   Whatever you do with gs, be very sure to run it with the option for
  699.   disabling file access (-dSAFER).  PostScript is a fully functional
  700.   language, and a bad PostScript program could give you quite a
  701.   headache.
  702.  
  703.   Speaking of PDF, Adobe's Portable Document Format is actually little
  704.   more than organized PostScript in a compressed file.  Ghostscript can
  705.   handle PDF input just as it does PostScript.  So you can be the first
  706.   on your block with a PDF-capable printer.
  707.  
  708.   10.1.  Invoking Ghostscript
  709.  
  710.   Typically, ghostscript will be run by whatever magic filter you settle
  711.   upon, but for debugging purposes it's often handy to run it directly.
  712.  
  713.   gs -help will give a brief informative listing of options and
  714.   available drivers (note that this list is the list of drivers compiled
  715.   in, not the master list of all available drivers).
  716.  
  717.   You might run gs for testing purposes like: gs options -q -dSAFER
  718.   -sOutputFile=/dev/lp1 test.ps.
  719.  
  720.  
  721.   10.2.  Ghostscript output tuning
  722.  
  723.   There are a number of things one can do if gs's output is not
  724.   satisfactory (actually, you can do anything you darn well please,
  725.   since you have the source).
  726.  
  727.   10.2.1.  Output location and size
  728.  
  729.   The location, size, and aspect ratio of the image on a page is
  730.   controlled by the printer-specific driver in ghostscript.  If you find
  731.   that your pages are coming out scrunched too short, or too long, or
  732.   too big by a factor of two, you might want to look in your driver's
  733.   source module and adjust whatever parameters jump out at you.
  734.   Unfortunately, each driver is different, so I can't really tell you
  735.   what to adjust, but most of them are reasonably well commented.
  736.  
  737.  
  738.   10.2.2.  Gamma, dotsizes, etc.
  739.  
  740.   Most non-laser printers suffer from the fact that their dots are
  741.   rather large. This results in pictures coming out too dark. If you
  742.   experience this problem you should use your own transfer function.
  743.   Simply create the following file in the ghostscript lib-dir and add
  744.   its name to the gs call just before the actual file. You may need to
  745.   tweak the actual values to fit your printer. Lower values result in a
  746.   brighter print.  Especially if your driver uses a Floyd-Steinberg
  747.   algorithm to rasterize colors, lower values ( 0.2 - 0.15 ) are
  748.   probably a good choice.
  749.  
  750.  
  751.  
  752.        ---8<---- gamma.ps ----8<---
  753.        %!
  754.        %transfer functions for cyan magenta yellow black
  755.        {0.3 exp} {0.3 exp} {0.3 exp} {0.3 exp} setcolortransfer
  756.        ---8<------------------8<---
  757.  
  758.  
  759.  
  760.  
  761.  
  762.   It is also possible to mend printers that have some kind of colour
  763.   fault by tweaking these values. If you do that kind of thing, I
  764.   recommend using the file colorcir.ps, that comes with ghostscript (in
  765.   the examples/ subdir), as a test page.
  766.  
  767.  
  768.   11.  How to print to a printer over the network
  769.  
  770.   One of the features of lpd is that it supports printing over the
  771.   network to printers physically connected to a different machine.  With
  772.   the careful combination of filter scripts and assorted utilities, you
  773.   can make lpr print transparently to printers on all sorts of networks.
  774.  
  775.  
  776.   11.1.  To a Unix/lpd host
  777.  
  778.   To allow remote machines to print to your printer, you must list the
  779.   machines in /etc/hosts.equiv or /etc/hosts.lpd.  (Note that
  780.   hosts.equiv has a host of other effects; be sure you know what you are
  781.   doing if you list any machine there).  You can allow only certain
  782.   users on the other machines to print to your printer by usign the rs
  783.   attribute; read the lpd man page for information on this.
  784.  
  785.  
  786.   11.1.1.  With lpd
  787.  
  788.   To print to another machine, you make an /etc/printcap entry like
  789.   this:
  790.  
  791.  
  792.  
  793.   # REMOTE djet500
  794.   lp|dj|deskjet:\
  795.           :sd=/var/spool/lpd/dj:\
  796.           :rm=machine.out.there.com:\
  797.           :rp=printername:\
  798.           :lp=/dev/null:\
  799.           :sh:
  800.  
  801.  
  802.  
  803.  
  804.   Note that there is still a spool directory on the local machine man¡
  805.   aged by lpd.  If the remote machine is busy or offline, print jobs
  806.   from the local machine wait in the spool area until they can be sent.
  807.  
  808.  
  809.   11.1.2.  With rlpr
  810.  
  811.   You can also use rlpr to send a print job directly to a queue on a
  812.   remote machine without going through the hassle of configuring lpd to
  813.   handle it.  This is mostly useful in situations where you print to a
  814.   variety of printers only occasionally.  From the announcement for
  815.   rlpr:
  816.  
  817.  
  818.   Rlpr uses TCP/IP to send print jobs to lpd servers anywhere on a
  819.   network.
  820.  
  821.  
  822.   Unlike lpr, it *does not* require that the remote printers be
  823.   explicitly known to the machine you wish to print from, (e.g. through
  824.   /etc/printcap) and thus is considerably more flexible and requires
  825.   less administration.
  826.  
  827.  
  828.   rlpr can be used anywhere a traditional lpr might be used, and is
  829.   backwards compatible with traditional BSD lpr.
  830.  
  831.  
  832.   The main power gained by rlpr is the power to print remotely *from
  833.   anywhere to anywhere* without regard for how the system you wish to
  834.   print from was configured.  Can work as a filter just like traditional
  835.   lpr so that clients executing on a remote machine like netscape,
  836.   xemacs, etc, etc can print to your local machine with little effort.
  837.  
  838.  
  839.   Rlpr is available from SunSite
  840.   <ftp://sunsite.unc.edu/pub/Linux/system/printing/>.
  841.  
  842.  
  843.   11.2.  To a Win95, WinNT, LanManager, or Samba printer
  844.  
  845.   There is a Printing to Windows mini-HOWTO out there which has more
  846.   info than there is here.
  847.  
  848.   It is possible to direct an lpd queue through the smbclient program
  849.   (part of the samba suite) to a TCP/IP based SMB print service.  Samba
  850.   includes a script to do this called smbprint.  In short, you put a
  851.   configuration file for the specific printer in question in the spool
  852.   directory, and install the smbprint script as the if.
  853.  
  854.   The /etc/printcap entry goes like this:
  855.  
  856.  
  857.  
  858.  
  859.   lp|remote-smbprinter:\
  860.       :lp=/dev/null:sh:\
  861.       :sd=/var/spool/lpd/lp:\
  862.       :if=/usr/local/sbin/smbprint:
  863.  
  864.  
  865.  
  866.  
  867.   You should read the documentation inside the smbprint script for more
  868.   information on how to set this up.
  869.  
  870.   You can also use smbclient to submit a file directly to an SMB
  871.   printing service without involving lpd.  See the man page.
  872.  
  873.  
  874.   11.3.  To a NetWare Printer
  875.  
  876.   The ncpfs suite includes a utility called nprint which provides the
  877.   same functionality as smbprint but for NetWare.  You can get ncpfs
  878.   from SunSite.  From the LSM entry for version 0.16:
  879.  
  880.  
  881.        With ncpfs you can mount volumes of your netware server
  882.        under Linux. You can also print to netware print queues and
  883.        spool netware print queues to the Linux printing system. You
  884.        need kernel 1.2.x or 1.3.54 and above. ncpfs does NOT work
  885.        with any 1.3.x kernel below 1.3.54.
  886.  
  887.  
  888.  
  889.   To make nprint work via lpd, you write a little shell script to print
  890.   stdin on the NetWare printer, and install that as the if for an lpd
  891.   print queue.  You'll get something like:
  892.  
  893.  
  894.        sub2|remote-NWprinter:\
  895.                :lp=/dev/null:sh:\
  896.                :sd=/var/spool/lpd/sub2:\
  897.                :if=/var/spool/lpd/nprint-script:
  898.  
  899.  
  900.  
  901.  
  902.   The nprint-script might look approximately like:
  903.  
  904.  
  905.        #! /bin/sh
  906.        # You should try the guest account with no password first!
  907.        /usr/local/bin/nprint -S net -U name -P passwd -q printq-name -
  908.  
  909.  
  910.  
  911.  
  912.  
  913.   11.4.  To an EtherTalk (Apple) printer
  914.  
  915.   The netatalk package includes something like nprint and smbclient.
  916.   Others have documented the procedure for printing to and from an Apple
  917.   network far better than I ever will; see the Linux Netatalk-HOWTO
  918.   <http://thehamptons.com/anders/netatalk/>.
  919.  
  920.  
  921.   11.5.  To an HP or other ethernet printer
  922.  
  923.   HPs and some other printers come with an ethernet interface which you
  924.   can print to directly using lpd.  You should follow the instructions
  925.   that came with your printer or its network adaptor, but in general,
  926.   such printers are "running" lpd, and provide one or more queues which
  927.   you can print to.  An HP, for example, might work with a printcap
  928.   like:
  929.  
  930.  
  931.        lj-5|remote-hplj:\
  932.                :lp=/dev/null:sh:\
  933.                :sd=/var/spool/lpd/lj-5:\
  934.                :rm=printer.name.com:rp=raw:
  935.  
  936.  
  937.  
  938.  
  939.   HP Laserjet printers with Jet Direct interfaces generally support two
  940.   built in lpd queues - "raw" which accepts PCL (and possibly
  941.   Postscript) and "text" which accepts straight ascii (and copes
  942.   automatically with the staircase effect).  If you've got a JetDirect
  943.   Plus3 three-port box, the queues are named "raw1", "text2", and so
  944.   forth.
  945.  
  946.   In a large scale environment, especially a large environment where
  947.   some printers do not support PostScript, it may be useful to establish
  948.   a dedicated print server to which all machines print and on which all
  949.   ghostscript jobs are run.
  950.  
  951.   This also allows your Linux box to act as a spool server for the
  952.   printer so that your network users can complete their print jobs
  953.   quickly and get on with things without waiting for the printer to
  954.   print any other job that someone else has sent.
  955.  
  956.   To do this, set up a queue on your linux box that points at the
  957.   ethernet equipped HP LJ (as above). Now set up all the clients on your
  958.   LAN to point at the Linux queue (eg lj-5 in the example above).
  959.  
  960.   Some HP network printers apparently don't heed the banner page setting
  961.   sent by clients; you can turn off their internally generated banner
  962.   page by telnetting to the printer, hitting return twice, typing
  963.   "banner: 0" followed by "quit".  There are other settings you can
  964.   change this way, as well; type "?" to see a list.
  965.  
  966.  
  967.   11.5.1.  To older HPs
  968.  
  969.   Some printers (and printer networking "black boxes") support only a
  970.   cheesy little non-protocol involving plain TCP connections.  Notable
  971.   in this category are early-model JetDirect (including some
  972.   JetDirectEx) cards.  Basically, to print to the printer, you must open
  973.   a TCP connection to the printer on a specified port (typically 9100,
  974.   or 9100, 9101 and 9102 for three-port boxes) and stuff your print job
  975.   into it.  This can be implemented, among other ways, in Perl:
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.   #!/usr/bin/perl
  992.   # Thanks to Dan McLaughlin for writing the original version of this
  993.   # script (And to Jim W. Jones for sitting next to Dan when writing me
  994.   # for help ;)
  995.  
  996.   $fileName = @ARGV[0];
  997.  
  998.   open(IN,"$fileName") || die "Can't open file $fileName";
  999.  
  1000.   $dpi300     = "\x1B*t300R";
  1001.   $dosCr      = "\x1B&k3G";
  1002.   $ends = "\x0A";
  1003.  
  1004.   $port =  9100 unless $port;
  1005.   $them = "bach.sr.hp.com" unless $them;
  1006.  
  1007.   $AF_INET = 2;
  1008.   $SOCK_STREAM = 1;
  1009.   $SIG{'INT'} = 'dokill';
  1010.   $sockaddr = 'S n a4 x8';
  1011.  
  1012.   chop($hostname = `hostname`);
  1013.   ($name,$aliases,$proto) = getprotobyname('tcp');
  1014.   ($name,$aliases,$port) = getservbyname($port,'tcp')
  1015.       unless $port =~ /^\d+$/;;
  1016.   ($name,$aliases,$type,$len,$thisaddr) =
  1017.           gethostbyname($hostname);
  1018.   ($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
  1019.   $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
  1020.   $that = pack($sockaddr, $AF_INET, $port, $thataddr);
  1021.  
  1022.   if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {
  1023.   #    print "socket ok\n";
  1024.   }
  1025.   else {
  1026.       die $!;
  1027.   }
  1028.   # Give the socket an address.
  1029.   if (bind(S, $this)) {
  1030.   #    print "bind ok\n";
  1031.   }
  1032.   else {
  1033.       die $!;
  1034.   }
  1035.  
  1036.   # Call up the server.
  1037.  
  1038.   if (connect(S,$that)) {
  1039.   #    print "connect ok\n";
  1040.   }
  1041.   else {
  1042.       die $!;
  1043.   }
  1044.  
  1045.   # Set socket to be command buffered.
  1046.  
  1047.   select(S); $| = 1; select(STDOUT);
  1048.  
  1049.   #    print S "@PJL ECHO Hi $hostname! $ends";
  1050.   #    print S "@PJL OPMSG DISPLAY=\"Job $whoami\" $ends";
  1051.   #    print S $dpi300;
  1052.  
  1053.   # Avoid deadlock by forking.
  1054.  
  1055.   if($child = fork) {
  1056.       print S $dosCr;
  1057.       print S $TimesNewR;
  1058.  
  1059.       while (<IN>) {
  1060.           print S;
  1061.       }
  1062.       sleep 3;
  1063.       do dokill();
  1064.   } else {
  1065.       while(<S>) {
  1066.           print;
  1067.       }
  1068.   }
  1069.  
  1070.   sub dokill {
  1071.       kill 9,$child if $child;
  1072.   }
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.   11.6.  Running an if  for remote printers
  1079.  
  1080.   One oddity of lpd is that the if is not run for remote printers.  If
  1081.   you find that you need to run an if, you can do so by setting up a
  1082.   double queue and requeueing the job.  As an example, consider this
  1083.   printcap:
  1084.  
  1085.  
  1086.        lj-5:\
  1087.                :lp=/dev/null:sh:\
  1088.                :sd=/var/spool/lpd/lj-5:\
  1089.                :if=/usr/lib/lpd/filter-lj-5:
  1090.        lj-5-remote:lp=/dev/null:sh:rm=printer.name.com:\
  1091.                :rp=raw:sd=/var/spool/lpd/lj-5-raw:
  1092.  
  1093.  
  1094.  
  1095.  
  1096.   in light of this filter-lj-5 script:
  1097.  
  1098.  
  1099.        #!/bin/sh
  1100.        gs <options> -q -dSAFER -sOutputFile=- - | \
  1101.                lpr -Plj-5-remote -U$5
  1102.  
  1103.  
  1104.  
  1105.  
  1106.   The -U option to lpr only works if lpr is run as daemon, and it sets
  1107.   the submitter's name for the job in the resubmitted queue correctly.
  1108.   You should probably use a more robust method of getting the username,
  1109.   since in some cases it is not argument 5.  See the man page for
  1110.   printcap.
  1111.  
  1112.  
  1113.   11.7.  From Windows.
  1114.  
  1115.   Printing from a Windows (or presumably, OS/2) client to a Linux server
  1116.   is directly supported over SMB through the use of the SAMBA package,
  1117.   which also supports file sharing of your Linux filesystem to Windows
  1118.   clients.
  1119.  
  1120.   Samba includes fairly complete documentation, and there is good Samba
  1121.   FAQ which covers it, too.  You can either configure a magic filter on
  1122.   the Linux box and print PostScript to it, or run around installing
  1123.   printer-specific drivers on all the Windows machines and having a
  1124.   queue for them with no filters at all.  Relying on the Windows drivers
  1125.   may in some cases produce better output, but is a bit more of an
  1126.   administrative hassle if there are many Windows boxen.  So try
  1127.   PostScript first.
  1128.  
  1129.  
  1130.   11.8.  From an Apple.
  1131.  
  1132.   Netatalk supports printing from Apple clients over EtherTalk.  See the
  1133.   Netatalk HOWTO Page <http://thehamptons.com/anders/netatalk/> for more
  1134.   information.
  1135.  
  1136.  
  1137.   11.9.  From Netware.
  1138.  
  1139.   The ncpfs package includes a daemon named pserver which can be used to
  1140.   privide service to a NetWare print queue.  From what I understand,
  1141.   this system requires a Bindery-based NetWare, ie 2.x, 3.x, or 4.x with
  1142.   bindery access enabled.
  1143.  
  1144.   For more information on ncpfs and it's pserver program, see the ncpfs
  1145.   FTP site <ftp://ftp.gwdg.de/pub/linux/misc/ncpfs/>.
  1146.  
  1147.  
  1148.   12.  Windows-only printers
  1149.  
  1150.   As I discussed earlier, some printers are inherently unsupported
  1151.   because they don't speak a normal printer language, instead using the
  1152.   computer's CPU to render a bitmap which is then piped to the printer
  1153.   at a fixed speed.  In a few cases, these printers also speak something
  1154.   normal like PCL, but often they do not.  In some (really low-end)
  1155.   cases, the printer doesn't even use a normal parallel connection but
  1156.   relies on the vendor's driver to emulate what should be hardware
  1157.   behaviour (most importantly handshaking).
  1158.  
  1159.  
  1160.   In any case, there are a few possible workarounds if you find yourself
  1161.   stuck with such a lemon.
  1162.  
  1163.  
  1164.   12.1.  The Ghostscript Windows redirector
  1165.  
  1166.   There is now a Windows printer driver available (called mswinpr2) that
  1167.   will run a print job through Ghostscript before finally printing it.
  1168.   (Rather like an if filter in Unix's LPD).  There is also a new
  1169.   Ghostscript driver which will print using Windows GDI calls.  Taken
  1170.   all together, this should(tm) allow a Windows machine to print
  1171.   PostScript to a Windows-only printer through the vendor's driver.
  1172.  
  1173.   If you get that working, you can then follow the instructions above
  1174.   for printing to a Windows printer over the network from Linux to let
  1175.   Unix (and other Windows, Mac, etc) hosts print to your lemon printer.
  1176.  
  1177.   That said, I've never tried this since I don't have a winprinter, so
  1178.   your mileage may vary.  All the software involved should be available
  1179.   from the Ghostscript home page (see the links in the Ghostscript
  1180.   section of this document).
  1181.  
  1182.  
  1183.   12.2.  The pbm2ppa program
  1184.  
  1185.   Some HP printers use "Printing Performance Architecture"
  1186.   (marketingspeak for "we were too cheap to implement PCL").  This is
  1187.   supported in a roundabout way via the pbm2ppa translator written by
  1188.   Tim Norman.  Basically, you use ghostscript to render PostScript into
  1189.   a bitmapped image in pbm format and then use pbm2ppa to translate this
  1190.   into a printer-specific ppa format bitmap ready to be dumped to the
  1191.   printer.  This program may also come in ghostscript driver format by
  1192.   now.
  1193.  
  1194.  
  1195.   The ppa software can be had from the ppa home page
  1196.   <http://www.rpi.edu/~normat/technical/ppa/>; pbm2ppa supports some
  1197.   models of the HP 720, 820, and 1000; read the documentation that comes
  1198.   with the package for more details on ppa printer support.
  1199.  
  1200.  
  1201.   13.  How to print to a fax machine.
  1202.  
  1203.   13.1.  Using a faxmodem
  1204.  
  1205.   There are a number of fax programs out there that will let you fax and
  1206.   receive documents.  One of the most complex is Sam Leffler's HylaFax,
  1207.   available from ftp.sgi.com.  It supports all sorts of things from
  1208.   multiple modems to broadcasting.
  1209.  
  1210.   SuSE ships a Java HylaFax client which allegedly works on any Java
  1211.   platform (including Windows and Linux).  There are also non-Java fax
  1212.   clients for most platforms; Linux can almost certainly handle your
  1213.   network faxing needs.
  1214.  
  1215.   Also available, and a better choice for most Linux boxen, is efax, a
  1216.   simple program which sends faxes.  The getty program mgetty can
  1217.   receive faxes (and even do voicemail on some modems!).
  1218.  
  1219.  
  1220.   13.2.  Using the Remote Printing Service
  1221.  
  1222.   There is an experimental service offered that lets you send an email
  1223.   message containing something you'd like printed such that it will
  1224.   appear on a fax machine elsewhere.  Nice formats like postscript are
  1225.   supported, so even though global coverage is spotty, this can still be
  1226.   a very useful service.  For more information on printing via the
  1227.   remote printing service, see the Remote Printing WWW Site
  1228.   <http://www.tpc.int/>.
  1229.  
  1230.  
  1231.  
  1232.   14.  How to generate something worth printing.
  1233.  
  1234.   Here we get into a real rat's-nest of software.  Basically, Linux can
  1235.   run many types of binaries with varying degrees of success: Linux/x86,
  1236.   Linux/Alpha, Linux/Sparc, Linux/foo, iBCS, Win16/Win32s (with dosemu
  1237.   and, someday, with Wine), Mac/68k (with Executor), and Java.  I'll
  1238.   just discuss native Linux and common Unix software.
  1239.  
  1240.   For Linux itself, choices are mostly limited to those available for
  1241.   Unix in general:
  1242.  
  1243.  
  1244.   14.1.  Markup languages
  1245.  
  1246.   Most markup languages are more suitable for large or repetitive
  1247.   projects, where you want the computer to control the layout of the
  1248.   text to make things uniform.  Trying to make a pretty sign in a markup
  1249.   language would probably hurt...
  1250.  
  1251.  
  1252.      nroff
  1253.         This was one of the first Unix markup languages.  Man pages are
  1254.         the most common examples of things formatted in *roff macros;
  1255.         many people swear by them, but nroff has, to me at least, a more
  1256.         arcane syntax than needed, and probably makes a poor choice for
  1257.         new works.  It is worth knowing, though, that you can typeset a
  1258.         man page directly into postscript with groff.  Most man commands
  1259.         will do this for you with man -t foo | lpr.
  1260.  
  1261.  
  1262.      TeX
  1263.         TeX, and the macro package LaTeX, are one of the most widely
  1264.         used markup languages on Unix.  Technical works are frequently
  1265.         written in LaTeX because it greatly simplifies the layout issues
  1266.         and is still one of the few text processing systems to support
  1267.         mathematics both completely and well.  TeX's output format is
  1268.         dvi, and is converted to PostScript or Hewlett Packard's PCL
  1269.         with dvips or dvilj.
  1270.  
  1271.  
  1272.      SGML
  1273.         There is at least one free sgml parser available for Unix and
  1274.         Linux; it forms the basis of Linuxdoc-SGML's homegrown document
  1275.         system.  It can support other DTD's, as well.
  1276.  
  1277.  
  1278.      HTML
  1279.         Someone suggested that for simple projects, it may suffice to
  1280.         write it in HTML and print it out using Netscape.  I disagree,
  1281.         but YMMV.
  1282.  
  1283.  
  1284.   14.2.  WYSIWYG Word Processors
  1285.  
  1286.   There is no longer any shortage of WYSIWYG word processing software.
  1287.   Several complete office suites are available, including one that's
  1288.   free for personal use (StarOffice).
  1289.  
  1290.      StarOffice
  1291.         A German company is distributing StarOffice on the net free for
  1292.         Linux.  This full-blown office suite has all the features you'd
  1293.         expect, and you can't beat the price.  There's a mini-HOWTO out
  1294.         there which describes how to obtain and install it.  It
  1295.         generates PostScript or PCL, so should work with most any
  1296.         printer that works otherwise on Linux.
  1297.  
  1298.      LyX
  1299.         LyX is a front-end to LaTeX which looks very promising.  See the
  1300.         LyX Homepage <http://www-pu.informatik.uni-
  1301.         tuebingen.de/users/ettrich/> for more information.  There is a
  1302.         KDE-styled version of LyX, called Klyx; the author of LyX and
  1303.         the instigator of KDE are the same person.
  1304.  
  1305.      The Andrew User Interface System
  1306.         AUIS includes ez, a WYSIWYG-style editor with most basic word
  1307.         processor features, HTML capabilities, and full MIME email and
  1308.         newsgroup support.  Unfortunately, AUIS is no longer maintained.
  1309.  
  1310.      Koffice
  1311.         The KDE project is working toward a whole office suite.  I don't
  1312.         think it's ready for prime time yet.
  1313.  
  1314.      GNOME
  1315.         The GNOME project also is working toward various GNU-licensed
  1316.         officey tools.  None are available yet, though.
  1317.  
  1318.      Commercial offerings
  1319.         At least Caldera and Red Hat ship packages containing the usual
  1320.         office apps like a WYSIWYGish word processor and a spreadsheet.
  1321.         I would assume they do a dandy job, but I've never used them.  I
  1322.         think Caldera also ships Sun's WABI, so you could probably run
  1323.         something like MS Office under that if you had to integrate with
  1324.         other folks' files.
  1325.  
  1326.  
  1327.         Jeff Phillips <jeff@I_RATUS.org> uses Caldera's WordPerfect for
  1328.         Linux (on Slackware, of all things) and says that it works well.
  1329.         It apparently includes built-in printer support, as one would
  1330.         expect.  Caldera should have info on  <http://www.caldera.com/>.
  1331.         You can also buy a newer version of Wordperfect directly from
  1332.         Corel's chosen Unix port company.
  1333.  
  1334.  
  1335.         RedHat and SuSE ship a suite called Applixware; you can find
  1336.         their web site at  <http://www.redhat.com/>.  Applix is
  1337.         available on many platforms, and includes a spreadsheet, word
  1338.         processor, a presentation package, and so on.  There is a
  1339.         separate version of Applix available in Java called
  1340.         ApplixAnyWhere; I would assume it's much the same, but slower
  1341.         and less featureful.
  1342.  
  1343.  
  1344.         Other vendors should feel free to drop me a line with your
  1345.         offerings.
  1346.  
  1347.  
  1348.  
  1349.   15.  On-screen previewing of printable things.
  1350.  
  1351.   Nearly anything you can print can be viewed on the screen, too.
  1352.  
  1353.   15.1.  PostScript
  1354.  
  1355.   Ghostscript has an X11 driver best used under the management of the
  1356.   PostScript previewer gv.  The latest versions of these programs should
  1357.   be able to view PDF files, as well.  Note that gv has replaced the
  1358.   older previewer "Ghostview"; the new user interface is mch prettier
  1359.   and featureful that ghostview's plain old Athena gui.
  1360.  
  1361.  
  1362.   15.2.  TeX dvi
  1363.  
  1364.   TeX DeVice Independant files may be previewed under X11 with xdvi.
  1365.   Modern versions of xdvi call ghostscript to render PostScript
  1366.   specials.
  1367.  
  1368.   A VT100 driver exists as well.  It's called dgvt.  Tmview works with
  1369.   Linux and svgalib, if that's all you can do.
  1370.  
  1371.  
  1372.   15.3.  Adobe PDF
  1373.  
  1374.   Adobe's Acrobat Reader is available for Linux; just download it from
  1375.   their web site  <http://www.adobe.com/>.
  1376.  
  1377.   You can also use xpdf, which is freeware and comes with source, and I
  1378.   should think Ghostview supports viewing PDF files with gs under X11 by
  1379.   now.
  1380.  
  1381.  
  1382.   16.  Serial printers under lpd
  1383.  
  1384.  
  1385.  
  1386.  
  1387.   16.1.  Setting up in printcap
  1388.  
  1389.   Lpd provides five attributes which you can set in /etc/printcap to
  1390.   control all the settings of the serial port a printer is on.  Read the
  1391.   printcap man page and note the meanings of br#, fc#, xc#, fs# and xs#.
  1392.   The last four of these attributes are bitmaps indicating the settings
  1393.   for use the port.  The br# atrribute is simply the baud rate, ie
  1394.   `br#9600'.
  1395.  
  1396.  
  1397.   It is very easy to translate from stty settings to printcap flag
  1398.   settings. If you need to, see the man page for stty now.
  1399.  
  1400.  
  1401.   Use stty to set up the printer port so that you can cat a file to it
  1402.   and have it print correctly. Here's what `stty -a' looks like for my
  1403.   printer port:
  1404.  
  1405.  
  1406.        dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2
  1407.        speed 9600 baud; rows 0; columns 0; line = 0;
  1408.        intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  1409.        eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  1410.        lnext = ^V; min = 1; time = 0;
  1411.        -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  1412.        -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr
  1413.        -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel
  1414.        -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
  1415.        bs0 vt0 ff0
  1416.        -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase
  1417.        -tostop -echoprt -echoctl -echoke
  1418.  
  1419.  
  1420.  
  1421.  
  1422.   The only changes between this and the way the port is initialized at
  1423.   bootup are -clocal, -crtscts, and ixon. Your port may well be differ¡
  1424.   ent depending on how your printer does flow control.
  1425.  
  1426.  
  1427.   You actually use stty in a somewhat odd way.  Since stty operates on
  1428.   the terminal connected to it's standard input, you use it to
  1429.   manipulate a given serial port by using the `<' character as above.
  1430.  
  1431.  
  1432.   Once you have your stty settings right, so that `cat file >
  1433.   /dev/ttyS2' (in my case) sends the file to the printer, look at the
  1434.   file /usr/src/linux/include/asm-i386/termbits.h. This contains a lot
  1435.   of #defines and a few structs (You may wish to cat this file to the
  1436.   printer (you do have that working, right?) and use it as scratch
  1437.   paper).  Go to the section that starts out
  1438.  
  1439.  
  1440.  
  1441.        /* c_cflag bit meaning */
  1442.        #define CBAUD   0000017
  1443.  
  1444.  
  1445.  
  1446.  
  1447.   This section lists the meaning of the fc# and fs# bits. You will
  1448.   notice that the names there (after the baud rates) match up with one
  1449.   of the lines of stty output. Didn't I say this was going to be easy?
  1450.  
  1451.  
  1452.  
  1453.   Note which of those settings are preceded with a - in your stty
  1454.   output. Sum up all those numbers (they are octal). This represents the
  1455.   bits you want to clear, so the result is your fc# capability.  Of
  1456.   course, remember that you will be setting bits directly after you
  1457.   clear, so you can just use `fc#0177777' (I do).
  1458.  
  1459.  
  1460.   Now do the same for those settings (listed in this section) which do
  1461.   not have a - before them in your stty output. In my example the
  1462.   important ones are CS8 (0000060), HUPCL (0002000), and CREAD
  1463.   (0000200). Also note the flags for your baud rate (mine is 0000015).
  1464.   Add those all up, and in my example you get 0002275. This goes in your
  1465.   fs# capability (`fs#02275' works fine in my example).
  1466.  
  1467.  
  1468.   Do the same with set and clear for the next section of the include
  1469.   file, "c_lflag bits". In my case I didn't have to set anything, so I
  1470.   just use `xc#0157777' and `xs#0'.
  1471.  
  1472.  
  1473.   16.2.  Older serial printers that drop characters
  1474.  
  1475.   Jon Luckey points out that some older serial printers with ten-cent
  1476.   serial interfaces and small buffers really mean stop when they say so
  1477.   with flow control.  He found that disabling the FIFO in his Linux
  1478.   box's 16550 serial port with setserial corrected the problem of
  1479.   dropped characters (you apparently just specify the uart type as an
  1480.   8250 to do this).
  1481.  
  1482.  
  1483.   17.  Credits
  1484.  
  1485.   The smbprint information is from an article by Marcel Roelofs
  1486.   <marcel@paragon.nl>.
  1487.  
  1488.  
  1489.   The nprint information for using Netware printers was provided by
  1490.   Michael Smith <mikes@bioch.ox.ac.uk>.
  1491.  
  1492.  
  1493.   The serial printers under lpd section is from Andrew Tefft
  1494.   <teffta@engr.dnet.ge.com>.
  1495.  
  1496.  
  1497.   The blurb about gammas and such for gs was sent in by Andreas
  1498.   <quasi@hub-fue.franken.de>.
  1499.  
  1500.  
  1501.   The two paragraphs about the 30 second closing_wait of the serial
  1502.   driver was contributed by Chris Johnson <cdj@netcom.com>.
  1503.  
  1504.  
  1505.   Robert Hart sent a few excellent paragraphs about setting up a print
  1506.   server to networked HPs which I used verbatim.
  1507.  
  1508.  
  1509.   And special thanks to the dozens upon dozens of you who've pointed out
  1510.   typos, bad urls, and errors in the document over the years.
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.