Feel free to browse
http://EMacro.sf.net/ for more of this stuff.
I expect to make a new release, this month.
Here is the relevant code, from e-common.el:
;;Note that ps2pdf might not be installed
(defun save-current-buffer-as-pdf ()
"Export pretty-printed file to PDF format."
(interactive)
(ps-print-buffer-with-faces (concat (buffer-file-name) ".ps"))
(shell-command (concat "ps2pdf " (buffer-file-name) ".ps"))
(delete-file (concat (buffer-file-name) ".ps"))
(message "Done"))
(defvar cache-htmlize) ;shut up compiler
(cache-locate-library
use-cache 'cache-htmlize "htmlize"
"To export as HTML, get htmlize.el from <url:
http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el>")
(when cache-htmlize (require 'htmlize))
(when (or cache-htmlize (which "ps2pdf"))
(easy-menu-change file-menu "Export As"
(list
["PDF" save-current-buffer-as-pdf
(if (which "ps2pdf") t nil)] ;enable only if in PATH
["HTML" htmlize-buffer
(if cache-htmlize t nil)])))
;;note that cache-htmlize can be replaced by a slower call to locate-library()