The simplest approach would be to get one of the free PDF print drivers, like
CutePDF and simply print the source code from your favorite editor or IDE. This would preserve all of the layout and syntax highlighting provided by your editor, but unless your editor/IDE has 'print all' or similar capability, you might end up with one pdf per source file, which is probably not what you want.
A better option is to get one of the many source code to HTML converters out there. That approach not only preserves the layout and syntax highlighting, but in many cases gives you a navigable document. For example, you can click on a method call and it takes you to the definition of that method like many IDE's. You can convert the HTML to the Kindle's MOBI format with tools like
calibre or
Mobipocket Creator.