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...