Sunday, March 24, 2013

Printing Source Code

This is a little tip on how to print source code neatly in Linux.

$ sudo apt-get install a2ps
$ a2ps -2 your-directory/all-files --line-numbers=1 -o total.ps
$ ps2pdf total.ps total.pdf

The result is as follows:



The options used for a2ps are this.
  -2 means two columns in a single page on landscape mode
  --line-numbers=1 means to print line numbers every line
  -o specifies the resulting PostScript file.