Use enscript, which is installed by default on linux systems.
$ enscript --helpwill show you a whole list of options to choose from. If you're as lazy as me, just rely upon the configuration which I found most useful:
$ enscript -2rGC --color -Ec code.cThe options passed along with what they do is as follows:
- -2 : 2 columns. To have single column, you can use -1. Use --columns=NUM, if you want to specify more than 2 columns.
- -r : landscape view.
- -G : cool fancy looking header, which includes file name, page number and creation time.
- -C : print line number in front of each line.
- --color : colored output
- -Ec : formatted using C syntax. Though enscript supports various coding syntaxes, which range from Java to Python to Tcl etc., it is not intelligent enough to understand which language is the code written in, so you need to pass this flag. For e.g. To get the code formatted using python syntax, use -Epython.
$ enscript -2rGC --color -p testing.ps -Ec code.cThat's it! Enjoy code reading!
No comments:
Post a Comment