[pdftex] ``Reload'' function for Adobe Reader (Linux)
James Quirk
jjq at galcit.caltech.edu
Thu Jan 22 22:09:48 CET 2009
Alexander,
On Thu, 22 Jan 2009, Alexander Grahn wrote:
>
> James, I tried your code. Unfortunately, my acroread (8.1.3) crashes
> (sementation fault) if there is more than one document open.
>
> I found out that it is currentDoc.closeDoc() which fails if the event
> is triggerd by clicking the tool button. The object currentDoc, however,
> is valid, as I can output currentDoc.path to the console.
>
Below is a revised folder-level JavaScript that works at my end with
AR8.1.3, when there is more than one opened document . It uses two delayed
calls to overcome whatever internal problems AR is suffering from. I've
tried to reduce it to just the one TimeOut, but I can't get it to work.
I will have another go tomorrow to see if I can come up with a more
elegant workaround.
James
var myCurrentDoc;
var myCurrentDocPath;
var myCurrentDocView;
function MyReloadStep1() {
myCurrentDocView = myCurrentDoc.viewState;
myCurrentDocPath = myCurrentDoc.path;
myCurrentDoc.closeDoc();
app.setTimeOut("MyReloadStep2()",1);
}
MyReloadStep2 = app.trustedFunction(function() {
app.beginPriv();
var oDoc = app.openDoc(myCurrentDocPath);
oDoc.viewState = myCurrentDocView;
app.endPriv();
});
reloadCurrentDoc = app.trustedFunction(function(currentDoc) {
app.beginPriv();
myCurrentDoc = currentDoc;
app.setTimeOut("MyReloadStep1()",1);
app.endPriv();
});
app.addMenuItem({
cName: "reloadCurrentDoc",
cUser: "Reload",
cParent: "File",
cExec: "reloadCurrentDoc(event.target);",
cEnable: "event.rc = (event.target != null);",
nPos: 0
});
var oReloadButton = {
cName: "Reload",
cExec: "reloadCurrentDoc(event.target);",
cEnable: "event.rc = (event.target != null);",
cTooltext: "Reload Current PDF",
nPos: -1,
cLabel: "Reload"
};
app.addToolButton(oReloadButton);
More information about the pdftex
mailing list