I'd usually use enscript: something like
$ enscript --highlight=cpp
--header='|Real Name|Class 101'
--footer='|Page $% of $=|'
-poutput.ps *.cpp
will be a start - this writes postscript output to output.ps
, so you can preview and overwrite that while you're tinkering with the config and then print it once you're happy. See the man page for more very extensive options.
EDIT getting the footer to work correctly is a bit of a pain with enscript - I'd never noticed because I've never required it. If you save this file to ~/.enscript/so.hdr
(you probably need to create the directory), you'll actually get the required output with
$ enscript --highlight=cpp
--header='|Real Name|Class 101'
--footer='|Page $% of $=|'
--fancy-header=so
-poutput.ps *.cpp
giving

Roughly,
- LaTeχ is the best quality and the most work to set up,
- enscript or a2ps are intermediate in both quality and work,
- vim's
:hardcopy
command is easy but not that flexible, and
- doing syntax highlighting manually in a non-code-aware editor is a lot of effort for a poor return.