Ads by Google

Saturday, August 15, 2009

Getting DocView to work on Windows Emacs

Emacs 23 has a new document viewer called docview.  From the manual

is a viewer for DVI, Postscript (PS),and PDF documents.  It provides features such as slicing, zooming, and searching inside documents.  It works by converting the document to a set of images using the `gs' (GhostScript) command, and displaying those images.

To get it to work on Windows, you'd at least need to have a working LaTeX system like MiKTeX.  And also have ghostscript installed.  Now, if you read the Docview info, this is all you need to get it work but on Windows you need to jump through additional hoops to view it.

As a first step, M-x getenv RET PATH should show something like this.

C:\MiKTeX2.7\miktex\bin;C:\cygwin\bin;C:\cygwin\usr\bin;C:\gnu\bin\;....

Next configure all doc-view-*-program to point to the correct binaries.
Upto this point, docview will work to convert the DVI or PDF file to a PNG file.  In order to view the files, you need to have Emacs with Image support.  On Windows, the following DLLs are required to make it work.
glut32.dll
jpeg62.dll
libimage.dll
libpng12.dll
libpng13.dll
libpng3.dll
librle3.dll
libtiff3.dll
zlib1.dll
which can be had from downloading the following from the gnuwin32 site.
libpng-1.2.37-bin.zip
libpng-1.2.37-dep.zip
tiff-3.8.2-1-bin.zip
jpeg-6b-4-bin.zip                        
tiff-3.8.2-1-dep.zip
jpeg-6b-4-dep.zip                        
Note that the actual version numbers may differ.  Just take only the DLLs and dump them in the Emacs bin directory. Or you could put them somewhere in the search path, so that you don't have to do this step every time a new Emacs version is released.

Docview should now work without a hitch.  The added bonus is that other image formats can also be viewed within Emacs with all the other DLLs plugged in, in Image mode.

In my set up, docview program variables point to a mix of MiKTeX and Cygwin binaries and that has not created any issues so far.