Hack 95. Print to Unsupported Printers
Use a Windows machine as a print server, when you can't print from Linux. Linux's support for printers increases with every passing day; the team at http://linuxprinting.org and the army of software developers building free drivers for new printers do a sterling job. However, printers are still on the market (and new ones are being released each day) that Linux does not support; no driver is available, so Linux users cannot print to these unfortunate devices. This problem has no direct solution, but if you find yourself in this situation and you can attach your printer to a Windows machine, you can hack a solution. Under normal circumstances a printer connected to a Windows machine can be used by Linux (via Samba). But this doesn't work when a Linux printer driver is not available. This hack delivers an interesting solution to this problem. It uses a generic printer driver on Linux to send a PostScript print job to a Windows machine sharing the printer. The Windows machine interprets the PostScript using a local copy of Ghostscript, which then sends the information to the Windows printer driver and on to the printer. 11.5.1. How Printing WorksThe normal process of printing from Linux to a supported shared Windows printer is as follows:
This hack changes this process a little by adding a couple of extra steps. After it has been set up, the process works like this:
Because steps 4 and 5 are where the magic happens, the rest of this hack covers setting up Ghostscript as a pseudoprinter. 11.5.2. Creating a Redirected PrinterThe first step in getting the redirected printer working is to install GhostScript and some supported programs on Windows. Download and install the following programs:
GSview is sometimes packaged with Ghostscript, so you might not need to install it separately. Within the directory containing gsprint.exe (C:\GS\GSVIEW, by default), create the file gsprint.cfg with the following content: -noquery -color -printer windows_printer_name -ghostscript "C:\GS\GS8.14\BIN\GSWIN32C.EXE" You can remove the -color line if you are using a black-and-white printer. The path in the last line should be the actual path to gswin32c.exe. The line windows_printer_name must exactly match the name the real Windows printer has in the control panel. Be careful about spaces; there must not be any trailing or leading spaces on any of the lines, and there must not be any blank lines in the file (including at the end). Next, create a new printer in the control panel that uses the Apple LaserWriter II driver (this driver is for a PostScript printer). This PostScript printer is necessary, because your Linux box knows how to print to PostScript printers, but not to your Windows printer; next, you'll set up the PostScript printer so that it passes documents sent from your Linux box on to Ghostscript. View the properties of the just-created PostScript printer, click Add Port on the Ports tab, and select "Redirected port" (this option appears only once you install the RedMon utility). Call the port RDR1: and click OK. Click Configure Port and enter the following settings:
After saving the details, go back to the Ports tab of the PostScript printer's properties and set the Port to be RDR1:. Now print a test page to the PostScript printer; it should print out of the real printer. The print job that is sent to the PostScript printer is being sent on to Ghostscript (the printer is "redirected to a program," as noted in the previous table), and then Ghostscript prints the job to your Windows printer, because it was configured to do so (when you put the name of the Windows printer in gsprint.cfg). The printer should be available to all users; to do this, you need to copy the settings in the registry that define the printer from your user account to the default user account. Export the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices from RegEdit to a file. Edit the exported file, and change the line [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices] to [HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Devices]. Save the changed file, and double-click it to load it into the registry. Finally, go back to the PostScript printer's properties, choose Ports, select RDR1: and Configure Port, and uncheck Run as User. Now share the PostScript printer with a short share name (less than eight characters). Remember this name: you'll need it shortly. 11.5.3. Printing to the New PrinterOn the Linux machine, set up the printer as you would normally set up
a Windows printer. For example, under GNOME, in the Printers window,
click Add Printer Under KDE, select "SMB shared printer (Windows)" from the KDEPrint Add Printer wizard, and enter the details as for GNOME. Again, select the printer type as an Apple LaserWriter II or a generic PostScript printer. Now your Linux applications should be able to print to the printer successfully! For more information and details, take a look at http://mywebpages.comcast.net/heretrythis/hp3100/psemunt.html. Stuart Langridge |