Subject: Linux-Activists - DOC Channel digest. 93-4-21-8:0
From: "Linux Activists" <[email-masked]>
To: "Linux-Activists" <[email-masked]>
Date: Fri, 21 May 1993 15:06:58 +0300

Topics:
	 A Printing FAQ for perusal

----------------------------------------------------------------------

From: [email-masked] (Grant Taylor)
Subject: A Printing FAQ for perusal
Date: Fri, 21 May 1993 04:11:46 +0300

The following is a realization of the printing faq whose outline I
posted early last week.  This is in response to that thread/flame war
we had about "obscure formats like dvi which made external
contribution impossible."

There are a few details missing, please fill me in -- particularly,
what would a sed script to add a \r after each \n look like?  i don't
know sed :(

when the holes get filled in, this can be added to ftp sites, etc...

here it is (sorry if it blows your undigestification) :

------------------------------------------------------------

INTRO  <<<<<<--------

This is my printing/previewing FAQ for linux.  Please send comments,
bug reports, etc, to:

[email-masked]

Some details are missing; that is because I do not know.  Thus please
fill me in at the above address, and I will update this thing...

INDEX   <<<<<<<<<<----------

main categories are followed in the text by <<<<<<<<<--------
sub categories all begin with '-- CATEGORY'

intro

index

printing
  ascii
  postscript
  lpr
  *roff/man pages
  mpage
  a2ps
  tex/dvi
  texinfo

previewing
  ghostview
  gspreview
  xdvi
  gxditview
  
non-x-previewing
  
ascii translation
  from tex
  from dvi
  from ps
  from troff
  from ascii  (just kidding:)

PRINTING   <<<<<<<<----------

-- ASCII TEXT

Under Linux, or under most any Un*x operating system, the easiest
thing to print with most printers is plain ASCII.  Any way you can
arrange to send the text to the printer is perfectly valid.  If you
have a serial printer, then use device /dev/ttys?, and if you have a
regular parallel hookup, use /dev/lp?.  typing 

cat file >/dev/????

should do it.  You may need root privileges, or you may wish to chmod
your printer device if this is all you ever print.
some printers (ie, HP deskjet) want dos-style end of lines:
newline+carriage return.  For these, you can simply filter them
through a little sed script which adds a cr after each \n:

cat file |sed '????????' >/dev/????

-- POSTSCRIPT

Printing almost anything other than plain text under unix involves
the ability to print postscript.  If you have a postscript printer,
you're all set.  But for most, this is not so easy.

The established way to interpret postscript under Linux is to use
ghostscript which, like nearly everything else, comes from the gnu
project.  Ghostscript is a postscript interpreter which accepts
postscript input and generates output appropriate for X displays, most
printers, some specialized display hardware, and supposedly some fax
software.  

Installations of ghostscript are available from several places:

A full, and presumably correct, installation is available in the sls;
note that this binary requires libX.so.???, as it includes the X11
display driver.  It didn't used to have the fonts, maybe it does now?

The `official' installation is to obtain the sources and build it
yourself.  This is recommended because you can select your own drivers
and build with or without X libraries as appropriate for your system.
prep.ai.mit.edu(or any gnu mirror):/pub/gnu/ghostscript-xxxx.tar.z
and ghostscript-fonts-xxxx.tar.z

A minimal binary installation of ghostscript and several other
packages needed for printing the linux documentation is available as 
sunsite.unc.edu:/pub/linux/apps/tex/texmin/texmin-0.1.tar.z
note that this does not contain any postscript fonts.

To print ps, first determine your driver name:

gs -help

and remember it.  Then type 

gs -sDEVICE=xxxxxx -q -sOutputFile=/dev/???? file.ps

and your output should (hopefully) appear at your printer.  

Note that the Epson 2550 driver works quite well for 2500 and the
Panasonic 11?? series; just don't try to print any color :)

-- LPR

Most 'real' unix systems use lpr, the line printer daemon and friends,
to spool print jobs and run them through all needed filters.  While
line printers are certainly on their way out, spooling print jobs and
running them through filters is definitely a convenient thing.  Thus
lpr.  Setting up lpr to accept postscript and print it happily is not
very difficult; simply make the following shell script:

#!/bin/sh
cat silly.ps | (gs -q -sDevice=djet500 -OutputFile=- -) >/dev/lp1

and place its name as the `if' parameter in the printcap for your
printer.  You will also need to set up a spooling directory, and make
sure you have the binaries lpd, lpr, lprm, lpq.  A binary package
which can be coaxed into working perfectly is in the sls.  Once you
have done this, simply saying 

lpr file.ps    or   cat file.ps|lpr

will print out postscript on your (probably not postscript) printer.
This use of lpr is what most programs expect to do under unix when
they want to generate printed output.

You may find that you don't like or ever expect to need the header
page which lpr by default prints out.  In principle, the `hf' printcap
parameter will let you turn this off.  For my binaries, this didn't
work, so I made the following shell script, which i called lpr:

#!/bin/sh
real.lpr -h $*

Setting up lpr correctly is definitely worth the trouble...

-- {N,T,G}ROFF, MAN PAGES:

Man pages can of course be printed straight from the cat pages which
come with the SLS (in lieu of the normal nroff source pages) as though
they were a normal text file (which they are).  If you have the nroff
source (the finding of which I highly recommend) you can say 

man -t foobar |lpr

and your man program will hopefully format the man page using groff
into postscript, which will then be sent to your lpd and on to the
printer.  This form of man page output looks MUCH better than the
plain ASCII version.

If your man doesn't do this, you might try the perl version of man,
available as man-pl on sunsite.  It is written entirely in perl, and
is thus easily customizable (perl being an interpreted language).

You can also find the nroff source file and do it yourself, into any
format supported by groff:

groff -mandoc -T{ascii,dvi,ps,X100,X75} foobar.1 [|{dvips,lpr,xditview}]

-- MPAGE

The package mpage is an excellent ASCII postscript-ifyer and n-up re
formatter for postscript.  Available as:

(wuarchive:/pub/mirrors/unix-c/printing/mpage.tar-z, approx.)

man -t foobar|mpage 

will send a 2-up version of the man page to lpr and its ps
interpreter.  This saves paper and speed up printing.

-- A2PS

A2ps will take ASCII and turn it into a nice postscript document with
headers and footers and page numbers, printed two pages on one.  A2ps
does a very nice job at this.  It is available at the same place mpage
is.

-- TEX/DVI

[La]TeX is the text formatting package used by many in the academic
world and many other places where people realize word perfect not to
be all that wonderful and ami pro to be too imprecise.  (please, no
flames, this document is helpful to some, let me put in an opinion or
two :)  TeX works much like any other compiler -- source code is run
through the program tex to become a .dvi file (analogous to a .o
object file in C) which can be further manipulated to produce printed
output.  Manipulating a dvi (device independant) file usually takes a
bit of doing.  This `bit of doing' is well worth it; TeX's output is
of professional quality.

For those in the real world who cannot afford a dvi understanding
printer, it is best to convert the dvi into postscript that you can
pipe into ghostscript or lpr.  The sls comes with a functioning
installation of both TeX and dvips.  Typing

dvips -f1 file.dvi |lpr

will do it.  Dvips must be able to seek around in its input file, so
it will not accept a pipe as input (ie, cat file.dvi |dvips...).
Dvips responds to either command line arguments or a file 
/usr/TeX/lib/tex/ps/config.ps (in the sls, at least) in which you can
arrange to have dvips automatically send it's output to lpr.  Thus 

dvips file.dvi

will do everything that needs to be done.  (this is much better than
the 'manual' dvips -f1 file.dvi |gs -q -sDEVICE=xxx -sOutputFile=- -
|/dev/????)

Note that some .dvi's may include graphics in the dvips stage rather
than the tex stage of the game; if they are not found, you will get a
hole instead of a picture.  This follows naturally from the object
file analogy above :) Usually, pre-made documentation in this form has
a makefile or script.  Lilo docs are an example of this.

Dvips has several interesting options; dvips -r1 file.dvi will print
it out backwards. We deskjet users love this one.

If all you are given is a file with a .tex ending, try either tex
file.tex or latex file.tex.  One of these is bound to work.  Then you
have a dvi.  (You may have to run it twice for indexing)

-- TEXINFO

This is the native documentation format of the GNU project.  Emacs can
be coerced into producing an info file out of this, and TeX can be
coerced into producing nice printed docs from the same file.  It is a
bit of a stretch for both systems, but it works.  It is really just
TeX source which expects the macro file texinfo.tex to be installed on
your system.  The SLS ought to have the macro package.  Just do:

tex thefile.texi[nfo] 

twice (for index generation purposes), and you end up with a plain
.dvi, to print or preview at your leisure.

PREVIEWING   <<<<<---------

-- GHOSTVIEW

There are three previewing mechanisms commonly available of which I am
aware.  Ghostview, a companion program for gs, previews postscript on
an X display.  It also lets you select individual or ranges of pages
from a postscript document to print using lpr.  A binary installation
of this is probably in the SLS.  The real installation is from source

prep.ai.mit.edu:/pub/gnu/ghostview-xxx.tar.z

and is a clean build.  Ghostview requires gs to work.  The new
version, 2.6, will use X display fonts in an effort to improve
legibility at low resolution (a previous failing of this pair relative
to commercial display-postscript based systems such as Sun's
pageview).

-- GSPREVIEW

This is another front-end for ghostscript.  I have gotten and built
it, and actually preferred the user interface, but it had a slight
glitch which was probably me doing a careless install rather than a
program bug.  It didn't seem as feature full as ghostview, though.
(Not that there are all THAT many features in ghostview, but it does
its job well)

export.lcs.mit.edu:/contrib/GSPreview*

-- XDVI

A beautifully legible previewing program for dvi with a handy 
zoom+pan feature.  Will not interpret ps specials, which are
understood only by dvips (back to the compiler, object file, and now
linker analogy :)  To view a file, do:

xdvi file.dvi.  

Mine (from export.lcs.mit.edu:/contrib/... ) has the selfile feature,
where xdvi puts up a file browser... cute but useless.  This comes
with either TeX or X in the SLS -- either way, you've probably got
one.

-- GXDITVIEW

Produces a preview version of troff source using X fonts (this means
it's legible and typeset-looking.)  

groff -TX100 -mandoc man_page.1

will typeset and run gxditview to show you a typeset version of the
man page.  -TX75 is the same thing, but tiny.  My SLS didn't have a
working one at all.  A good one comes with the source to groff, which
you might want to get anyway for the additional drivers (the SLS,
until recently, was missing several).  

prep.ai.mit.edu:/pub/gnu/groff-xxxx.tar.z

-- NON-X-PREVIEWING

gs comes with pc video hardware drivers, but under unix these are not
a good thing.  did anyone bother with a vgalib port?

ASCII TRANSLATION   <<<<<<------------

-- FROM TEX

lametex will generate ascii from tex source.  a beta (?) version is
now available:

sunsite.unc.edu:/pub/Linux/apps/tex/lametex.tar.z

-- FROM DVI

dvicat supposedly spits out the text in a dvi file; I've never dealt
with it.

-- FROM PS

Ghostscript 2.6 comes with a script file which will use gs to extract
just the text from a ps file, called ps2ascii.  See the gs information
above for where it can be found.

-- FROM TROFF

groff -Tascii.....    

will do you :)

END <<<<<<<<<<<<<<---------------

-grant

-------------------------------------------------------------------
Grant Taylor                                 [email-masked]
13215 Indian Creek Way			      Work:  (713) unknown!
Houston, TX 77079			      Home:  (713) 467-9115

------------------------------

End of DOC Digest
*****************
-------