Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Living Linux

Printing Banners and Signs

04/28/2000

This week, we'll take a look at how to make banners and signs with Linux.

To make a fancy poster or sign containing graphics, multiple typefaces and a specific, detailed design, your best bet is to use a tool like the GIMP to make an image file, save it as Encapsulated PostScript (EPS), and print that.

This article will focus on making and printing simple text banners and signs quickly, from the command line -- how to print signs with text in a large font and how to print vertical banners.

Making Signs

As I mentioned a few weeks back, you can use the enscript tool to quickly make and print signs. For example, suppose you put the following text in a file called "meeting.txt":

STAFF MEETING 



TODAY AT 8:30



CONF ROOM B

You can print a sign of it with enscript by using the -f option to specify a large font (Helvetica Bold at 63 points ought to do), wrapping lines at word boundaries if necessary, and omitting the default headers by giving the -B option:

$ enscript --word-wrap -B -f "Helvetica-Bold63" meeting.txt RET

You need to use the --word-wrap option because at these larger font sizes you run the risk of making lines that are longer than what would fit on the page.

To make a sign that prints across the long side of the page, use enscript with the -r option, which outputs the text in landscape mode, where the content is rotated 90 degrees counterclockwise on the page.

For example, if the file "meeting.txt" contained this text instead:

*************************

TODAY'S MEETING IS CANCELLED!

*************************

You'd make and print a sign out of it with the following command:

$ enscript -r --word-wrap -B -f "Helvetica-Bold63" meeting.txt RET

Making Banners

The easiest way to print a long, vertical banner of text in Linux is with the old UNIX banner tool.

Give a text message as an argument and banner outputs a large, vertical "banner" containing that message. The message itself is written in a "font" composed of ASCII text characters, similar to those used by the figlet tool -- except that the message is output vertically for printing, and you can't change the font.

To send the output of banner to the printer, pipe it to lpr. For example, to print a banner containing the message "Happy Birthday Susan," you'd type:

$ banner "Happy Birthday Susan" | lpr RET

Unfortunately, the breadth of characters that banner understands is a bit limited -- you can't use the following characters in a banner message: < > [ ] \ ^ _ { } | ~

To make a banner of the contents of a text file, send its contents to banner by redirecting standard input. For example, to make a banner of the contents of the file /etc/hostname, you'd type:

$ banner < /etc/hostname RET

Changing the width of the banner

The default width of a banner is 132 text columns; you can specify a different width by giving the number of the width as an argument to the -w option. If you give the -w option without a number, banner outputs at 80 text columns.

For example, to print a banner containing the text "Happy Birthday Susan" at a width of 23 text columns, type:

$ banner -w 23 "Happy Birthday Susan" | lpr RET

To make a banner containing the text "Happy Birthday Susan" at a width of 80 text columns, type:

$ banner -w "Happy Birthday Susan" | lpr RET

Next week: a look at some of the tools for writers that Linux has to offer.

Michael Stutz was one of the first reporters to cover Linux and the free software movement in the mainstream press.

Read more Living Linux columns.

Copyright © 2009 O'Reilly Media, Inc.