My Dymo label writing process

This page contains raw notes and/or untested notes. They may be incorrect, parts may be missing or the article may contain parts that are not needed and more. An update will probably follow some day.

To print labels on my Dymo, I'm running a custom built webapp that allows users in the entire network to print. It has a memory, prints KIX-codes (that make it easier for the postal service to process letters) and prints a logo.

In my setup, the server generating the logo and the server printing it are two different machines. But even if they weren't, this method keeps the webserver in its SELinux confinement.

Requirements

We need some tools, install the packages with the following command:
yum install ripmime

Add the printer to CUPS

Add the printer to CUPS, so you can spool jobs to it. I'm not explaining this part.

Generate a label

Using PHP's GD extensions I generate a new image with width=1010 and height=540. Using this high resolution results in good quality prints.

The image is exported as a .png file, named [something-random].dymo.png and transported to the printserver through a special email-address.

Prepare the mailserver

I'm running a Postfix mailserver. This mailserver has a special address that accepts print jobs, extracts the files and prints them.

In /etc/postfix/master.cf, add the following lines:

printer unix  -       n       n       -       -       pipe
  flags=F  user=nobody argv=/etc/postfix/bin/printserver $sender $recipient

Then in /etc/postfix/transport, we put:

printer.geeklab.info    printer:

The domain printer.geeklab.info doesn't necessarily need to exist, as long as you smtp right to this mailserver.

Finally in /etc/postfix/main.cf we enable the transport maps, if that hasn't been done before:

transport_maps = hash:/etc/postfix/transport

Write a script

In master.cf we start the script /etc/postfix/bin/printserver. Add this content to said script:

#!/bin/bash
TMPDIR=/var/spool/mailprinter/$$_${RANDOM}_${RANDOM}
MESSAGE_FILE=${TMPDIR}_the_message
mkdir -p $TMPDIR
cat > $MESSAGE_FILE
ripmime -i $MESSAGE_FILE -d $TMPDIR
for i in ${METAMAIL_TMPDIR}/*.dymo.png; do
lpr -PDymo -o PageSize=w167h288 -o landscape -o page-left=0 -o page-top=0 -o page-right=0 -o page-bottom=26 -o orientation-requested=5 -o scaling=100
done
rm -rf $MESSAGE_FILE $TMPDIR

Manage SELinux settings

The script we just write uses ripmime and lpr and runs as the Postfix pipe user. To allow the Postfix pipe program to use these tools, run postfix_pipe_t in a permissive state:
semanage permissive -a postfix_pipe_t
Always remember to manage SELinux, not disable it.

Ubuntu/Debian

I'm running RedHat-based software on all of my machines. Above information may be useful for Ubuntu/Debian users, but it's not tested and I'm not supporting it.

Servers: RedHat Enterprise Linux/CentOS is more suitable for servers, as there's a lot of professional level support available. I think that's important, because if I say, get a car accident, I want the servers to be managable by another professional.

Desktops/Laptops: RPM packages are pretty exchangable between RedHat-based platforms. That's a good reason to run Fedora on the desktop.
© GeekLabInfo My Dymo label writing process is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

CUPS ERROR: Unable to write raster data to driver!

On my CUPS server, I've connected a Dymo 400 labelwriter. For some reason, while printing labels perfectly, I just can't get the imagetoraster filter to stop "crashing" with the following error:
ERROR: Unable to write raster data to driver!

So I fixed this the dirty way. I downloaded the CUPS Source RPM from CentOS. I installed it to /usr/src/redhat using the command rpm -i cups-1.4.2-35.el6.src.rpm. In the directory SOURCES, I added a file named geeklab.patch containing:

--- cups-1.4.2/filter/imagetoraster.c   2009-06-05 23:38:52.000000000 +0200
+++ cups-1.4.2/filter/imagetoraster.cpatched    2011-10-21 11:18:28.427271405 +0200
@@ -1197,7 +1197,7 @@
                fputs(_("ERROR: Unable to write raster data to driver!\n"),
                      stderr);
                cupsImageClose(img);
-               exit(1);
+               exit(0);
              }
             }
          }
@@ -1293,7 +1293,7 @@
               fputs(_("ERROR: Unable to write raster data to driver!\n"),
                    stderr);
              cupsImageClose(img);
-             exit(1);
+             exit(0);
            }
 
            /*
@@ -1333,7 +1333,7 @@
                fputs(_("ERROR: Unable to write raster data to driver!\n"),
                      stderr);
                cupsImageClose(img);
-               exit(1);
+               exit(0);
              }
             }
          }

Then I added to the spec:
Patch700: geeklab.patch
after the line that starts with Patch100:
and %patch700 -p1 -b .geeklab just after the line that starts with %patch100

Now you can use the regular rpmbuild commands to build packages:
rpmbuild -bs <specname> to build a new SRPM
rpmbuild -ba <specname> to build a new SRPM and binary RPMs
I personally prefer the first, as I mostly use mock to build clean destination RPMs.

© GeekLabInfo CUPS ERROR: Unable to write raster data to driver! is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Unable to connect to CUPS server localhost:631 – Connection refused

On my fileserver, I have printing disabled in Samba but still I get all these messages in the logs:
[2011/12/08 10:18:26.821280, 0] printing/print_cups.c:108(cups_connect)
Unable to connect to CUPS server localhost:631 - Connection refused

I don't want Samba to offer printers. After trying some configurations, I found this made smbd stop trying:

load printers = no
printing = bsd
printcap name = /dev/null
© GeekLabInfo Unable to connect to CUPS server localhost:631 - Connection refused is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading...

Printing from a CUPS server to Windows 7

A colleague of mine has some family issues that require him to be home more often. However, work continues. So he started working at home with a laptop. Nothing special about that. What is special, is that we're running a piece of software ("RR") that has old-style telnet-like terminals, which is sending it's print jobs straight to the printer.

His laptop has a direct VPN connection to the company network, but his printer doesn't.

Network info

The old software ("RR") is running on a pretty new RHEL 5.6 installation. It uses CUPS to queue and deliver print jobs. In my situation, the RR printer has zero printers configured, there's another Linux server that has all printers configured and broadcasts those printers over the network. But you could leave that print server out.

Problem

RR cannot reach the printer directly. But it can reach the laptop, which is running Windows 7 Professional. I searched for an IPP server that I could install on Windows, so that the printserver could use that to relay messages to the local printer, but I couldn't find any.

Solution

Windows 7 still has the option to install an lpd server. It's not installed by default, but it's very simple to install.

Windows setup:

  • In the Windows 7 Control Panel
  • Go to the "Programs and Features"
  • Click "Turn Windows Features on or off"
  • Turn on the LPD protocol.
  • Now go to the "printers" and share all printers you want to share.
  • Don't use long names and names with spaces, like "HP Laserjet 4200 Series", which are hard to setup on the client. Use something short like hplj4200.

Client setup:
Now you can setup the client to print to lpd://[ip-or-hostname-of-client]/[printername], for example lpd://10.10.10.17/hplj4200

If you can't get it to work, please check printer permissions and the firewall of the Windows 7 machine, which must have port 515 open.

© GeekLabInfo Printing from a CUPS server to Windows 7 is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.00 out of 5)
Loading...