Setting up printing

This file documents the procedure to set up printing with the HP OfficeJet Linux driver (hpoj) package.

Introduction

The hpoj software's printing support is largely powered by the existing printing subsystem which should already be installed on your computer by your distribution. Typical components of this infrastructure include: Due to the wide variety of printing solutions available for Unix-like operating systems, this document cannot possibly provide information specific to each one. Instead, it presents the general procedure for setting up printing, with particular emphasis on what you need to do differently in order to print through the hpoj low-level driver (ptal-mlcd) so as to coexist properly with other services on the device, such as scanning. In some cases, examples specific to RedHat printtool or generic lpd are provided. In addition to this document, you should refer to your distribution's printing-setup documentation, and/or to the Linux Printing HOWTO, for more specific information.

Be sure to follow the instructions to compile and install the hpoj software and set up basic device connectivity if you haven't already. In particular, the ptal-printd and ptal-mlcd daemons, typically started by the ptal-init script, need to be running for each locally-connected HP all-in-one peripheral.

Setting up a print queue

Note: If you are upgrading from a previous version of the hpoj package where you had set up print queue(s) using the old "wrapfilter" method, then you should delete the old print queue(s) and start from scratch.

First, you need to add a print queue to your spooler. The specific procedure differs greatly depending on what spooler you have. Consult your distribution's/spooler's documentation for details.

The general setup procedure you use depends on whether your peripheral is connected locally to your PC's parallel port or USB, or remotely to an HP JetDirect print server.

Setting up a local print queue

You must provide a path and filename to the character-device special file to which the print-job data should be written in order to send to the peripheral. In the "traditional" case of a single-function printer, which is not controlled by ptal-mlcd, you would provide a filename of the form /dev/lp0 for a parallel-connected printer, or /dev/usb/lp0 for a USB-connected printer. However, that will not work properly in the case of an HP all-in-one peripheral controlled by ptal-mlcd, because it would conflict with ptal-mlcd's use of the port and would probably also confuse the peripheral.

In the section on setting up basic device connectivity, you should have arranged for the ptal-printd daemon to be loaded for each locally-connected device, in addition to ptal-mlcd. You could have either done this explicitly, by editing the ptal-start.conf configuration file (typically for parallel-connected peripherals), or by running ptal-init with the setup option, which probes your system for USB-connected printers and updates ptal-start.conf accordingly.

The ptal-printd daemon creates a special file (specifically, a named pipe), which simulates a traditional printer character device. Any data written to this pipe special file, presumably by the print spooler, is correctly routed through libptal, ptal-mlcd, and on to the printer.

By default, ptal-printd creates this special file in the /dev/ptal-printd directory. The default filename is the PTAL device name with colon characters replaced with underscores, because colons have special meaning in /etc/printcap.

For example, the PTAL device name mlc:par:0 by default maps to /dev/ptal-printd/mlc_par_0, and mlc:usb:OfficeJet_G85 maps to /dev/ptal-printd/mlc_usb_OfficeJet_G85.

By default, ptal-init and ptal-start.conf also pass the "-like /dev/lp0" switch to ptal-printd. The purpose of this switch is to tell ptal-printd from where to copy file permissions for the special file. Unless you have different file permissions for different printer character devices, you don't need to change this, even if your peripheral is connected somewhere other than to parport0.

lpd specific:

Set the lp= field in /etc/printcap to the path and filename of the pipe special file created by ptal-printd, such as /dev/ptal-printd/mlc_par_0 or /dev/ptal-printd/mlc_usb_OfficeJet_G85.

Setting up a remote (JetDirect) print queue

For setting up a remote lpd queue, you need to specify the following information:

lpd specific:

The following fields in /etc/printcap are specific to setting up remote lpd queues:

Optional: alternatives to remote lpd queues

There are several alternatives to setting up a remote lpd queue for printing to a JetDirect-connected peripheral:

Common print queue setup

Set the queue name to something appropriate, such as officejet, hpojg85, etc. Depending on your print spooler and print-queue-setup application, you may be able to specify multiple names with a vertical bar ("|") in between. Just make sure you don't use the same name for multiple queues.

If you are asked for a file limit or maximum size, set it to zero, which should mean unlimited, unless you really want to enforce a maximum print job size for your users.

If you are asked whether to print headers (banner pages), then tell it to disable this feature (the sh option in /etc/printcap).

Once you have created the print queue, you may need to restart your print spooler (such as lpd) to cause it to re-read its configuration file(s) and notice the new print queue.

Troubleshooting

If your system hangs when (re)starting lpd, particularly during bootup, then be sure ptal-printd gets started (typically by ptal-init) before lpd. See the Post-installation steps for more information.

Setting up the ghostscript print filter

This step sets up the mechanism to convert device-independent PostScript from an application into the page description language specific to your model, such as HP PCL. Again, due to the diverse methods for setting this up, only generic instructions will be provided.

For the best print quality, use the HP inkjet driver, which consists of a modification to ghostscript and a separate "server" process (hpijs). This set of drivers may be installed in one of the following ways:

The procedure for installing the hpinkjet drivers is beyond the scope of this document.

For the most up-to-date information on what ghostscript drivers work with which HP all-in-one peripherals, refer to the "Print" column on the Supported Devices page on the hpoj web site.

Here are the currently known driver-to-printer mappings:

Note: Older hpinkjet versions had a bug that made the DJ6xx and DJ6xxP drivers not work in conjunction with ptal-mlcd. This problem was fixed in version 0.96 and later.

Select the following options if you are asked for them (this particular wording is from RedHat printtool):

See the file Devices.htm or devices.txt in the ghostscript documentation for more information.

Optional: Adjusting the ghostscript gamma setting

Thanks to Joe Piolunek for providing this information.

If you need to adjust the brightness of one of the ghostscript drivers (probably not necessary with the hpinkjet drivers), then create the file /usr/local/etc/gamma.ps (or in a different location if you'd like). Specify this filename (with the full path) in the "Extra GS options" field for the print filter configuration dialog box (for RedHat printtool). In general, this file should be passed to ghostscript before the actual file you're trying to print.

My gamma.ps contains the following text (between the "cut" lines). Blank lines and lines starting with '%' are ignored by ghostscript.

cut------------------------------------------------

%!
% filename: /usr/local/etc/gamma.ps
%
% Blank lines and lines starting with '%' are ignored by ghostscript.
%
% For additional information, see 'Devices.htm' or 'devices.txt' in your
% ghostscript documentation.
%
% Enable only one line by removing the '%'
% from the beginning. You may need to play with
% these settings to see which works best
% on your printer model. Your ghostscript
% version may also make a difference.
%
% Some models may prefer three gamma correction parameters, some four.
%
% This is the currently enabled setting. It works with my OfficeJet 600:
{0.333 exp} {0.333 exp} {0.333 exp} currenttransfer setcolortransfer
%
% If the first doesn't work, try this:
%{0.333 exp} {0.333 exp} {0.333 exp} {0.333 exp} currenttransfer setcolortransfer
%
% Settings can be abbreviated.
% {0.333 exp} dup dup currenttransfer setcolortransfer
%
% The floating-point numbers in the curly braces
% can be used to lighten or darken individual colors,
% but it is probably better to keep them equal to each other.
%
% Decreasing the size of the floating-point numbers
% in the parameter set will lighten the printing.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This section is taken from the SuSE Linux Support web site. It is meant for
% use with apsfilter, but it may be useful in other cases:
%
% Note: these don't work for me. I'm including them only
%       as information in case you want to try them.
%
% Assuming your printer uses CMYK colors, just remove the '%'
% sign from the line you'd like to use as follows:
%
%%   CYAN      MAGENTA     YELLOW      BLACK
%{0.217 exp} {0.217 exp} {0.217 exp} {0.217 exp} setcolortransfer
%{0.256 exp} {0.256 exp} {0.256 exp} {0.256 exp} setcolortransfer
%{0.333 exp} {0.333 exp} {0.333 exp} {0.333 exp} setcolortransfer
%{0.450 exp} {0.450 exp} {0.450 exp} {0.450 exp} setcolortransfer
%
% The values must be between 0.001 and 0.999
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cut------------------------------------------------

Setting ownership and permissions for gamma.ps:

	$ su
	# cd /usr/local/etc
	# chown root:root gamma.ps
	# chmod 644 gamma.ps
It's not necessary to restart lpd if you're only modifying gamma.ps.

The SuSE Linux Support site has more information on printer gamma setting. A Google search for gamma.ps will turn up more information.

Trying it out

With Redhat printtool the easiest way to test your printing setup is to click on the queue and print an ASCII and/or PostScript test page (from the "Tests" menu). If you experiment with gamma settings as described in the previous section, you should see a difference in the brightness of the graphics on the PostScript test page.

For most if not all print spoolers, the lpr command is used to print files (for example, "lpr foo.txt" or "lpr foo.ps"). If you have more than one print queue, then by default lpr uses the first one. If you want to use a particular queue, then use the -P parameter (for example, "lpr -Pofficejet foo.ps"). To print from Netscape and many other applications, tell it to use the print command lpr or "lpr -Pofficejet" as appropriate.

Optional alternative: bypassing the print spooler

If for whatever reason you can't get your print spooler and the hpinkjet driver to cooperate, or even if you just want more control over the PostScript-to-PCL conversion, then you can use some variation on the following pipeline (split over multiple lines for clarity) to print:
	cat foo.ps | gs -q -sDEVICE=hpijs -sDeviceName=DJ9xx \
		-r300x300 -sPAPERSIZE=letter -dNOPAUSE -dSAFER \
		-sOutputFile=- - | ptal-print mlc:par:0
Note that that last command is ptal-print, without the "d" suffix.

Substitute as appropriate the following things:

On the other hand, if you want to "print to a file", or in other words save the resulting PCL output to a file rather than printing it, then redirect the gs output to a file instead of piping it to ptal-print.

Next steps

You may now set up scanning if you haven't already, or return to the index.