New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows implementation of 'Goto annotation in pdf' #109
Comments
someone watching who can help with this? I don't have windows so I need someone who can text code. |
Here are the relevant information if someone wants to help out. There are two important parts for making this work on Windows. The first part finds the path of Adobe Reader by accessing the registry and the second opens the pdf. Both can be tested independently by setting the path manually using the 1) Getting the path for Adobe Readervar wrk = Components.classes["@mozilla.org/windows-registry-key;1"]
.createInstance(Components.interfaces.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths",
wrk.ACCESS_READ);
if(wrk.hasChild('AcroRd32.exe')) {
subkey = wrk.openChild('AcroRd32.exe', wrk.ACCESS_READ);
acrobat = subkey.readStringValue('Path') + 'AcroRd32.exe';
}
wrk.close();
acrobat 2) Opening the pdf// acrobat = 'C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe'
path = '[PATH TO A PDF FILE]'
page = 2
// These two function should work so don't worry about them
createFile = function(path) {
try {
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsIFile);
file.initWithPath(path);
return(file);
}
catch (err) {
return(-1);
}
}
runProcess = function(command, args, blocking) {
// default arguments
blocking = typeof blocking !== 'undefined' ? blocking : true;
try {
// set up process
var cmd = createFile(command);
var proc = Components.classes["@mozilla.org/process/util;1"].
createInstance(Components.interfaces.nsIProcess);
proc.init(cmd);
// run process
proc.runw(blocking, args, args.length);
}
catch(err) {
Components.utils.reportError(err);
return (-1);
}
}
// open pdf on page
// http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
if (page)
args = ['/A', '"page=' + page + '"', '"' + path + '"'];
else
args = ['/A', '"' + path + '"'];
// run process
runProcess(acrobat, args, false); |
Is there a reason why you are set on using only Adobe Acrobat for this? Looking around, it seems that probably most PDF readers support the Looking around at how Windows Explorer figures this out on Windows 7 (this may be a bit different on XP), you want to follow the following steps:
Let me know if you need me to dig around some more Edit: escaped some special chars |
I am not at all set on using Adobe Reader. I just have no idea about windows so it's good to know that other PDF readers support the |
This should do it. I'll have to test it on other machines though
Edit: tiny fix. Don't overwrite progId if there's nothing to redirect to. |
Thanks, that is great! I just added the function to zotfile so that the links to certain pages in pdfs might now work. I wasn't able to test it though (the last version with adobe wasn't working anyway). I hope I can give it a shot soon though. Let me know how it works on your other pc. |
Works on Windows XP also, but I have not tested this with PDF-XChange or FoxIt |
I fixed the last thing in zotfile, added some documentation and the whole process should work now. Thanks again for helping out! I think this is a very useful feature. |
I mostly use PDFfiller to annotate my PDFs. Its not the same thing, but maybe someone needs it. It also allows you to fill, edit erase in a pdf, esign, efax, add logos and pics to pdfs. Its pretty easy to use and its pretty cheap. I think you can get a free week if you and a friend both register. Here is a link to the site's functionality http://goo.gl/rNcHzt. |
No description provided.
The text was updated successfully, but these errors were encountered: