Printing Avery labels with Linux

5492

Author: Michael Stutz

To aid users in the task of label printing, Avery Dennison offers a host of free (to download) software, including a program for the Mac released late last month. Linux still isn’t supported, but that’s no matter — there’s more than one open source application for Linux that lets you format text for printing on the whole universe of Avery labels, from DVD covers to business cards. Here’s a look at them.

LabelNation

One versatile program written for the express purpose of printing on Avery labels is Karl Fogel’s Python-based LabelNation.

It outputs formatted PostScript that you can either save to a file or send directly to the print spooler, if you have a PostScript printer or a print filter that converts incoming PostScript to something that your printer understands. You can print from a database of addresses on a single run, such as for printing a mailing list, and in addition to plain text input it can also take PostScript code — which means you can print labels with graphics.

Once you have it downloaded and installed (just put the labelnation file in /usr/local/bin), you can get a list of its predefined labels with the --list-types option:

$ labelnation --list-types

The latest version, 1.64, understands about 50 different labels, including the most popular Avery sizes as well as the Maco LL5805, LL8100, and LL8550 labels, and the Maverick ST340817.

To make output, you need to give several options. First, give the name of the label you want to use as an argument to the -t option. To read the input text from a file, give the file name as an argument to the -i option, and use the -l option to specify that the file is “line input,” or lines of plain text.

By default, LabelNation writes a PostScript file named labelnation.ps in the current directory. To specify a file name, give it as an argument to the -o option:

$ labelnation -l -i address.txt -t avery-5160 -o address.ps

To print out a batch of mailing-list labels, use the -d option to specify the delimiter used between addresses in the input file. Be sure to quote it. For example, if you have a file called subscribers.txt where every address is separated by a single line containing a hash character, the following command will output PostScript for printing on Avery 5160 labels to a file called printme.ps:

$ labelnation -t avery-5160 -d "#" -i subscribers.txt -o printme.ps

You can use a PostScript file for the input by giving the -c option, as so:

$ labelnation -t avery-5160 -c -i winebottle.ps -o printme.ps

And you’re not limited to the predefined label sizes, either. You can define your own custom sizes by first making a file containing various parameters, which are best described by looking at the parameters of an existing label type. To see the parameters for a particular label, run labelnation with the label type you’re interested in and give the -l and --show-parameters options. For instance, to get the parameters for Avery 5160 labels:

$ labelnation -t avery-5160 -l --show-parameters
LeftMargin:      11
BottomMargin:    16
LabelWidth:      180
LabelHeight:     72
HorizSpace:      20
VertSpace:       0
HorizNumLabels:  3
VertNumLabels:   10
FontName:        Times-Roman
FontSize:        12
$

Your own parameter file should contain the parameters and their values (in PostScript points, which are 1/72 of an inch), as shown in the output above. Then, instead of giving a label type, call your parameter file as an argument to the -p option:

$ labelnation -p mylabels -i address

When you’re defining custom labels, the --show-bounding-box option is also handy — it just draws a box around each label, which is good for a test run. Print your boxed labels on a piece of scrap paper and hold it up to a label sheet to see if you have the correct size before printing on the label stock.

The full documentation is available with the --help option, which you’ll want to send to a pager:

$ labelnation --help | less

Templates for OpenOffice.org

Users of OpenOffice.org will find a huge set of label templates available to them from the OO Extras and Worldlabel sites.

These templates handle many popular Avery sheets as well as a few others — from printing Verbatim CD labels to those tab inserts used in Oxford hanging file folders.

LaTeX packages

The LaTeX markup language has had a number of solutions for printing Avery labels, and they’ve been available for years.

While the regular LaTeX letter class is capable of making labels (with the makelabels command), they’re only sized for Avery 5352 labels; for more, get and install envlab, a macro package for envelopes and labels. It understands many common Avery sizes by name, but you can also specify your own dimensions for custom labels (or envelopes).

Other potentially useful LaTeX label packages include labelmac3, for printing on Avery 6150 labels, and the labels package, which you can use to print various kinds of labels.

Command-line scripts

Finally, there are a number of simple command-line scripts that, like LabelNation, take input text and output PostScript formatted for a particular kind of label sheet.

The best I’ve found are two public-domain Perl scripts written by Greg Ercolano. The first is avery-address, which prints return address labels on Avery 5160 or 5260 sheets.

To use it, give as quoted arguments the text you want on the three lines of the label. Then, redirect the output to a file or pipe it to the print spooler or previewer. For example, here’s how you’d preview it with gv:

$ avery-address "Jane Smith" "14 Sycamore St." "Los Angeles, CA 90028" | gv -

The second script is avery-tapenum, which writes PostScript output for Avery 5267 labels, and can be used for labeling tapes, collections, or anything else with a numeric series. You give two arguments: the text used as offset and the first number to start with.

For example, here’s how to print tape labels that are prefaced by the text “CLASSICS, vol.” and begin numbering at 100:

$ avery-tapenum “CLASSICS vol. ” 100 | lpr

Notice the blank space in the first argument; this is necessary, because otherwise the numbers would be written immediately after the word, with no space. This command prints labels such as:

CLASSICS, vol. 100
CLASSICS, vol. 101
CLASSICS, vol. 102