Posts Tagged “cups”

Once upon a time, there was a company called Cansel that used ERP software that was only capable of printing directly to PCL5 and PCL6 printers. This worked very well for a long time as the company only used popular (HP and Xerox) laser printers that met this criteria.

One day, it was decided that one of the sales staff would be working long-term in a town where we had no office and he would need a small inkjet printer that could run in his car. He would be connecting to the internet using a mobile 3G ExpressCard and the printer would be connected to his laptop by Bluetooth. On his laptop, he would be running the corporate VPN software so that he could access email and use the ERP software to make sales and what not. However, his new special printer only supported PCL3 and nobody had yet determined how he would be printing invoices.

I was asked to look into it and started to examine the inner workings of the printing system in order to find a way. If I did not succeed, the salesman would be emailing himself invoices to print off, which would be an annoying extra step, to be sure.

First I tried making the ERP software print PCL3 directly, which was largely unsuccessful. I could get the template to print cleanly, but as the software was outputting the overlay in PCL5 or 6, I couldn’t get the text to print on the same page or even line up cleanly. There had to be a way to interpret and convert PCL data in much the same way that PostScript can be interpreted and converted to other formats.

After a great deal of searching, Google found me GhostPDL (new name of GhostPCL), which was exactly that–a PCL interpreter and converter. It is to PCL as Ghostscript is to PostScript. I tested this tool with the template files (stored in pcl) and it worked! I could convert a PCL5/6 template to PCL3 directly, or convert it to postscript and have Ghostscript render the PCL3 (seemed to look much nicer this way). I was still stumped, however, about how I would perform this operation on the fly without being able to modify the ERP software.

It was time to investigate the workings of the Common UNIX Printing System (CUPS). Typically, our ERP would print to a raw spool on CUPS which would then forward the raw PCL to a network-capable PCL printer. This new printer was bluetooth and spoke only to the salesman’s laptop. In addition, the salesman was not connected to the internet all the time. It would be hard for CUPS to find the printer each time it needed to spool to it.

First things first, to keep the laptop as secure as possible while allowing the printer to be shared, I installed the Print Services for UNIX component in Windows XP. This runs an LPD server on port 515 which is very easy for CUPS to connect to. That solved the communication issue with the bluetooth printer. However, the system was still only connected to the internet by a mobile 3G card and got a new IP address on almost every connection. I decided to solve this by using DHCP over the VPN connection to reserve the laptop a statically assigned IP address. Every time the VPN client software was running, the laptop would accept LPD connections on the same IP, so CUPS could always find it. This works very well.

Unfortunately, the data was still not being properly filtered to PCL3. This was the most difficult part of the ordeal. CUPS does not have a simple method of adding a filter on a particular print queue. It supports global filters on specific mime types and allows overrides in the print drivers, but no simple per-queue filter. So, I put together a PPD file with an appropriate *cupsFilter line, made some changes to the mime types so PCL was no longer captured under the application/vnd.cups-raw heading and voila (well, not quite that quick, but after a lot of tweaking and testing), things worked.

A number of other little things had to be changed, but they aren’t really worth mention independently.

Presumably the salesman will live happily ever after. At the very least, I’m entertained by this working as well as it has. When the overlay printed smoothly over a perfectly printed template the first time today, I was cheering aloud.

This has been a nerdy moment brought to you by the letters I and T and a lot of acronyms.

;)

Comments 1 Comment »

Disclaimer: The opinions expressed on Litui.Net reflect the personal views of Aron Burrell (litui) and are in no way representative of the views of any of the companies or organizations in which he is involved.