print label XML to a Dymo printer on any platform
This app sets up a small web server on port 41951 and accepts POST requests with XML. The XML is interpretted, albeit not perfectly, and rendered to PDF, which is then sent directly to the Dymo print driver.
- Basic text and auto-shrinking text
- Text box solid background colors
- Horizontal lines
- "Verticalized" text
- Rotated text
- Other shapes
- Alpha transparency on background colors
- Multiple font sizes/styles in the same text box (probably not possible)
- Probably other stuff
Some text is not placed exactly the same with this app as Dymo would do it. Dymo and Prawn have very subtle differences in how they render text. Some of those differences have been accounted for, but not all.
If your labels rely on precise placement/alignment of different objects, this solution may not work well for you.
Below are some samples:
These instructions should work on Debian and Ubuntu.
Install some prerequisites:
sudo apt update sudo apt install build-essential openssl ruby-dev libssl-dev cups cups-bsd printer-driver-dymo ttf-mscorefonts-installer
Note: we want
lpr-- do not install the
Add the Tahoma font, which seems to be Dymo's default:
cd /tmp wget https://sourceforge.net/projects/corefonts/files/OldFiles/IELPKTH.CAB cabextract -F 'tahoma.ttf' IELPKTH.CAB sudo mv tahoma.ttf /usr/share/fonts/truetype/msttcorefonts/Tahoma.ttf
Allow your user account to manage printers with cups:
sudo gpasswd -a USERNAME lpadmin
USERNAMEabove with your user, e.g.
piif running on Raspbian.
Add the printer via the Cups admin page:
sudo gem install bundler cd git clone https://github.com/seven1m/dymo-printer-agent.git cd dymo-printer-agent bundle
Generate a self-signed certificate:
openssl req -nodes -new -x509 -keyout ca.key -out ca.crt -subj /CN=localhost -days 3650
Start the printer agent:
cd dymo-printer-agent ruby agent.rb
There is currently a bug in the Dymo printer driver that causes long delays in between printing each label. In another terminal, start the
dymo_speed.rbscript to work around this issue:
cd dymo-printer-agent ruby dymo_speed.rb
My specific use-case for this script was to run it on a Raspberry Pi running Raspbian. I wanted the script to auto-start upon boot of the Raspberry Pi. The following commands will set that up:
echo '@/home/pi/dymo-printer-agent/start_in_lxterminal.sh' >> ~/.config/lxsession/LXDE-pi/autostart echo '@ruby /home/pi/dymo-printer-agent/dymo_speed.rb' >> ~/.config/lxsession/LXDE-pi/autostart
Copyright Tim Morgan
Licensed under the 2-clause BSD license (see the LICENSE file in this repo)