htmlfontify.el can make an html view of any buffer in Emacs. Emacs has a command (
browse-url-of-file) to send any html file to the selected web browser.
Adding these two things together you suddenly have a way to get a snapshot of the buffer’s view in your web browser. And - finally - if you can print from your web browser, then this gives a simple way to preview and print (with colors) from Emacs.
I implemented this in
hfyview.el. Beside printing a buffer it can print a window or frame, see the example at http://ourcomments.org/Emacs/nXhtml/doc/htmlfontify-example.html. If you want to it can also add a Quick Print entry in the File menu.
To easily distribute
htmlfontify.el + hfyview.el I have put them in nXthml.
[question] How does bundling something in with an unrelated package that many people don’t need make it easy? I can find htmlfontify.el as a separate download, but where do I get hfyview.el?
It makes it easy for me …;-) And actually for you since doing it this way I can find time to keep it updated all the time. Please look at the reposity for nXhtml. You will find
hfyview.el in the util subdir. (But actually I think it is less trouble to just install nXhtml.)
Note: This was originally written for MS Windows because I could not find an easy way to print there, but it is OS independent. From the beginning this was implemented using
htmlize-view.el. I switched to
htmlfontify.el instead because htmlfontify could take care of a bit more cases and because htmlfontify will hopefully also soon be part of Emacs. (Here on EmacsWiki there is an old version for MS Windows called Lisp:w32-winprint.el)