MkLinux DeskWriter Printing With netatalk


Document Change History (check this to see what's different if you've visited this page before)

This document describes how I print to my HP DeskWriter 540c from MkLinux. This is done by treating the DeskWriter as a PostScript printer. There are two main factors in getting this to work:

Once everything is set up and working, you can print PostScript to a DeskWriter from a MkLinux login session and make the DeskWriter available as a PostScript printer over the network to MacOS or UNIX clients.

Preliminaries

There are certain prerequisites that must be in place before you can use the instructions in this document:

There is another document you can read that describes how to print to DeskWriter printers from Linux. I recommend you read it, even though it's PC Linux-oriented rather than MkLinux-oriented. There is also a discussion of using ghostscript with DeskWriter printers in the devices.txt file that is included with the ghostscript distribution. It's in the "HP color inkjet printer" section. You should take a look at it, especially if you don't have the same model printer that I do. You may need to specify a different device name or parameters in some of the commands shown below.

DeskWriter Printing Setup

The steps I followed to be able to treat my DeskWriter 540c as a PostScript printer are described below.

The printer must be reachable over an ethernet network because MkLinux has ethernet support only. Since DeskWriters have LocalTalk (non-ethernet) interfaces, this means you'll need to use some sort of bridging from LocalTalk to ethernet. You can use a hardware device such as a microPrint or equivalent. If you run nbplkup from the MkLinux host, you should see the DeskWriter in the list of AppleTalk entities.

The printer must have an entry in /etc/printcap. I called my printer dwa (DeskWriter A), and its entry looks like this:

    dwa|HP DeskWriter 540:\
        :sd=/var/spool/dwa:\
        :lp=/dev/atalk/dwa:\
        :mx#0:sh:sf:\
        :lf=/var/log/lpd-errs:\
        :if=/usr/local/atalk/lib/atalk-filters/ifdeskwriter:

If printcap entries are unfamiliar to you, read the background document on netatalk printing under MkLinux.

Create the spool directory:

    # cd /var/spool
    # mkdir dwa
    # chown root.lp dwa
    # chmod 775 dwa

Create the "line printer" device file:

    # cd /dev
    # mkdir atalk                (if it doesn't exist)
    # chown root.lp atalk
    # chmod 775 atalk
    # touch atalk/dwa
    # chown root.lp atalk/dwa
    # chmod 664 atalk/dwa

Create the log file if it doesn't already exist:

    # cd /var/log
    # touch lpd-errs
    # chown root.lp lpd-errs
    # chmod 664 lpd-errs

Create the input filter (/usr/local/atalk/lib/atalk-filters/ifdeskwriter). This is the interesting part since the DeskWriter will be treated as a PostScript printer, but does not understand PostScript. The input filter takes care of this by running the print job through ghostscript to convert PostScript to the input format that a DeskWriter understands. (Note: This means the filter assumes its input is already in PostScript format. If you want to send text files to the printer, you'll either need to run them through a PostScript converter or arrange to use some sort of filter that does this for you.)

A ghostscript command to read PostScript on the standard input and send DeskWriter output to the standard output looks like this:

    gs -q -dNOPAUSE -sDEVICE=cdjcolor -sOutputFile=- -

The device name of cdjcolor works for DeskWriter 500 or 540 models. For a different type of DeskWriter, you would likely substitute a different DEVICE value.

As it happens, colors in output created this way tend to print rather dark, so it works better to preface the PostScript to be printed with a short fragment that resets the RGB gamma (this is explained in the devices.txt file that comes with the ghostscript distribution). One way to do this is as follows:

    ( echo '%!' ;
      echo '{0.333 exp} dup dup currenttransfer setcolortransfer' ;
      cat -
    ) | gs -q -dNOPAUSE -sDEVICE=cdjcolor -sOutputFile=- -

Once the PostScript has been converted to DeskWriter-compatible format, it can be sent to the printer using the pap program. Unfortunately, I found (as have others who've tried the same thing) that pap doesn't exit once the job has been sent and you have to kill it manually. This is apparently due to some sort of protocol violation such that the printer doesn't return an end of file indication. The difficulty can be avoided by using the (undocumented) -E flag. The flag tells pap not to wait for end of file from the printer after it's sent the job.

Given the constraints just described, the input filter ifdeskwriter can be written like this:

    #!/bin/sh

    # lpd input filter for DeskWriter 540 printer (may work for others)
    # - Assumes PostScript input is on stdin
    # - Assumes printer is named in .paprc in printer spool directory
    # - Uses pap -E to not wait for printer to do device close because
    #   DeskWriter seems to violate protocol
    # - The echo lines set the RGB gamma so colors aren't printed so dark

    PATH=/usr/local/atalk/bin:/usr/local/bin:/bin:$PATH
    export PATH

    ( echo '%!' ;
      echo '{0.333 exp} dup dup currenttransfer setcolortransfer' ;
      cat -
    ) | gs -q -dNOPAUSE -sDEVICE=cdjcolor -sOutputFile=- - | pap -E

One thing yet remains, which is to create a .paprc in the printer's spool directory so that pap can tell where to send the print job. My /var/spool/dwa/.paprc file looks like this:

    DeskWriter:DeskWriter@*

If you have renamed your printer from the default of "DeskWriter", the first field in the name will be different. Also, I specified the zone as "*" because my network has no zones. If you were in a network with named zones, you'd replace the "*" with the zone name.

Now you can try printing. A simple test is to print the tiger.ps file in the ghostscript distribution:

    % lpr -Pdwa tiger.ps
You can check the print queue like this:
    % lpq -Pdwa
I don't like having to type -P flags, so I created two scripts dwa and dwaq and installed them in /usr/local/bin. dwa looks like this:
    #!/bin/sh
    exec /usr/bin/lpr -Pdwa $*
dwaq looks like this:
    #!/bin/sh
    exec /usr/bin/lpq -Pdwa $*

Printing From MacOS Clients Through MkLinux

Once you've gotten local DeskWriter printing working, you can advertise the printer over the network to Macintoshes running MacOS. They see the DeskWriter as a PostScript printer and can print to it using the LaserWriter 8 driver.

My MkLinux machine is named grey so I chose to make the DeskWriter available from it as dwa-grey. This requires an entry in the papd.conf file in /usr/local/atalk/etc:

    dwa-grey:\
        :pr=dwa:\
        :pd=/usr/local/atalk/etc/HP_650C1.PPD:\
        :op=netatalk:

The PostScript printer description file named here (the pd value) is for a DesignJet 650c. I used it since there is no equivalent file for a DeskWriter 540c. There might be a better choice, but the HP_650C1.PPD file seems to work well enough. I got it from the Adobe FTP site and copied it into /usr/local/atalk/etc on the MkLinux host. You should also put a copy in the Printer Descriptions folder inside System Folder:Extensions on each MacOS client.

To make the DeskWriter visible to client machines, either reboot the MkLinux host, or kill and restart papd. Macintosh clients should be able to see dwa-grey in the printer list from the Chooser when they select the LaserWriter 8 driver, and should be able to configure it as a DesignJet 650. You should also see the name dwa-grey from the MkLinux machine if you run nbplkup.

If a print job contains color but you don't get a color printout when printing from a Macintosh client, be sure to click the Options button in the print dialog and select Color/Grayscale.

Printing From UNIX Clients Through MkLinux

Instructions for this are available here.

Change History

No changes yet.


Go to main MkLinux page
Document written by: Paul DuBois, paul@snake.net
Last updated: Thursday, 04 July 1996 11:53