chrislale@users.sourceforge.net
Revision History | ||
---|---|---|
Revision 1.0 | 14th November 2002 | Revised by: CTL |
Initial draft |
Copyright ©2002 Chris Lale (chrislale@users.sourceforge.net). Permission is granted to copy, distribute and/or modify this document with no Invariant Sections, with no Front-Cover texts and with no Back-Cover Texts under the terms of the GNU Free Documentation License, version 1.1 or any later version, published by the Free Software Foundation. A copy of the license can be found at http://www.fsf.org/copyleft/fdl.html.
You can get the latest version of this document from http://newbiedoc.sourceforge.net.
If you find any errors, omissions etc, please let me know at chrislale@users.sourceforge.net.
I have written this article in standard (UK) English. I hope that this will not cause problems for users of other dialects eg American (US) English. I have used American spelling for some technical terms eg 'program' and 'disk' where this have become widely accepted. If you spot a mistake, please check with a UK dictionary or spell-checker before contacting me! You can find a summary of English punctuation and grammar at http://www.bolton.ac.uk/webpublishing/guidelines/grammatical.html.
Information from the screen, or echoed from the keyboard, appears in a highlighted block. I have tried to start each section with an explanation, and then summarise the screen output in a single block.
Command prompts are constructed from the name of your computer, your user name and a '$' for a normal user or a '#' for a user with root privileges. Your command prompts will look different from mine. I have abbreviated the command prompts in the rest of this article to either '$' or '#'.
For example, these are the prompts for user 'chris' on computer (host) 'athlon':
chris@athlon:~$ athlon:/home/chris# |
In this article they are abbreviated to:
$ # |
A command is invoked at the command prompt by tapping the enter key. For clarity, I will not show the enter key after the command. However, I will indicate where the enter key is used within a program.
Enter key assumed at command prompt:
# modconf |
Enter key specifically shown within a program:
Exit enter |
You can install a parallel printer by loading some kernel modules for the parallel port, and installing Lpr or Lprng. Some programs seem to print OK to a non-postscript printer (eg an inkjet or a PCL printer). When I first installed Debian I tried printing a text file from Emacs. It printed perfectly and I thought everything was OK. Then I tried Emacs' "Pretty-Print" and the printer produced an unending stream of pages covered with PostScript code. Fortunately, Debian includes various software packages to overcome this problem.
I have tried Apsfilter, but I cannot get it to work in Debian 3.0 (although it worked well in 2.4). Magicfilter and CUPS both work well, but Magicfilter is probably simpler for a home desktop PC.
Magicfilter makes use of Ghostscript to convert PostScript output into a single page image (or several page images). Your printer treats each page as a single graphic. Brilliant! You now have a PostScript capable printer for the price of a cheap inkjet.
If you find that your non-PostScript printer is spewing out pages and pages of postscript code - don't panic. You can use the command lprm - to remove the active print job. (If you are using the X-window system you must open a terminal first.)
# lprm - enter |
You can find out more about this command by typing man lprm followed by enter at the command prompt.
I will assume that you will use the spooling daemon Lpr, although Lprng also works with Magicfilter. I will also assume that you will install the software packages from the official Debian CDs, but you can use any Apt source.
I have tested these instructions on my x86 system. I have a Canon BJC-4200 colour inkjet printer attached to the parallel port.
I explain how to carry out the installation in stages rather than in one go. It takes a little longer, but you can test that everything works at each stage. This makes it easier to pin down errors, or even to avoid them all together.
The stages are:
Find out the make and model of your printer.
Check which port your printer is attached to.
Find out the name of the Ghostscript driver for your printer.
Decide which Magicfilter input filter to use.
Install Lpr, Ghostscript and Magicfilter.
Use Magicfilterconfig to generate a new printer capabilities database file ('printcap').
Install the new printcap file.
Test printing both ASCII and PostScript output.
Before you start, you need some information about your printer. This enables you to find a suitable Ghostscript driver and Magicfilter input filter for your printer. This is what you need:
You will need to know the following information:
Make and model of your printer
The port used by your printer. Most printers are connected to the parallel port LPT1 (lp0 in Linux). If it is a serial printer, it is usually connected to COM1 (ttyS0) or COM2 (ttyS1).
You need to know the name of a suitable Magicfilter input filter for your printer. You can find out which filters are available on your system later on from within Magicfilter. I have reproduced this list in Table 1 below.
Magicfilter's input filters make use of Ghostscript's printer drivers. The filters usually have names very similar to Ghostscript's drivers. For example, the 'epsonlq' filter makes use of Ghostscript's 'lq850' driver. You should be able to recognise the filter you need if you know the Ghostscript driver for your printer. You can find out which Ghostscript driver suits your printer from a Linux printer database on the Web. You can find it at http://www.linuxprinting.org/printer_list.cgi. Using this database I found that the Ghostscript driver for my Canon BJC-4200 printer was the 'bjc600'. This enabled me to choose Magicfilter's 'bj600' filter.
Here is the list that appears when you configure Magicfilter. The filters concentrate on the printer language. If you know, that your printer uses a given printer language (e.g. ESC/P2 or PCL5) and your printer is not listed, you can use another filter which uses same language.
Table 1. Magicfilter input filters
StylusColor-1520@1440dpi | StylusColor-500@360dpi | StylusColor-500@720dpi |
StylusColor-600@1440dpi | StylusColor-600@360dpi | StylusColor-600@720dpi |
StylusColor-800@1440dpi | StylusColor-800@360dpi | StylusColor-800@720dpi |
StylusColor-II-IIs@360dpi | StylusColor-II@720dpi | StylusColor-IIs@720dpi |
StylusColor-generic | StylusColor@360dpi | StylusColor@720dpi |
bj10e | bj200 | bj600 |
bj600_draft | bj610 | bj800 |
bj800_draft | cps300 | cps400 |
cps600 | cpsonly300 | cpsonly400 |
cpsonly600 | deskjet | dj500 |
dj500c | dj550c | dj630c |
dj670c | dj670c-best | dj670c-low |
dj690c | dj690c-best | dj690c-low |
e312 | epson9 | epson9c |
epsonlq | epsonlqc | gdi |
ibmpro | jetp3852 | la50 |
la75 | laserjet | laserjetlo |
lbp8 | lj250 | ljet2p |
ljet2plo | ljet3 | ljet4 |
ljet4050 | ljet4l | ljet4m |
ljet4ml | ljetplus | ljetpluslo |
ln03 | m8510 | necp6 |
oki182 | pcl3 | pj |
pjxl | pjxl300 | ps300 |
ps400 | ps600 | psonly300 |
psonly400 | psonly600 | r4081 |
stylus800 | tek4693 | tek4696 |
You are now ready to install the software packages.
This section explains how to install kernel modules for parallel port printer support, the print spooler Lpr, the print filter Magicfilter and the PostScript interpreter Ghostscript.
You must have root privileges to carry out this work. You could login as root, but this is considered to be bad practice. You could more easily make a mistake and damage your system. It is safer to login as a normal user and use the 'switch user' (su) command and root password to obtain sufficient root privileges. If you use an X session graphical login you can either
login and open a terminal window (eg Xterm), or
open a virtual terminal with the key combination ctrl+alt+F1 and login. (Use ctrl+alt+F7 to return to your X console later.)
Switch user using the root password:
$ su Password: # |
Return to normal user privileges at the end of the installation:
# exit $ |
Skip this section if your printer does not connect to your parallel port. (The parallel port is a D-shaped connector with 25 pins in two rows. It is sometimes labelled 'LPT1'.)
The kernel may already have parallel printer support support module installed. You can check by running the modconf program by entering modconf at the command line. Modconf can also install the module for you.
The first screen asks you to select the category of modules. Scroll down the list (or tap m) to highlight 'misc Drivers that don't fit in the other categories'.
The next screen allows you to select modules. Scroll down the list (or tap l a few times) to highlight 'lp Parallel printer support'. If line is tagged with '+', the module is already installed. There is no need to install any more modules. Scroll up to the top of the list (or tap the home key) to return to the previous menu and exit.
If the 'lp' line is tagged with '-', you must install the module. Make sure that the line is highlighted and tap enter to install the module in the kernel. You should not need to enter commandline arguments. The 'lp' module is able to autoprobe for the information it requires.
Check that the 'lp' module is now tagged with '+'. Exit to the previous screen, and then exit the program.
# modconf Please select the category of modules misc Drivers that don't fit in the other categories. enter lp - Parallel printer support enter Install this module in the kernel? enter Enter Command-Line Arguments (leave blank) enter lp + Parallel printer support home Exit Finished return to previous menu enter Exit Finished return to previous menu enter # |
Lpr uses a spooling daemon (lpd) to print files in the background while you carry on with other tasks. Apt-get is the best way to install it. Apt-get will tell you if it is already installed. Do not skip this step unless you are sure that Lpr (or Lprng) is already installed. Magicfilterconfig creates a spool directory during the configuration process. If you do not install Lpr before this happens, you may have to create the directory manually (mkdir /var/spool/lpd/name_of_the_spool_directory).
Enter the command apt-get install lpr. Apt-get will tell you that it is reading package lists and building the dependency tree.
If Lpr is already installed, Apt-get will exit with the message 'Sorry, lpr is already the newest version'. Otherwise it will tell you which new package(s) it is going to install. If you are installing from CD it will prompt you to insert 'Official i386 Binary-1' in your CDROM drive. Apt-get will unpack and set up Lpr. It will then start the Lpd print spooler and exit. Easy!
# apt-get install lpr Reading Package Lists... Building Dependency Tree... The following NEW packages will be installed: lpr Media Change: Please insert the disc labeled '...Official i386 Binary-1...' enter Unpacking lpr ... Setting up lpr ... Starting printer spooler: lpd. # |
Use Apt-get to install the Ghostscript package 'gs'. If Ghostscript is already installed, Apt-get will tell you so and exit.
# apt-get install gs |
Use Apt-get to install Ghostscript and Magicfilter. Apt-get will also intelligently install any other packages that may be required. After unpacking and setting up Magicfilter it will suggest that you run Magicfilterconfig. More on this in the next section.
# apt-get install magicfilter Reading Package Lists... Building Dependency Tree... The following NEW packages will be installed: magicfilter Media Change: Please insert the disc labeled '...Official i386 Binary-1...' enter Unpacking magicfilter ... Setting up magicfilter ... Run `magicfilterconfig' if you want to have your printcap automatically generated or edit it by hand. # |
You are now ready to configure Magicfilter.
Lpr uses a printer capabilities database file called /etc/printcap to store details about your printer's configuration. Magicfilterconfig needs to change some of the information in this file. Rather than making changes automatically, magicfilterconfig creates a new printcap file which you can use to replace the original one by hand. This leaves you in full control. You can always restore the original printcap file if the new one causes problems.
Magicfilterconfig asks you to provide a name for your printer and a short name for its spool directory. These can be anything you like, but you should try and make them recognisable. (I decided on 'Canon BJC-4200' for my printer's name and 'myCanon' for the spool directory.) Magicfilterconfig will also ask you for the device name of your printer port. This would be /dev/lp0 for a printer plugged into the lp0 (LPT1) parallel port. For a serial printer /dev/tty0 is the device for the tty0 (COM1) port, and /dev/tty1 for the tty1 (COM2) port.
You must also supply the name of the Magicfilter input filter that you chose in "Choosing an input filter" above. You can check that the input filter suits your printer by reading the first few lines of the filter file with a text editor. The files are in the /etc/magicfilter directory.
Magicfilterconfig prompts you to enter the full name for a second printer. Enter 'none' if you do not wish to set up a second printer.
# magicfilterconfig Printer #1: ------------ Full name, `done' when done [HP Laserjet 4L ]: Canon BJC-4200 enter Short name, name of the spool directory [hplj4l ]: myCanon enter Full device path (or remote machine name) [/dev/lp1 ]: /dev/lp0 enter (List of filters appears here.) The input filter to be used [ljet4l ]: bj600 enter Printer #2: ------------ Full name, `done' when done [done ]: done enter |
Magicfilterconfig now summarises the settings you have chosen, and asks you to confirm them:
Printer configuration Printer name Short name Spool dir Device Input filter ------------------------------------------------------------------------------- Canon BJC-420 myCanon /var/spool/lpd/myCan /dev/lp0 bj600 * Is this ok? (y/n) [y]: y enter |
Some messages appear here. They are summarised in the next two sections.
Press <ENTER> to continue. enter # |
Your new printcap file has been created in /var/tmp.
One of Magicfilterconfig's messages suggested that you may wish to fine tune your newly created /var/tmp/printcap file. Such modifications are beyond the scope of this article. If you wish to go ahead, Magicfilterconfig suggests that you read the printcap(5), lpr(1), lpq(1), lprm(1) and lpc(1) manual pages and the PRINTING-HOWTO first.
Now all you need to do is replace the original /etc/printcap file with your new /var/tmp/printcap file. Keep the original printcap by renaming it to /etc/printcap.orig. You must stop Lpr temporarily while you do this.
Stop the running Lpr:
# /etc/init.d/lpr stop |
Save the old printcap:
# mv /etc/printcap /etc/printcap.orig |
Install Magicfilter's printcap:
# mv /var/tmp/printcap /etc/printcap |
Start Lpr:
# /etc/init.d/lpr start |
That's it! Try printing from an application that produces ASCII code and one that produces PostScript. The 'Emacs' editor does both. 'Print' sends ASCII output to the spooler and 'Pretty-print' sends PostScript.
It worked for me! I hope it works for you.