[X2go-Dev] SOLUTION: A generic way to print to cheap GDI-only printers (not only with X2Go)

Stefan Baur newsgroups.mail2 at stefanbaur.de
Wed Dec 21 00:37:33 CET 2011


Hi List,

since I've had issues getting client-side printing to work (which I need 
for low-budget printers that don't support PCL/PS), I built my own 
work-around.

The following is an explanation on how to turn every printer that is 
connected to a Windows client into a printer that can be accessed with 
CUPS, regardless of the print protocol it speaks. IOW: If it can print 
from Windows, it can now print from CUPS as well, as long as it's 
connected to a Windows box.

The advantage over using the X2Go built-in solution is that you don't 
even need a running X2Go client on the particular box - say, in a small 
two-person office with only one (low-budget inkjet) color printer, with 
the X2Go user wanting to print something in color, but the pritner is 
connected to the other machine, and the co-worker currently isn't using 
X2Go.

Requirements:

On the client computer:
* RedMon - http://pages.cs.wisc.edu/~ghost/redmon/
* Sumatra PDF viewer - 
https://kjkpub.s3.amazonaws.com/sumatrapdf/rel/SumatraPDF-1.9-install.exe
* fixed IP or DNS entry, proper gateway setting if server and client are 
located in different networks
* Windows 2K or XP, and installation media / extracted service pack files
   OR Windows Vista / 7  *and lots of patience*

On the server:
Any recent CUPS server with CUPS-PDF installed

---------------

Preparing the Server:
---------------------
Log in as root (or run this prefixed with sudo)
lpadmin -p "CLIENTNAMEHERE_LPD" -v 
"lpd://CLIENTDNSNAMEORIPHERE/PDFQueue" -D "Generic Printer" -L 
"CLIENTNAMEHERE" -E -m "lsb/usr/cups-pdf/CUPS-PDF.ppd"

(everything on one line, substitute clientname and IP where required)

---------------

Preparing the Client (Windows 2K/XP):
-------------------------------------

1) Go to Control Panel/Software, Windows Components and install the LPD 
Print Service (this may require you to insert installation media or 
point Windows to the folder with the extracted service pack files)

2) Check the Services - The TCP/IP-Print Service should be running and 
set to start automatically - if not, change it so it does.

3) Download and install RedMon (see above - it's available in several 
languages, choose the one that suits you best)
Be sure to unzip all the files to %ProgramFiles%\RedMon before 
installing - redmon doesn't do that by itself when you install it, and 
we need some files from that directory later on

4) Download and install Sumatra PDF. Do not set it as your default PDF 
viewer unless this is really what you want. Most users will prefer to 
use Adobe Reader as the default viewer.

5) Install a new printer:
Local Printer, do not scan for PnP devices
Create New Port,
Redirected Port,
RPT1,
Manufacturer: Generic*, Type: Generic/Text Only, Name: "PDFQueue". 
Double-check that it is not set as the standard printer (or you will 
create an infinite spooler loop), do not share it, and do not print a 
test page.

*If you can't find "Generic" or "Standard",
press "Windows Update", if that still doesn't help,
pick a common printer model like a HP Color LaserJet.

6) Double-Click the newly created printer Go to Properties, and pick the 
"Ports" tab.
7) Configure the RPT1: port. Choose
Redirection Program: C:\Program Files\Redmon\redrun.exe
"Program handles Output"
Run: "Hidden"
C:\Program Files\SumatraPDF\SumatraPDF.exe -print-to-default 
-exit-on-print %1

Note that you have to type the language-specific path in *both fields*, 
say, "C:\Programme\" on a German Windows - substituting %programfiles% 
doesn't work.

8) add a Firewall exception for Port 515 (may or may not be necessary - 
if your CUPS server complains that it can't connect and keeps retrying, 
try the firewall rule)

---------------

Preparing the Client (Windows Vista/7 - not for the faint of heart):
--------------------------------------------------------------------

1) Go to Control Panel/Software, Windows Components and install the LPD 
Print Service (this may require you to insert installation media or 
point Windows to the folder with the extracted service pack files)

2) Check the Services - The TCP/IP-Print Service should be running and 
set to start automatically - if not, change it so it does.

3) Download and install RedMon (see above - it's available in several 
languages, choose the one that suits you best)
Be sure to unzip all the files to C:\Program Files\RedMon before 
installing - redmon doesn't do that by itself when you install it, and 
we need some files from that directory later on

4) Download and install Sumatra PDF. Do not set it as your default PDF 
viewer unless this is really what you want. Most users will prefer to 
use Adobe Reader as the default viewer.

Attention users of Windows Vista or Windows 7:
You need to run cmd.exe with an administrative account and use the 
following command to start the "Add Printer Wizard" *from within that 
cmd session* to make this work!
rundll32 printui.dll,PrintUIEntry /il

5) Install a new printer:
Local Printer,
Create New Port,
Redirected Port,
RPT1 (If this fails with an error message and you're on Vista/Win7, you 
didn't pay attention to what I wrote above),
Manufacturer: Generic, Type: Generic/Text Only, Name: "PDFQueue". 
Double-check that it is not set as the standard printer (or you will 
create an infinite spooler loop), do not share it, and do not print a 
test page.

Attention users of Windows Vista or Windows 7:
Do *not* double-click on the newly created printer, rather, double-click 
the printer named "Microsoft XPS Document Writer".
(There is no way to open the PDFQueue printer with admin privileges, and 
attempting any change to the RedMon settings will result in an error 
message when pressing OK/Apply)

6) Click on "Printer", "Open as Administrator", then click on "Printer" 
again, select "Properties", and pick the "Ports" tab.

7) Configure the RPT1: port. Choose
Redirection Program: C:\Program Files\Redmon\redrun.exe
"Program handles Output"
Run: "Hidden"
C:\Program Files\SumatraPDF\SumatraPDF.exe -print-to-default 
-exit-on-print %1

Attention users of Windows Vista or Windows 7:
Be sure to re-select "XPSPort:" for the "Microsoft XPS Document Writer" 
after you're done (or you will disrupt printing to this printer).

8) In contrast to the Windows XP installation, I did not have to change 
firewall settings. YMMV.

---------------

Test:

Printing to the CLIENTNAMEHERE_LPD printer should result in a spool file 
ending up in the PDFQueue on the client, which disappears again shortly 
after, another spool file in the queue of your default printer on the 
client, which also dissapears again shortly after, and a print job 
coming out of your default printer.

---------------

Comments welcome, and if somebody decides *where* in our wiki this 
should go, I'll be happy to add it there with proper formatting.

Kind Regards,
Stefan

PS: I'd still be interested in knowing what's currently going wrong with 
the X2Go-client's built-in printing support on Windows (see my post at 
https://lists.berlios.de/pipermail/x2go-dev/2011-December/003133.html). 
Should be way less of a hassle to configure once it works.



More information about the x2go-dev mailing list