Article Preview
Buy Now
COLUMN
Printing Labels
A simple label printing program
Issue: 9.6 (September/October 2011)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 22,694
Starting Page Number: 66
Article Number: 9611
Related Link(s): None
Excerpt of article text...
A few issues ago I covered printing, demonstrating a print preview feature and how to print styled text. Today we're going to finish up that lesson with something practical: I'm going to show you a label printing program I've been using for years. More than a good demonstration, it's actually a useful application!
I first wrote this back in 2002 when I launched this magazine as I frequently needed to print address labels to mail subscribers magazines. Now that we're not print-based, I don't do as much physical mailing any more, but I do still have to mail books and CDs and printed back issues so I still use this frequently.
The main reason I wrote this program is so I wouldn't waste address labels. Almost any word processor will let you batch print labels with a mail-merge feature, but that only works if you have 30+ addresses to print. What if you're just printing one or two labels? So I made LabelPrinter display a grid of labels and allow you to select just the label position you want to print on. This means I could use up any leftover labels sheets or print one-off labels easily.
To do this, I created the interface you see in Figure 1. There's a template popupmenu where you can select the label paper you are using. (This is a simple XML-like structure that defines the label paper. I include several Avery brand examples but you can easily make your own.) The default template is a 30-up label sheet. Below that is a preview of label paper with a red box marking the currently selected label. Just click on a different label to select it instead.
In the upper right is a
textArea
which contains our address(s). Below that are font choices. Then we have print buttons and some checkboxes for print preview and whether we're printing multiple labels or not.Label Preview
...End of Excerpt. Please purchase the magazine to read the full article.