I don’t often need it, but the code printing facility in the Arduino IDE is very weak. It has some colour highlighting, but no page numbering, no line numbering, and no headers at all.
a2ps will sort you right out here. Years back, it was a simple text to PostScript filter, but now it has many wonderful filters for pretty-printing code. The Wiring/Arduino language is basically C++, and a2ps knows how to deal with that. So, to create a PostScript file with a nice version of the the most basic Blink sketch:
a2ps --pro=color -C -1 -M letter -g --pretty-print='C++' -o ~/Desktop/Blink.ps Blink.ino
If you’re somewhere that uses sensible paper sizes (in other words, not North America), you probably don’t want the
-M letter option. a2ps is supposed to have a PDF print option (
-P pdf), but it doesn’t work on my installation, so I just splat the output through ps2pdf. The results are linked below:
Not bad, eh?