You can use an editor with syntax highlighting that allows export of RTF, export the colorized text, and import that into your document editing program.
For OS you can use e.g. Sublime Text and install the SublimeHighLight package.
But if you search around for os x editor syntax highlighting and then for the found editors search their name + rtf output or export rtf for you may come across other candidates.
For Windows such an editor is Notepad++.
Then use an additional style like in this Word example to color the background or maybe change the font. I think Word is no longer much used in the Mac world, but you can do this in practically any document processor.
From there printing to PDF should be easy. I'm not a Mac man, in Windows one could use PDF995.
For details about how others solved this in Windows see e.g. this StackOverflow post.