Using a Raspberry Pi to put a legacy printer on the network
New Life
Niche hardware from the olden days does not always embrace the network. Attaching a Raspberry Pi or other single board computer can add lots of new functionality.
I inherited a DYMO 400 label printer that has a simple USB connection, but it has recently lost the Windows support lottery. My goal was to convert this old standalone label printer (Figure 1) into a network label printer that all the computers on my network can access. Linux users often chafe at the need to replace hardware that is still functioning perfectly well, so keeping an old printer going is a problem that many of us have faced in the past. In this case, it actually appears that the old version of the printer might function better than the newer model (see the box entitled "DRM Woes"), so I'd prefer to keep using it.
DRM Woes
The DYMO company is still in business and sells a newer version of this printer, but the new version is less of a bargain than their older model. The older DYMO 400 and 450 can accept both DYMO official labels as well as generic labels. The newer 550 model has been engineered with digital rights management, preventing users from printing generic labels. This is apparently by design, according to their documentation [1]:
"The LabelWriter 550 series of printers work only with Authentic DYMO LW labels. Non-authentic DYMO labels will not be recognized by the printers."
This seems to be a rather shabby trick to play on their customers, but electronics is not magic, and solutions to most problems do exist if you are willing to invest enough time. One such solution exists on GitHub [2] to allow generic labels to be used with the DYMO 550; it was developed within a few months of the DYMO 550 being launched.
This solution is a I2C device to deal with the DRM recognition. Although this might be a great option for the technical do-it-yourselfer, most business people will not purchase a microcontroller, compile the code, flash the microcontroller, and solder it to their printer. Keep in mind, also, that hacking your way around DRM is illegal in some jurisdictions. Better to keep the old hardware going if you have the option.
The Linux ecosystem is a rich and mature environment with all sorts of programs and utilities that cover almost any situation, but back in the 1990s, printing support in Linux was fairly limited due to the large number of standards and protocols and the lack of Linux-specific drivers. In 1999, Easy Software Products saw this defect/opportunity and created the Common UNIX Printing System (CUPS). The CUPS solution basically turns the computer running it into a print server.
More importantly, CUPS provides a single standard that can handle many printers and protocols. CUPS was released in 1999 and was adopted by many Linux distributions. The CUPS printer service was quite successful for its time, but it could only support printers that had CUPS drivers, as well as the few printers with native support for Postscript.
In 2002, Apple was working on OS X, and, like every other operating system, it needed printing support. Apple decided to buy rather than build. Apple first licensed CUPS from Easy Software Products in 2002, but, after a few short years, they purchased the CUPS source code [3] and hired the lead developer Michael Sweet. CUPS is still used by Apple to support printing on all of their operating systems.
Apple owning CUPS might seem like a problem for the open source community, but that was not the case. Early Linux printing was difficult due to the number of different standards and protocols, but more importantly, Linux did not have a very large install base. Apple computers provided too large of a market segment to ignore, so printer companies started to provide printer drivers for Mac OS X. These drivers did not directly support Linux, but there was a great workaround. The workaround was to download the Mac driver and extract the PPD file and then test it to see if it worked for your specific printer. In many cases, this approach seemed to work. Since then, it has become much easier to find the PPD files for many popular printers [4].
No relationship is perfect, and the hundreds of improvements that Apple has committed to Git have slowed down to a trickle since 2020 [5]. CUPS was no longer progressing. The CUPS code was eventually forked and is now maintained by the Linux Foundation's OpenPrinting project, which serves as the upstream source for Apple's CUPS [6] .
Raspberry Pi Networking
One of the really forward-thinking design decisions built into CUPS is that it uses a web browser for the user interface (Figure 2). A browser interface makes it easier for CUPS to run on many different platforms big or small, and that means the Raspberry Pi is just as capable as a full-sized server.
Coupling a DYMO label printer with a Raspberry Pi will make it a true network printer. I will also be able to add a queue to buffer if too many labels are printed at once. CUPS does all the hard work; it is just a matter of installing and configuring everything. Setup only takes a few minutes.
The first step might not even be necessary, depending on which Linux distribution you are using. It was not necessary to install CUPS on either Mint or on Raspberry Pi OS, but for a Debian-based distribution the command is:
sudo apt-get update && sudo apt-get install cups cups-client
If CUPS was not installed previously, you will also probably want to set up CUPS to start automatically when the system starts (see the sidebar entitled "In systemd"). Once CUPS is installed and the DYMO label printer is attached, you should verify that the operating system recognizes it. You can use the lsusb
command to verify, or you can skip directly to the CUPS lpinfo
command to display what devices are available. In my case, the lpinfo
command displays both the DYMO LabelWriter 400 and my HP printer (Listing 1).
In systemd
If CUPS was not previously installed, you will probably want to configure CUPS to start when the computer is started. Raspberry Pi OS uses systemd, so the systemctl
command is used to manage processes.
To enable CUPS at startup:
sudo systemctl enable cups
To restart CUPS:
systemctl restart cups.service
To stop or start CUPS:
systemctl stop cups.service systemctl start cups.service
Listing 1
lpinfo
$ lpinfo -v direct usb://DYMO/LabelWriter%20400?serial=07000619355405 file cups-brf:/ network beh network ipp direct vnc:/ network socket network ipps direct hp network http network lpd network https direct hpfax network dnssd://HP%20Color%20LaserJet%20Pro%20M478f-9f%20%5BD7422C%5D._ipp._tcp.local/?uuid=b69de7ee-8055-5cc9-c1d0-526e9f44a5a5 network ipps://HP%20Color%20LaserJet%20Pro%20M478f-9f%20%5BD7422C%5D._ipps._tcp.local/ network socket://192.168.178.43:9100
You can install the DYMO printer while installing the CUPS software. But if you are feeling cautious, you can do each step separately.
sudo apt-get install printer-driver-dymo
This DYMO package does not actually add any drivers or programs but instead supplies a lot of defined page formats, which correspond to the labels that you can feed to the printer.
Configure the Printer
Setting up a DYMO printer from the CUPS menu (as shown in Figure 3) doesn't require very much user interaction. From the menu, click on the Administration menu and then click on the Add Printer button. This button will display a list of local and discovered printers; simply select the DYMO from the list.
Clicking on the Continue button will bring up a dialog (Figure 4), allowing you to enter the name of the printer. Initially the printer queue name was DYMO_LabelWriter_400
, which I shortened to DYMO_LW_400
. This is just the local name that you can use to print to from the command prompt. During the setup, selecting the Share This Printer checkbox did not quite have the effect I was looking for (more on this later). Clicking on the Continue button will bring up another dialog (Figure 5), which allows you to select your printer model. These three dialogs are actually associating the printer that was found by CUPS with a user-provided name and model number.
Click on the Add Printer button to create the printer configuration and bring up a final dialog. This final dialog (Figure 6) defines a few settings, with the most important being the label size. My DYMO printer has an address label #99012, which is 89x36mm. This size seems a bit odd for a metric measurement but the size doesn't really look much better when converted to Imperial measurements: 3.5x1.4 inches. Pressing Set Default Options brings you back to the menu.
If you wish to verify that the printer was set up correctly, you can click on the Printers tab of the menu, but a more gratifying test would be to try to print a label. Use the lpstat
command to see all available print queues (Listing 2).
Listing 2
Checking Available Print Queues
pi@smartframe:~ $ lpstat -v device for DYMO_LW_400: usb://DYMO/LabelWriter%20400?serial=07000619355405 device for HP_Color_LaserJet_Pro_M478f_9f_D7422C_: implicitclass://HP_Color_LaserJet_Pro_M478f_9f_D7422C_/
Initially, when I set up this printer, I was hoping that I could print out Internet postage from the German Post Office. It is possible to get a sample label from the German Post Office website [7], which does support the DYMO 99012 label as a PDF. I created a few test labels, which you can download from the Linux Magazine server [8].
The lp
command lets me print a label on the newly defined DYMO_LW_400
printer queue from the command prompt:
lp -d DYMO_LW_400 testlabel.pdf
A more convenient testing method might be to create a document in LibreOffice (Figure 7). The first time I tried to print from LibreOffice, the page size was incorrect. To fix this problem, I selected Use Printer Properties and checked Use only paper size from printer preferences.
If the task was just setting up the printer locally, the process is complete. However, with just a few more small changes, you can make the printer available to the entire network. All of the configuration is in the cupsd.conf
file, which is usually located in the /etc/cups
directory.
CUPS listens only to the localhost on a port for print jobs but can be configured to accept jobs from the entire network. The configuration file has a line that defines a port number for listening on the network:
Listen localhost:631
This new configuration will listen on port 631 and essentially accept any IP address that can reach the printer server.
In addition to enabling network printing, it is possible to enable remote configuration and remote admin support. Each of these tasks has a block in the configuration file (Listing 3).
Listing 3
Configuration File
# Restrict access to the server to local network <Location /> Order allow,deny Allow from @LOCAL </Location>
There are situations where allowing full access to the printer is inadvisable. In those cases, it is possible to limit access to a specific subnet. Adding a partial subnet will limit which computers can access the printer (Listing 4).
Listing 4
Restricting Access
# Restrict access to the server... <Location /> Order allow,deny Allow from 192.168.178.* </Location>
I planned to administer the printer remotely, so I added the "Allow from" statement to both the /admin
and /admin/conf
location blocks. Once I added these small changes, I had to restart the CUPS daemon. If there are any errors in the configuration file, the restart will not work and might display a cryptic message.
Once everything is correctly set up for your network and CUPS has restarted, you can use the lpstat -v
command to see if your printer is visible to CUPS (Listing 5).
Listing 5
lpstat -v
chris@chrismint20:~$ lpstat -v device for DYMO_LabelWriter_400_smartframe: implicitclass://DYMO_LabelWriter_400_smartframe/ device for HP-HP-Color-LaserJet-Pro-M478f-9f-new: hp:/net/HP_Color_LaserJet_Pro_M478f-9f?hostname=HPBCE92FD7422C.local device for HP_Color_LaserJet_Pro_M478f_9f_D7422C_: implicitclass://HP_Color_LaserJet_Pro_M478f_9f_D7422C_/ chris@chrismint20:~$
Direct Printing
When I first decided to use this label printer, it was with the goal of printing Internet postage from the German post office, but I also considered using it for creating and printing out address labels. I thought about writing a small program to print the labels but actually hoped someone might have solved this problem before me. Despite the number of DYMO projects on GitHub, I could not find one that solved my exact problem, even though there were quite a few DYMO label printer projects.
One interesting project [9] was short and contained a fairly concise example of printing complex labels. The label it produces was tailored by its author for a very specific case, but the code did help to illustrate the general Java programming techniques to output to a printer while using different fonts. The effort to create a Java program to print 5 or 6 line labels seemed a bit excessive, considering that I could easily use LibreOffice to create and print labels.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.