Last active
September 28, 2022 10:23
-
-
Save maltefiala/1048e313111410c12d3e71d1d813cabc to your computer and use it in GitHub Desktop.
emacs print-to-pdf on OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Adapted following script to OSX: | |
;; https://genomeek.wordpress.com/2013/03/08/emarch-2-create-a-pdf-with-highlighted-code-source/ | |
(defun print-to-pdf () | |
(interactive) | |
(ps-spool-buffer-with-faces) | |
(switch-to-buffer "*PostScript*") | |
(write-file "tmp.ps") | |
(kill-buffer "tmp.ps") | |
(setq cmd (concat "pstopdf tmp.ps -o " (buffer-name) ".pdf")) | |
(shell-command cmd) | |
(shell-command "rm tmp.ps") | |
(message (concat "File printed in : "(buffer-name) ".pdf")) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
working under ubuntu 20.04
(defun print-to-pdf ()
(interactive)
(ps-spool-buffer-with-faces)
(switch-to-buffer "PostScript")
(write-file "tmp.ps")
(kill-buffer "tmp.ps")
(setq cmd (concat "ps2pdfwr tmp.ps " (buffer-name) ".pdf"))
(shell-command cmd)
(shell-command "rm tmp.ps")
(message (concat "File printed in : "(buffer-name) ".pdf"))
)