Printing long row ascii files to non-ps printer; how to resize font and make it fit on page?

What tool will most easily preprocess, or handshake with the printer to change ascii font size? I am printing text files composed with vi, which are 105-115 characters per row, that need to be resized (in font size) so that each line fits on the page when it’s printed on my, non-ps, brother mfc L2700dw printer?

lp -o fit-to-page doesn’t work
troff involves completely rewriting the text files, and short attempts in this direction failed to do what the manual said it would do.
I looked a bit at ghostscript, don’t recall my thoughts there.
enscript is advised, but is no longer part of the debian packages
asciidoctor and asciidoc might be the way to go

I need to understand the problem. Who is choosing the font? Is it the printer hardware, the linux print driver, the cups system?

Get font list

 fc-list : family style

Print demo.txt with Ubuntu Mono with 13 font size using paps

paps --font="Ubuntu Mono 13" --paper=letter demo.txt | lp
paps --font="Ubuntu Mono 13" --paper=letter demo.txt --lpi=N --cpi=M | lp

The -lpi sets the lines per inch. This determines the line spacing and the --cpi sets the characters per inch which is an alternative method of specifying the font size.
Other paps options:

              Set bottom margin. Default is 36 postscript points.

              Set top margin. Default is 36 postscript points.

              Set left margin. Default is 36 postscript points.

              Set right margin. Default is 36 postscript points.

              Set gutter width. Default is 40 postscript points.

HP printer

They have a GUI tool called HP device manger. That allows to control all of this too.

Scale a text document to fit the page using the lp command in Linux

Also we can do

command filename | lp -o cpi={value_N} -o lpi={value_M}
lp -d {printer_name} -o cpi={value_N} -o lpi={value_M} filename.txt
  • lpi is the number of lines per inch (LPI) that you want to print.
  • cpi is the the number characters per inch (CPI) that you want to print. You can calculate this by dividing the width of your document, in characters, by the width of your printable area, in inches.

That’s just fantastic. Easy as pie, the paps program can print what ever ps font you have (I presume). I’ve wanted to learn how to do this for decades. Thank you Tomboi.

Hi @mike :blush: I get tons of help from this and other forums. Would you please accept this as solution (click on three dots on my post and click on the Solution)? Good day ahead for you.

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki