|
|||
|
Hi, i am using the code (Shell.open) below to launch a .pdf file external, which works like a charm.
But i would like to check if Adobe reader is already running - and if so - i would like to close it first. I've tried window.close, but thats doesn't do it. Anyone who knows how to do it? And is there a possibility to check if adobe reader is installed? Code:
var path = getAppDir()+ "docs/"+selectedListing+"_"+selectedPrint+".pdf";
pdfx = createControl("AcroPDF.PDF.1", 0, 0, 0, 0);
var acrocontrol = pdfx.activex;
if (File.exists(path))
{
Shell.open(path);
} else {
// display error msg
}
|
|
|||
|
You can use the Shell.findExecutable method to see whether the acrobat reader or the foxit reader has been installed, as shown in the following ffish script code
Code:
// get the application that is used to open pdf files
var app = Shell.findExecutable(path);
var wnd = null;
if (!app) {
Dialogs.msgBox("No application for viewing pdf files");
} else {
Shell.open(path);
}
Code:
var filename = new File(path).name;
// get all windows in the system
var wnds = Window.getWindowsByName();
// find out the pdf viewer window
for (var i = 0; i < wnds.length; i++) {
// caption of the window
var caption = wnds[i].caption;
// The caption of the acrobat reader or foxit reader window will
// contain the opened pdf filename
if (caption.indexOf(filename) == 0 &&
(caption.indexOf("Adobe Acrobat") > 0 || caption.indexOf("Foxit Reader") > 0)) {
// close the window
wnds[i].close();
break;
}
}
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|