Printing Howto

(How to print different files under Linux)

© (2004) Pablo Arés, pablo /at/ math.tifr.res.in


Printing pnm files

You have to convert the pnm file to a ps file with

   pnmtops -scale 1000 -dpi 300 file.pnm | lpr -Plaser
or any other printer (-Pcolour will send the output to the colour printer).
Printing gif files

Convert to pnm and then to ps:

   giftopnm file.gif | pnmtops -scale 1000 -dpi 300 | lpr -Plaser

Printing jpeg files

Similar command:

   djpeg -pnm file.jpg | pnmtops -scale 1000 -dpi 300 | lpr -Plaser

Printing png files

You have to convert the png file to pnm and then print it:

   pngtopnm file.png | pnmtops -scale 1000 -dpi 300 | lpr -Plaser

Printing text files

There are several things you can to with text (ASCII) files. You can print them directly (lpr or prtmgr) or "make several pages into one" and then print. For example, you can do:

  a2ps -r -2 -j --no-header -i file | lpr -Plaser
to print "two-pages-in-one" without borders (I mean, without lines enclosing the text), or
  a2ps -r -2 -j -i file | lpr -Plaser
that will produce the text enclosed in a rectangle with the name of the file, the date and numbering of pages (plus your name in the top of each page).

Printing doc/rtf files

Although StarOffice and OpenOffice can display doc (and rtf) files, some times the printers cannot handle them. You can do the following trick:

  1. Open the file with StarOffice/OpenOffice and save it as a ps (PostScript) file, say file.ps
  2. Convert it to pdf with pd2pdf file.ps
  3. Convert it back to ps with pdf2ps file.pdf
  4. Print the resulting file.ps


Printing other files

Well, that depends on the type of file you have. DVI, PostScript (PS) and PDF files can be printed directly in all printers, either with lpr or with the prtmgr utility. Other graphics files require programs to convert them to PS files (the type of files the printer understand better). You will have to find a program for each type of file, or ask for help from the system administrator.