Skip to content

Instantly share code, notes, and snippets.

@maltefiala
Last active September 28, 2022 10:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maltefiala/1048e313111410c12d3e71d1d813cabc to your computer and use it in GitHub Desktop.
Save maltefiala/1048e313111410c12d3e71d1d813cabc to your computer and use it in GitHub Desktop.
emacs print-to-pdf on OSX
;; 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"))
)
@deligeer
Copy link

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"))
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment