Reloading a File in Adobe Reader

When working on document in LaTeX that is going to wind up as a PDF (e.g. my thesis), I prefer to look at it in Adobe Reader. Acroread seems to give the best impression of what the document will actually look like. In practice, though, I use xpdf, because it has a “reload” capability that allows me to immediately view changes. Acroread doesn’t have this. However, someone very clever has come up with a workaround. I found out about it here, and it is evidently due Alexander Grahn.

Create a file called ~/.adobe/Acrobat/8.0/JavaScripts/reload.js with:

reloadCurrentDoc = app.trustedFunction(
   function(currentDoc) {
      app.beginPriv();
      currentDocView=currentDoc.viewState;
      currentDocPath=currentDoc.path;
      currentDoc.closeDoc();
      currentDoc=app.openDoc(currentDocPath);
      currentDoc.viewState=currentDocView;
      app.endPriv();
   });

app.addMenuItem({
  cName: "reloadCurDoc",
  cUser: "Reload",
  cParent: "File",
  cExec: "reloadCurrentDoc(event.target);",
  cEnable: "event.rc = (event.target != null);",
  nPos: 0
});

app.addToolButton({
  cName: "reloadCurDoc",
  cExec: "reloadCurrentDoc(event.target);",
  cToolText: "Reload the current document",
  cEnable: "event.rc = (event.target != null);",
  cLabel: "Reload",
  nPos: -1
});

Reopen Acroread and you now have a reload button!

Leave a Reply

You must be logged in to post a comment.