Citation: LPD-Win www.kabelmax.de


What is LPD-Win?

LPD - line printer daemon - is part of the UNIX print system and widely used on almost all UNIX machines. It interacts with the other programs (lpr, lpq, lpc) there. It's job is to recieve and to send printer jobs to and from the local machine to and from the same machine or to and from other machines on a network. And it sends the jobs to the printer device. It uses TCP/IP at port 515 for the communication. The protocol for sending jobs over a network or to a local daemon is described in RFC 1179.

LPD-Win is a WINDOWS implementation of this protocol for Win9x/WinME. Running LPD-Win allowes other (authorized) machines to print at your system. It recieves jobs over network, stores them at the local disk and invokes a program of your choice to print them or sends them directly to a windows printer.

Wile WinNT/2k is shipped with its own LPD service I was asked to make LPD-Win run at NT/2k, too, because it allowes passing the jobs to a command line. So LPD-Win runs at NT/2k, but doesn't register as service (see How to install).

It is intended for user with both UNIX and WINDOWS machines and with a GDI printer which doesn't work (or doesn't work well) with UNIX. It can be used, too, if you prefer lpr instead of SAMBA or if you don't have SAMBA, but a LPR client.

Why?


Why?

There are other ways to print over network.

First WINDOWS is able to do this (using it's own protocol).

For UNIX machines there is SAMBA, speaking the same protocol as WINDOWS, and allows printing at WINDOWS machines too and vice-versa.

But there are "broken" printers.

Some printers have drivers, which doesn't allow network printing (HP DJ 840C for instance). Or they require to install a GDI driver at all machines - which is impossible to UNIX machines. Some still have raster drivers (PCLx or ESC/P emulation) but often with less quality, less resolution or whithout colour management (as the HP or my Canon), many don't have an own emulation and these can't be used with other operating systems (sometimes not even with WINDOWS 2000). And some laser printers offer a PCL emulation for the local host only (if a DOS program writes to LPT1).

Or you don't have SAMBA at your machine. Then LPD-Win allowes using lpr to print to your WINDOWS machine.

To allow the use of this printers with full quality and resolution LPD-Win offers a special way.

How it works


How it works

The use of a GDI printer or PCL software emulation is only possible for WINDOWS programs at the machine the printer is connected to (except the same GDI driver is installed at the other machines too, which isn't possible for UNIX machines or Mac). Sometimes no network printing capability is available at all.

So LPD-Win recieves a file which can be printed using a local program at the machine the printer is connected to. Because LPD-Win should work in the background without user intervention it is neccesary that these files can be printed from the command line. There are a few file formats allowing this:

Adobe Acrobat's PDF files for instance can be viewed with Acrobat Reader at almost all operating systems. There is an (not well documented) command line syntax for printing from the command line for Acrobat Reader.

Adobe PS (Postscript) is widely used for printing. Many professional printers (especially laser printers) come with an built-in Postscript interpreter. But PS can be viewed and printed by the free program GhostScript too (available for UNIX and WINDOWS). And GS can generate PDF files for Acrobat Reader. Of course GS can print from a command line.

Raw files (PS, PCL or so) can be sent to the printer too. Use this if you printer is able to print PS or PCL or so, but you don't have SAMBA at the UNIX machine or prefer lpr protocol. If your printer's driver has a software PCL emulation for DOS programs, you can install a PCL printer at the client and copy the file to LPT1 at the printer's host.

Other file formats can be used if they can be printed from a command line (Word documents!).

It would even be possible to use a common graphics format as BMP, if you have a picture viewer which is able to print from a command line without user intervention. But you must supply them in the right resolution and size, because rescaling/resizing will reduce quality and may cause moirée.

If the file is printed by one of this programs from the command line, all special features of the printer driver (as colour management, picture optimization and full resolution) are used by the local printer driver (it doesn't even know, that the job came over a network).

How to install


General setup

Bring up the window (click at the icon in the icon bar). Choose "File - Setup".

You must enter a spool directory. D: is just an example, change this! The jobs recieved over the network are stored there - for every printer in a separate direcory with the printer name, these are created automatically when neccesary.

Add the IP numbers of the hosts you will allow to print at your machine. Shorter numbers match all IP numbers starting with this entry (so 192.168. will allow printing for all machines with 192.168.xxx.xx or 192.168.xx.xxx and so on). This is very simple made - maybe I add support for host names and wildcards later.

You may change the port LPD-Win is listening on to something else than 515 - you will need this in very special situations only. Make sure this port isn't already in use. You will see debug messages ("Listening" or "Listen failed...") if connection messages are turned on.

Although a timeout isn't defined in the RFC (and the BSD unix implementation doesn't use one) I was told that Netware clients open connections and don't close them. So more and more connections linger around until Win is unusable (!) - that's why I decided to add a timeout function and a limit for connections. Default is 1 minute and 10 connections (should be enough in most situations), change it, if you need to.

If there are problems (hanging connections, print errors or so) you can set up extended logging in the help menu to find out more.

Then you should set up the clients (see Client setup) and the printers (see Printer setup).


Printer setup

Simply set up as many virtual printers as you like. Use "File - Add Printer", and change their settins with "Edit Printer" or double click the entry in the list.

Enter a name (without special characters and without spaces!), and enter the command line for printing below. Use %p for the path of the data file, %d for the file name to print. %c for the control file, %h for the hostname, %u for the remote user name and %f for the remote filename, if supplied by the sender can be used, too (if you need this). They are replaced with path/filename of the recieved files and hostname, username and remote filename  when the job is printed. See details later. Or check "print raw..." and select the desired printer.

To delete a printer, use "File - Remove Printer". (No confirmation request!)

You may disable printing and spooling (recieving jobs) using the checkboxes. You can even enter more than one printer with the same name and activate/deactivate the desired command line with the checkboxes. This could be useful if you have more than one printer and use a printer switch.

To see which printers are available and which port and driver they use you may look in the frame at the bottom. (This is only for your information. Chosing a printer there doesn't affect LPD-Win). To change printer settings there is a button for easy access to window's printer settings dialog.

Finding a proper command line for printing isn't too easy. A WINDOWS printer is specified by 3 parameters: the printer name, the driver type and the port. You'll see this parameters if you launch the printer setup. If a program doesn't offer the possibility to supply thes parameters, the defaults are used.

Examples:

To print PDF using Adobe Acrobat Reader enter a command line like that (without line break!):

"C:\Programs\Adobe\Acrobat 4.0\Reader\acrord32.exe" /t %p\%d "Minolta Quick Page" "Minolta Quick Page" "MLT.GDI"

Or:

"C:\Programs\Adobe\Acrobat 4.0\Reader\acrord32.exe" /t %p\%d "Canon BJC-620" "Canon BJC-620" LPT1:

/t tells Acroread to print and terminate when done.

%p is replaced by the path, %d by the filename of the data file.

The first "Canon..:" is the printer name. The second "Canon..." is the driver type (they are often the same). "LPT1:" is the port.

All has to be entered as one (long) line.

It may work to leave type and port empty and only enter the printer name (it works for me).

If the program's name or path or the printer name contains spaces, you must enclose it in double quotes (as shown above).

To print Postscript using GhostScript I use (without line break):

c:\aladdin\gs6.01\bin\gswin32.exe -sPAPERSIZE=a4 -sDEVICE=mswinpr2 -dNoCancel -sOutputFile="\\spool\Minolta Quick Page" -dQUIET -dNOPAUSE %p\%d quit.ps

Unfortunatly the WindowsPrintingSystem for my Canon crashes when GhostScript sends it jobs, so I can use PDF only for that printer.

See the documentation which comes with GS for details.

You may use batch files too. If you run WINDOWS applications from the batch you should should use "start /w path\program", this causes the batch to wait for its termination. If the batch terminates, LPD-Win will assume everything is done and remove the data file. You should edit the batch's properties (right click in explorer, properties), choose "program" and check the mark "close on exit", if you don't, the window remains open. A sample batch is:

start /w "c:\programme\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" /t %1 "Minolta Quick Page"

and launched from LPD-Win with:

"c:\programme\lpd\batch dir\sample.bat" "%p\%d"

(Notice the double quotes for the path to the program and the batch itself, if the path contains spaces!)

A sample for printing directly (if LPD-Win gets ready-to-print files for your printer) is:

C:\COMMAND.COM /C copy /B %p\%d lpt1:

A better way for that  is to print directly to window's print spooler or a local port. This can be nessecary if you have an USB printer, which can't be reached using a command line, but remember - you need ready-to-print files for the printer! It is useful for real PS or PCL printers with USB interface. It won't work with any cheap GDI printer (except you have a proper UNIX driver for it, as Lexmark Zx2). It may work with laser printers with software PCL emulation , try "local port LPT1:" in that case. If not, try the command line as above! You can select direct raw printing by check "print raw..." and and selecting the desired printer or port below. You can even enter a network path there ("\\host\printer"), but make sure, the host/printer exists and can be used. The command line is disabled in this case.

You should test if the command line work. After adding a printer select it in the printer list, and choose "Job - Add" in the menu. There are three testfiles (PDF, PostScript and PCL), select the one fitting to your command line (Ghostscript or Acrobat or raw/copy to LPT1). If you select other files for a raw printer, they must contain proper binary data for this printer (you can generate such files printing to a file or saving a job file while temporarily disabeling printing). If you send wrong data to the printer it may do nothing at all or produce many white pages with just a few characters at the top of them!

PDF or PS or raw


PDF or PS or raw

Using PS is much easier at the UNIX machine (they usually support Postscript printers in the network without any trouble "out-of-the-box"). It's nice to be able to print Postscript files at your WINDOWS machine too. And setup is very easy. But you must download and set up GhostScript for Windows and it's fonts. And the command line is much longer.

Using PDF is easier at the WINDOWS machine (Acrobat Reader is available at almost all WINDOWS installations and available at many CDs). But you must set up UNIX with GhostScript to send PDF files over the network. While Acrobat Reader is available for UNIX, PDF isn't common as printer file format, so you must see, understand and edit your printer filters and printcap.

If your printer can print PS or PCL, you can use raw printing - but you won't realy need LPD-Win then, except you don't use SAMBA or prefer lpr or your printer has PCL emulation in the driver only.

If you're a UNIX beginner, I would strongly recommand the first way, while if you don't trust GS for Windows, use PDF.

Contact/Copyright


Contact/Copyright

LPD-Win is freeware. No modification without permission.

(C) 09-2000 - 10-2002 Gernot Zander

It was tested using the following clients and printers:

- Linux, apsfilter 2.3, Ghostscript 5.5 for Linux (for PDF files) and Ghostscript 6.01 for Windows (for printing ps) and Acroread 4.0 (for printing PDF) at Canon BJC620, Minolta Page Pro 6ex, Okipage 10ex and Lexmark Z22 (USB and LPT), all at a Win98.

- Linux, CUPS 1.1.15 with lpr backend

- Linux, raw printing at Lexmark Z22 with Linux's driver (sending the GDI data using lpr to LPD-Win), for both LPT and USB connection, raw printing (PCL) to the Minolta.

- Windows LPR client by ACITS (hint: deactivate bidirectional printing and use raw format, not EMF), Windows LPR Spooler by Thomas Heil, LPR-Win (free, at my homepage).

- iMac (there is a lpr in the Desktop Printer Utility since Mac OS 8.1) printing PS directly  to a Laserwriter 630 Pro at the Win's parallel port. (Thanks to Mike Pryer for testing!)

- Win98 clients, Samba at a linux server, LPD-Win at one Win98 client with a HP Laserjet 1000w. The clients are set up with "HP Laserjet 4" and print via Samba to the linux server. This sends the jobs (PCL) via lpr to the LPD-Win, which sends them by "copy ... lpt1:" to the PCL emulation of the HP LJ1000w's driver. Select "Print true type as bitmap" at the clients. Strange, but this way the not network shareable printer can be used in the network!

- Same, but with LPR-Win at the clients, LPD-Win at the workstation with the HP, and "print raw" to its "HP LJ DOS" entry (that's the one with the PCL emulation).

- Linux, apsfilter as above, with HP DJ 840 and LPD-Win at Win ME, raw printing.

- As service with srvany.exe at WinNT 4 (Thanks to Oliver Betz), using an oscilloscope (!) as client.

There may be other lpr clients. I'll be thankful for reports, because the interpretation and implementation of RFC protocols are often different and cause problems.

Contact. hifi@gmx.de

Homepage: www.kabelmax.de

You'll find GhostScript at www.ghostscript.com

See Help/Info also.

If you mail me for problems, it's a good idea to turn on extended logging, save the log and attacht it to the mail.


How to install

Unzip lpd-win.zip in a directory of your choice.

Start lpd.exe with autostart folder or somehow else, as you like. It will look for old, unprinted jobs and read in lpd.ini, where it keeps all the settings. (You may look into this file, but I don't recommand editing it by hand).

LPD-Win puts itself into the icon bar in the lower right corner then. Click on it to bring the window up. Then you can setup, start and stop printers, see a log and the spooled, unprinted jobs. You may delete them (except jobs in progress). If you're done, minimize the window (don't close it, LPD-Win would exit then) and it disappears in the icon bar again.

No setup program is required, no changes to the registry are made.

To remove it simply delete lpd.exe, lpd.ini and the help files.

How to setup

Install at WinNT/2k

If you wish to use LPD-Win at WinNT/2k it doesn't register as a service process and will be terminated if the user loggs off. Unfortunatly I don't have the proper developement environment for NT/2k to compile service processes, but there is another way: At Microsoft's CD you'll find in three programs in the Ressource Kit: srvinstw.exe, instsrv.exe, srvany.exe. With these programs you can make any program run as a service, and so LPD-Win. The procedure is described at Microsoft's support pages at Q137890. For LPD-Win it should be done like this:

1. Log on as admin.

2. Install instsrv.exe and srvany.exe somewhere into the search path (system directory), if not there already.

3.Open up an MS-DOS command prompt.

4.Type the following command: INSTSRV lpd-win SRVANY.EXE

5.Open up the Registry Editor (Click on the Start Button, select Run, and type REGEDIT) .

Locate and highlight  the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lpd-win

From the Edit menu, select New, select Key, and name the new key "Parameters".

Highlight the Parameters key.

From the Edit menu, select New, select String Value, and name the new value "Application".

From the Edit menu, select Modify, and type in the full path to LPD-Win, including the drive letter and file extension.

Example: "D:\Program Files\lpd-win\lpd.exe"

6.Close the Registry Editor.


Client setup

The clients must use the lpr protocol to print. Usually you will have unix clients, but there are lpr clients for Windows or Mac too. WinXP and 2k comes with lpr capability, as far as I know.

The client must know the name or IP number of the remote host (the machine running LPD-Win) and the remote printer name, this is usually done in /etc/printcap (if you use a lpr client with windows there will be a setup where you can enter this).

And it must prepare the file in the desired format, this is done either by invoking a filter ("if"-entry in printcap, invoking ghostscript or so) or the application sends the data in the desired format already.

Here a few examples for linux/lpr:

1. The application sends the data in the desired format (PostScript - if you use GhostScript at the windows machine, or PCL - if you print raw at the windows machine, or equal):

/etc/printcap:

wings:\

:rm=your_win_machine:\

:rp=your_LPD-Win-printer-name:\

:sd=/var/spool/wings:\

:af=/var/spool/wings/acct:\

:lf=/var/spool/wings/log:\

:mx#0:\

:sh:\

:sf:

This can be done by common system managers as YaST. Simply choose any (colour) PS printer in your application, HP Laserjet XX PS or - for colour printing - NEC Colormate PS or so. Tell YaST or so that the printer is remote (so no "lp="-entry, but "rm=" and "rp="), or change this yourself later.

If you use the raw printing, you must set up everything as if the printer was locally connected (except the "rm=" and so on), choose the right printer model, (maybe you will need an "if=..." entry to invoke gs, but with "-sDEVICE=ljet4" or so, if your application sends PostScript and you want GhostScript to convert this to your printer's raw data format).

2. The application sends PostScript, and you use GhostScript to convert to PDF, and you use Acrobat Reader at the windows machine, apsfilter is used to invoke GhostScript:

/etc/printcap:

winpdf:\

:rm=your_win_machine:\

:rp=your_LPD-Win-printer-name:\

:sd=/var/spool/winpdf:\

:af=/var/spool/winpdf/acct:\

:lf=/var/spool/winpdf/log:\

:if=/usr/lib/apsfilter/filter/aps-pdf-a4-ps:\

:mx#0:\

:sh:\

:sf:

Set up that the printer is remote (so no "lp="-entry, but "rm=" and "rp=").

Apsfilter must be changed, a new entry for printing PDF could look like this:

case $PRINTER in

...(your other printers)

pdf)	gs\

-q\

-dQUIET\

-sPAPERSIZE=${PAPERSIZE}\

-sDEVICE=pdfwrite\

-dNOPAUSE\

-dSAFER\

-sOutputFile=-\

-

;;

Then link apsfilter to aps-pdf-a4-ps, depending of you location like this:

ln -s /usr/lib/apsfilter/bin/apsfilter /usr/lib/apsfilter/filter/aps-pdf-a4-ps

If you now enter a print command like "lpr -Pwinpdf" for Netscape, xv or other applications producing PostScript, this will be converted to PDF by apsfilter/GS, sent to you WINDOWS machine and printed there using Acrobat Reader.

There are other filtes as apsfilter (magicfilter, for instance), you must find out how to setup them to invoke gs to send PDF yourself.

Printer setup