Hack26.Integrate Windows Printing with CUPS


Hack 26. Integrate Windows Printing with CUPS

CUPS is not just a great solution for Linux and Unix printingit can also easily handle your Windows printing needs.

As we all know, it's important to be able to play nicely with Windows systems in today's academic and business environments. This may be philosophically unattractive to many of us, but it's a reality. While printing from Windows systems to Linux print servers is often done using Samba (leveraging the standard SMB/CIFS networking protocols), you may not want to set up Samba on every desktop for which you're responsible. Luckily, Microsoft's quest for proprietary standards hasn't eliminated their support for remote printing using other standard protocols, such as HTTP, which CUPS is happy to support. This hack explains how to configure Windows systems to print to remote CUPS print servers using the standard HTTP protocol.

3.8.1. Configuring Printing from Windows 2000/XP Systems

It's really quite easy to configure a Windows 2000 or XP system to print to a remote CUPS printer. First, select the standard "Add printer" icon from the Printers folder in the Control Panel. Specify that you want to create a remote printer, and enter a URL of the following form: http://name-or-address:631/printers/printer-name (as shown in Figure 3-11, which shows the Windows 2000 printer configuration dialog).

Figure 3-11. Specifying a URL in the Windows 2000 Add Remote Printer dialog


Continuing with the example used in the previous CUPS-related hacks in this book, I've entered the URL http://192.168.6.245:631/printers/epsoncolor200. Figure 3-12 shows the equivalent dialog under Windows XP.

Figure 3-12. Specifying a URL in the Windows XP Add Remote Printer dialog


Some combinations of Windows systems and CUPS versions require that you specify a hostname rather than an IP address in a printer URL. If your remote print server has a fixed IP address, the easiest way to do this is to create an entry in the Windows hosts file that maps the IP address to a hostname. This is the file C:\WINNT\system32\drivers\etc\hosts on Windows 2000 systems, and the file C:\WINDOWS\system32\drivers\etc\hosts on Windows XP systems. For example, adding an entry like 192.168.6.245 printserv to this file would enable me to specify the URL http://printserv:631/printers/epson-color200 for the remote printer.


Click Next to proceed with configuring the remote printer connection. Because you are connecting to a remote printer, you may see a dialog like the one shown in Figure 3-13. This dialog demonstrates that the Windows system is able to contact the remote print server, since the warning message displays the name of the print driver as known to the remote print server. To satisfy Windows, you can either choose an installed print driver from the subsequent dialog or locate the print driver on the Web or on the CD that accompanied your printer purchase.

Figure 3-13. Windows 2000 Print Driver Request dialog


3.8.2. Server-Side Configuration for HTTP Printing

Once you've finished configuring the printer on the Windows system, you'll need to make a few modifications to the CUPS printer configuration files on your print server. Because the files you print are being preformatted on your Windows system, and you are using the HTTP protocol, you will need to configure the CUPS server on the Linux system to which the printer is connected. You will need to modify two configuration files to tell the CUPS server how to handle raw data files received via HTTP, configuring it to send those files directly to the specified print queue with no local formatting.

First, edit the file /etc/cups/mime.types, which defines valid Multipurpose Internet Mail Extensions (MIME) formats that are supported by the CUPS server. MIME defines a variety of formats that one might encounter on the Internet (such as in a web browser or in HTTP communications) and defines how MIME-aware applications should handle them. To enable printing via HTTP, remove the hash mark (#) at the beginning of the following line:

 #application/octet-stream 

Without the leading comment character (the hash mark), this entry tells the CUPS print server that raw data streams are an acceptable input format. Next, edit the file /etc/cups/mime.convs, which defines the types of conversions that the CUPS server should perform on various MIME input formats. To enable printing via HTTP, remove the hash mark at the beginning of the following line:

 #application/octet-stream application/vnd.cups-raw 0 

As with the change to the /etc/cups/mime.types file, removing the comment character from the beginning of this line tells the CUPS server to handle input files in application/octet-stream format by passing them to a CUPS application that simply inserts them into a print queue without doing any local formatting.

3.8.3. Troubleshooting Windows Printing to CUPS Servers

The most common cause of being unable to print to a CUPS print server is that the printer is not configured to accept print jobs from your host's IP address. For more information about this, see the section "Enabling Remote Printing on the CUPS Server" in "Create a CUPS Print Server" [Hack #24]. If you're sure that this is not the problem, check the CUPS logfiles. The CUPS print servers maintain three logfiles that can provide a variety of information about attempts to access or use them: access_log, error_log, and page_ log. Of these, the access_log and error_log files are the most useful for diagnostic purposes. Examining the end of these files after attempting to print but not receiving any output usually shows meaningful error messages. For example, if you forgot to update the MIME files and are trying to print to a CUPS printer from Windows, you may see messages like the following:

 E [05/Sep/2005:17:55:49 -0400] get_job_attrs: job #0 doesn't exist! E [05/Sep/2005:17:55:49 -0400] print_job: Unsupported format 'application/   octet-stream'! I [05/Sep/2005:17:55:49 -0400] Hint: Do you have the raw file printing rules   enabled? 

These messages should help you identify the problem and suggest a fix.

3.8.4. See Also

  • http://www.cups.org/documentation.php

  • "Create a CUPS Print Server" [Hack #24]

  • "Share Files Across Platforms Using Samba" [Hack #60]



Linux Server Hacks (Vol. 2)
BSD Sockets Programming from a Multi-Language Perspective (Programming Series)
ISBN: N/A
EAN: 2147483647
Year: 2003
Pages: 162
Authors: M. Tim Jones

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net