A while ago I wrote about how I print my itinerary and other useful info (like alternate return flights) on a 3x5 card that I stick into my HPDA just before a trip. Since then, I’ve been traveling more for both business and pleasure, and I’ve honed my technique for making the cards.

I have only two criteria for the cards:

1. It must be easy to read, with clean fonts and a decent and consistent layout. The idea is to be able to get to the information quickly when in a cab or rental car or when walking through an airport or hotel lobby.
2. It must be easy to make from information copied from web sites and confirmation emails.

Initially I used a plain text file in BBEdit and used some special print settings to get a nice-looking font and the proper sizing. Too much fussing and too many retries as the line breaks often had to be changed to make things fit.

Then I went to AppleWorks. Not as much fussing over layout because the rulers give more control, but still more than I wanted. Also, pasted-in info from web sites carried its style with it, which was never the style I wanted on the card, so I’d have to keep resetting the font and font size. And AppleWorks takes longer to start up than I’d like. (TextEdit starts up fast, but can’t be used for printing on index cards because the left and right margins can’t be made smaller than 1 inch.)

Finally, I bit the bullet and wrote the program below. It takes a plain text file with a few formatting clues and generates and prints a card. Assembling the data in BBEdit (or Vim or TextMate or …) is simple and fast. The layout is clean and definitely consistent because it is built into the program.

Here’s the program.

#!/usr/bin/perl

use Getopt::Std;

$usage = <<USAGE; ptripcard: print travel information on a 3x5 card. usage: ptripcard [options] [file] options: -h : show this message -d : show the raw [gt]roff; don't process or send to printer The input file (or stdin) is a plain text that follows these rules: * the first line is the title * a tab is denoted by the pipe character (|) * a page break is denoted by a line of two or more hyphens (--) For the output: * the title is printed in 12 pt Helvetica * the rest is printed in 10 pt Helvetica * the title line has one tab--right-justified at the right margin * tabs in the rest of the document are left-justified and set every 5/8 inch * lines are not wrapped The file is immediately sent to the printer for manual feed printing (unless the debug option is set). USAGE # Handle command line my %opt; getopts('dh', \%opt); die$usage if ($opt{h});$debug = $opt{d}; # Top of [gt]roff file. The page offset is 0.10 inch less than # it should be because (I think) the Mac's printer driver shifts # things to the right a bit.$preamble = <<PREAMBLE;
.po 2.9i
.ll 2.5i
.sp |.25i
.ft H
.nf
.na
.vs 12
.ps 12
.ta 2.5iR
PREAMBLE

# The first line is the title.
$title = <>;$title =~ s/\|/\t/g;                  # change |s to tabs

# Slurp in the rest of the file.
{
local $/;$rest = <>;
}
$rest =~ s/\|/\t/g; # change |s to tabs$rest =~ s/^--+$/.bp\n.sp |.30i/gsm; # break page at line of -s # Change the font size and the tab layout between the title and the rest.$all = $preamble .$title . ".ps 10\n.ta .625i 1.25i 1.875i\n" . $rest; # Output is (normally) filtered through groff and sent to the printer. unless ($debug) {
open OUT, "| groff -P-m | lpr";
select OUT;
}
print \$all;


The usage message at the top of the program pretty much says it all. (I’ve developed a style of putting the usage message at the top of all my programs. It’s available from the command line by passing the program the ‘-h’ option, and it’s the first thing I see when I open the program in a text editor.)

The things to remember are to use the vertical bar (|) as the tab and a line of at least two hyphens as a page break. The vertical bar may seem funny, but it’s much easier to see a | than a tab (no, I don’t like to run BBEdit with the “Show Invisibles” setting turned on), and I’ve used this convention in several programs, so I’m used to it. Similarly, ----- is easier to see than an invisible page break character. When I need more than one page of travel info (which has only happened twice), I print on both sides of the card.

After I issue the command and feed it the input file, I walk over to my printer, which is blinking for paper, and feed it an index card. Voila! This magic comes courtesy of Perl’s ability to pipe, which you can see in the open OUT, "| groff -P-m | lpr"; line near the end of the program. The troff codes that the program generates are piped into groff, which—because of the ‘-P-m’ option—embeds a manual feed command in the PostScript output. The PostScript is then piped to my default printer, which is a PS printer.

If I didn’t have a PostScript printer, I might be forced to pipe the PS through Ghostscript to get it in a form my printer can handle. (In Linux, this is unnecessary: the printer drivers do it for you.) Or I might pipe it through ps2pdf to create a PDF file, which I would then print using Preview or Acrobat or whatever.

An example input file is this

Birmingham trip|Dec 21

Flight (conf no. XXXXXX)
Out:|SW 554|6:10-8:40am
Back:|SW 1929|6:50-9:25pm

Alternate returns:
SW 111||4:45-6:35pm
|following day
SW 436/418|6:45-9:35am
SW 945||8:55-10:35am


and the output looks like this

Update
If you have OmniOutliner (it came free with my iMac), you may want to use it to format your trip card. I have a template and some instructions here.