From LPD to PDF
Introduction
I recently ran into a situation where a legacy billing server needed to redirect its daily print jobs. The current print destination was a network-enabled HP LaserJet printer. The new destination was still in the process of being installed. I wasn’t sure if the new destination would support LPD like the old destination or only a newer protocol such as IPP. The legacy billing server only supports LPD, so I wanted to prepare the environment for the possibility of LPD not being available.
I decided that the best solution, at least for the time being, would be to set up an intermediate server that accepted print jobs from the legacy billing server over LPD, saved them as PDF, and create the ability to send the PDF copies out another printer, if needed.
Table of Contents
- Setting up the Printing Server
- Configuring CUPS to Accept LPD Jobs
- Sending the PDF Files Back Out
- Conclusion
Setting up the Printing Server
The intermediate printing server is just an Ubuntu virtual machine with CUPS installed. The following packages were used:
apt-get install cupsys cups-pdf cupsys-bsd xinetd
Once the packages install, there should be a PDF printer available in CUPS. If not, simply add a new printer through the CUPS admin interface of type PDF.
Configuring CUPS to Accept LPD Jobs
I used xinetd to handle the LPD connections. In /etc/xinetd.d, I created a file called cups with the following contents:
service printer
{
socket_type = stream
protocol = tcp
wait = no
user = root
group = lp
server = /usr/lib/cups/daemon/cups-lpd
server_args = -o document-format=application/octet-stream
port = 515
disable = no
}
Since the PDF printer is the only “locally attached” printer available, CUPS will accept the LPD job via xinetd and send it there for printing.
Several CUPS-PDF options can be specified in the config file /etc/cups/cups-pdf.conf. For example, to save the print jobs to the /var/spool area, I changed the Out config directive to:
Out /var/spool/cups-pdf/${USER}
I would have figured ${USER} was the user LPD was running as under xinetd (in this case, root), but the files are saved under the directory lp. Rather odd, but it’s something I wasn’t going to dwell on too much.
Sending the PDF Files Back Out
Once a proper remote printing destination is installed, I can simply create a new remote printer in CUPS and then send all PDF files in the spool directory to that new printer. This can easily be done through a shell script and scheduled for once an hour or day.
Conclusion
Legacy servers often create major upgrade roadblocks due to their inability to be upgraded themselves or provide support for newer protocols. Utilizing flexible services such as CUPS and custom scripting can create solutions to work around these roadblocks.

Add A Comment