Wednesday, September 30, 2009

Using doc-view-mode on Mac OS X

Included with emacs 23 is a new feature called DocView, which lets you view PDF, PS, and DVI files (via conversion to PNG) directly in emacs. However, it does not work on Mac OS X out of the box. If you try to open a PDF, you get an error of the form "No PNG support available or some conversion utility for pdf files is missing."

There seems to be little information on the web about this, but if you read the file header, it tells you what you need:
doc-view.el requires GNU Emacs 22.1 or newer. You also need Ghostscript, `dvipdf' (comes with Ghostscript) or `dvipdfm' (comes with teTeX or TeXLive) and `pdftotext', which comes with xpdf (http://www.foolabs.com/xpdf/) or poppler (http://poppler.freedesktop.org/).
You can install these via MacPorts:
sudo port install ghostscript xpdf
Then you must restart emacs to get DocView to register the availability of the new commands.

1 comment:

  1. Thank you very much -- I really appreciate this informative write-up. The only thing I added was setting the path to the macports bin in my .emacs. If the macports bin is not already in the $PATH (for whatever the reason), one option is to add this line to the .emacs file:

    (setq exec-path (append exec-path '("/path/to/macports/bin")))

    I have chosen not to load macports on startup of the computer, so my .profile and .bash_profile do not contain the path to the macports bin.

    ReplyDelete