Subject: Re: Printing
To: Andrew Crossley <toast@iinet.net.au>
From: Roger Brooks <R.S.Brooks@liverpool.ac.uk>
List: netbsd-help
Date: 02/26/2000 11:49:20
On Fri, 25 Feb 2000, Andrew Crossley wrote:

>Hello from Xit yet again,
>
>Strike me down for being stupid, but i have printing problems.  Firstly, I have
>read all the Manual pages relating to lp, lpr, lpq, magicfilter, etc.  They did
>not resolve my problem.
>
>Firstly, KDE is my Window Manager system of choice.
>
>In console printing situations, i am getting the classic "staircase" effect,
>and i am having problems finding an IP that fixes this.  I understand that unix
>uses only one character for line feed and carraidge return.  What is the
>necessary IP line that issues this in my printcap file ??
>
>When i try to print using kde, i get a garbled output that is no where near
>what i intended to print.  Being an old Linux head, i found it easy, as i have
>an install binary for magicfilter and that sorts things out for me.  I have
>used many different configs supplied with magicfilter ( i use a Canon BJC-210),
>eg BJ200, BJ600, Epson ones etc and they all give the same garbage in X, and
>still the staircase effect from the console.  Is there a newbie freindly binary
>available for NetBSD so as to set up an IP line in printcap easily, or can
>anyone point me in the direction of some more documentation to read in regards
>to printing in NetBSD ??

OK, this is because Unix uses NL as the line terminator, while most
printers want CR NL.

There are several ways you can fix this:

1.  If your printer is connected to a *serial* port, add

    :ms=opost onlcr <other stty options>:

    to the printcap entry (<other stty options> are anything else you need to
    match the settings of the printer's serial port - baud rate, parity etc).
    onlcr makes the tty driver expand NL to CR NL, and opost enables this
    and several other output postprocessing options).  But if your printer
    is connected to a parallel port this won't work.


2.  Use

    :if=/usr/libexec/lpr/lpf:

    in your printcap entry.  This also converts NL -> CR NL, and also
    handles overprinting and underlining with backspaces correctly (so
    bold and underlined text as produced by nroff looks right).
    Note that lpf is for ASCII files only (and will mangle things containing
    printer control codes).  lpf also expands TAB to the next multiple of 8
    columns and generates printer accounting records.

    
    If you also want to print non-ASCII files, you really need to set up filters
    for some of the other data formats (e.g. :nf=<filter> : for ditroff output or
    :vf=<filter>: for raster images.  Unfortunately, these are not provided,
    because the output you'd need to generate would delend on your printer.

    I guess these days that everything that isn't ASCII is handled as PostScript
    which I suppose is where magicfilter comes in.
    I've never used magicfiler, but I would think that if you use

    :if=/path/to/magicfilter:

    then magicfilter should be configured so that when it decides that the input
    is plain ASCII, it runs lpf (with the args supplied to magicfilter).


3.  Send an escape sequence to the printer at the start of every job which
    makes *it* expand CR -> CR NL.  What you need to send depends on the printer
    (and not all printers may provide a means of doing this).  I know you can
    do it with PCL printers, but I can't remember what you need to send.
    If you are using lpf, you would need to write a wrapper script e.g
    /usr/libexec/lpr/PCL-lpf which looked like this:

    #!/bin/sh

    echo <PCL_setup_codes> 
    exec /usr/libexec/lpr/lpf "$*"


Solution 2 is most general, in that it will work with serial, parallel and
ethernet-connected printers, and doesn't depend on knowlege of the control
codes used by the printer.
    


Roger

------------------------------------------------------------------------------
Roger Brooks (Systems Programmer),          |  Email: R.S.Brooks@liv.ac.uk
Computing Services Dept,                    |  Tel:   +44 151 794 4441
The University of Liverpool,                |  Fax:   +44 151 794 4442
PO Box 147, Liverpool L69 3BX, UK           | 
------------------------------------------------------------------------------