You'd be surprised, but this is much harder than it looks. Even forgetting about cosmetic niceties like green bars, aspect ratio and appropriate fonts, putting exactly M×N characters in a block on a page is complex, and your extended requirements comment:
Ideally, I'm looking for a tool that can automatically arrange NxM characters within a rectangle of a given size, automatically selecting the font based on size or pitch, depending on what is more restrictive, and adjusting the inter-line spacing or character spacing as appropriate.
may be practically impossible. (Adjusting character spacing, incidentally, is not recommended, ever.) Sadly, any effort to produce nice mono-spaced output is usually swamped by the (much larger) effort to make nice proportional output. As you didn't have any layout options on a line printer, it all seemed rather too easy.
But for the special case of 132×66, we can get close with a couple of programs. I'm going to assume you want PDF output, and we're going to get it by using the CUPS PDF virtual printer on Linux (in the printer-driver-cups-pdf
package on Debian). I'm also going to assume you have a file called 132cols.txt
that's exactly 132 columns wide. Tools such as fmt
can help you get there. We're also going to use US Letter paper, and we're going to be very happy to use Courier, okay?
1) enscript

enscript
has knocked around Unix installations for decades in many forms. The version you have on your system may not have all of the options I use here. But to get a 132×66 text block to fit a page, this command will do it:
enscript --no-header --no-job-header --lines-per-page=66 [email protected]/7.5 --media=letter --landscape --margins=18:18:36:36 --printer=PDF 132cols.txt
enscript's font selection is extremely poor, unless you're willing to dive into some deep configuration. The only other option available by default is Courier-Bold. --lines-per-page
is supposedly overridden by font selection (but isn't), and this font size was found by trial and error.
2) a2ps
a2ps
is a Gnu thing, so has overly long and mostly contradictory documentation. I had great difficulty keeping this to the 132×66 format, and sometimes even feeding it different input with the same options gave me different numbers of lines and columns. However, this appear to usually do the job:
a2ps --medium=Letter --landscape --columns=1 --rows=1 --lines-per-page=66 --no-header --borders=no --printer=PDF ~/Desktop/132cols.txt
Text block isn't centred, if that matters. For this page size, --lines-per-page=66
was the controlling variable. If I set --chars-per-line=132
I only got 58 lines per page.
Other options
- Ghostscript's
gslp
is equivalent to an early version of enscript, but written entirely in PostScript. Not tried, but seems to default to some very obsolete printer choices (even by our standards).
You may have to fiddle with the pr
(the text formatter/paginator) and fmt
utilities to make your output work. Good luck!