jEdit Community - Resources for users of the jEdit Text Editor
Detect Acrobat Reader Install Dir
Submitted by jrchilds on Wednesday, 11 August, 2010 - 17:34
I made a macro that opens our programming language reference, which is a PDF, and locates the definition for the selected command.

I also have a batch file that installs jEdit and copies the configuration changes needed for editing in our own language. This install is used by anyone who wants to develop in our language.

Here's the problem... In Beanshell, I am using the exec() command to launch the PDF, which requires the full path to the acrobat reader. This is of course different based on the operating system and installed version of the reader.

Here's my question... Is there a way that I can determine the install directory of the acrobat reader? Or is there a simpler solution I haven't yet considered?

Thanks
James
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
default application
by Robert Schwenn on Thu, 12/08/2010 - 22:12
You could try to "run" the file itself and let the OS find and invoke the default application for this file type. On Windows, this macro works:

pathToPDF = "T:\\dummy.pdf";
CommandInterpreter = getenv("COMSPEC");
Runtime.getRuntime().exec(CommandInterpreter + " /C " + pathToPDF);

Something similar should work on Linux. There also exists a shell script for most applications which is found without a given path. For example, when i enter "okular dummy.pdf" into a terminal, the OKULAR viewer is opened and shows the dummy.pdf.

Robert
 
Almost!
by jrchilds on Fri, 13/08/2010 - 18:55
That works great for launching the pdf without knowing the path to the Acrobat reader, thanks for that.

I am having trouble figuring out how to pass a switch to the pdf though.

I am using named destinations to jump to specific topics like this...
pdfPath = "T:\\MyPDF.pdf#nameddest="+TopicName;

But when I do that, it wont launch the PDF anymore...

Any suggestions?
 
Registry
by Robert Schwenn on Fri, 13/08/2010 - 21:35
Ah yes, You can't "run" a file and specify command line parameters.

You could try to get the application's path from the Windows registry in two stages:
1. Get the default value of the key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pdf". If it is "AcroExch.Document" then:
2. Get the default value of the key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AcroExch.Document\Shell\Open\Command". For me it's ""C:\Programme\Adobe\Reader 9.0\Reader\AcroRd32.exe" "%1"". Then You have to extract the path.

It should be possible to read the registry via the java.util.prefs.Preferences class ( http://www.jdocs.com/javase/7.b12/java/util/prefs/package-summary.html ), though I havn't had luck with this.

Robert
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300