I wanted to pretty print my labels on my (new) Dymo 400 label writer. All the howtos I found were detailing how to use LaTeX to print a sheet of labels. But I needed some LaTeX-foo to print only one. So /me to the rescue…

My labels are 36mm X 89 mm (Dymo part #99012) after some trial and error and four misprinted labels I came to the following LaTeX code which fits the text on the labels:

\documentclass{memoir}
\setstocksize{36mm}{89mm} %% dymo 99012 paper
\setlength{\headheight}{0mm}
\setlength{\headsep}{-28mm}
\setlength{\textwidth}{72mm} %% -17 mm
\setlength{\textheight}{28mm} %% -8 mm
\setlength{\oddsidemargin}{-16mm}
\setlength{\parindent}{0mm}

\begin{document}
...
\end{document}

For the actual text on the labels I use the following code (this should be placed at the dots (…) in the code above.

\sffamily
\textbf{My title}

\qquad The Author \\

\qquad\textbf{Genre} \\

ISBN: \textbf{9-785170-271955}\hfill2008

This LaTeX code is created by a little Perl script:

#!/usr/bin/perl
# labelfmt
# format bib db so that we can print labels
# gets standard sqlite text input:
# 663|9785170271955|Wat 3a Warom (russisch)|B. Barhep|computer|1998|1221413368|

use strict;
use warnings;
my $labelfile = "/tmp/label";

$_ = <>;  # only read one label at the time

my ($id, $i, $tit, $a, $g, $y) = split /\|/, $_;

# format the isbn number a bit
my @i = split //, $i;
local $"="";
$i = $i[0] . "-" . "@i[1..6]" . "-" . "@i[7..12]";

open TEX, ">", $labelfile . ".tex"; # yes, unsafe
select TEX;

print <<'EOF';
\documentclass{memoir}
\setstocksize{36mm}{89mm} %% dymo 99012 paper
\setlength{\headheight}{0mm}
\setlength{\headsep}{-28mm}
\setlength{\textwidth}{72mm} %% -6 mm
\setlength{\textheight}{28mm} %% -6 mm
\setlength{\oddsidemargin}{-16mm}
\setlength{\parindent}{0mm}

\begin{document}
\pagestyle{empty}
\sffamily
EOF

printf "\\textbf{%.30s}\n\n", $tit;
printf "\\qquad %.30s \\\\\n\n", $a;
printf "\\qquad\\textbf{%.30s} \\\\\n\n", uc $g;
printf "ISBN: \\textbf{%s}\\hfill%d\n", $i, $y;

print '\end{document}', "\n";
close TEX;

# now we make the pdf - after we clean up, the mess
if (system("pdflatex $labelfile") != 0) {
warn "Er ging iets falikant verkeerd";
} else {
unlink $labelfile . ".log", $labelfile . ".aux";
}

This will yield the following result

Example Label