PluginDetect.getVersion('AdobeReader'): [Returns string or null]
Returns the version (as a string) of the installed Adobe Reader plugin. When getVersion() returns a version, it only means that the plugin is installed. It does NOT necessarily mean that the plugin is enabled.
Returns null when the version could not be determined (when plugin is not installed/not enabled, or plugin is installed but the version information is unavailable).
By default, the returned version string is comma delimited and has the format of "A,B,C,D". If you wish to change the getVersion() delimiter, then use:
PluginDetect.getVersion(delimiter) where delimiter is a string with exactly 1 character.
For example,
PluginDetect.getVersion("."); // set delimiter
var version = PluginDetect.getVersion("AdobeReader"); // version has the format of "A.B.C.D"
PluginDetect.isMinVersion('AdobeReader', minVersion, mimetype): [Returns number]
Returns 1 if plugin is installed & enabled for the specified mimetype and plugin version is >= minVersion.
Returns 0 if plugin is installed & enabled for the specified mimetype. The plugin version is unknown, and thus we are unable to determine if version >= minVersion.
Returns -0.1 if plugin is installed & enabled for the specified mimetype, but plugin version is < minVersion.
Returns -0.2 if plugin is installed but not enabled for the specified mimetype. This means that the Adobe Reader plugin is present, but the browser will not use the Adobe Reader plugin to display a file with that mimetype. If there is a 3rd party plugin asociated with that mimetype, then it (instead of the Adobe Reader) will be used by the browser to display the file with that mimetype.
Returns -1 if plugin is not installed or not enabled.
Returns -2 if ActiveX is disabled (for Internet Explorer, this prevents plugin detection).
Returns -3 if you supplied a bad input argument to the isMinVersion() method.
minVersion: [string or number input argument]
This is the minimum plugin version.
Can be a string such as '1,5,0,0' or '1.5' or '1,5,0,1' or '1.5.0.1' etc...
Can be a number such as 0 or 1.5 or 1.50 etc...
If minVersion is not specified, then PluginDetect will assume minVersion is '0'.
Strings are more versatile than numbers since '1,5,0,1' cannot be expressed as a number.
mimetype: [string, optional input argument]
The mimetype input is only used by PluginDetect for non-Internet Explorer browsers. It is ignored if the browser is Internet Explorer.
If mimetype input is not a string, or is an empty string, or is a string with only space characters in it, or is not specified at all, then PluginDetect will assume a default value of "application/pdf". Most people will not need to specify any mimetype, and therefore the default value is assumed.
Some of the possible values for mimetype for Adobe Reader are: "application/pdf", "application/vnd.fdf", "application/vnd.adobe.xfdf", etc...
Spaces in the mimetype input string are ignored. The mimetype input string is case sensitive.
Limitations of Adobe Reader detection
When you install Adobe Reader on your computer, you have 2 basic ways of viewing pdf documents:
i) use the standalone Adobe Reader application (no browser needed), or
ii) use a browser with the Adobe Reader plugin.
The plugin is nice because when you browse a website and click on a link to a pdf, the pdf will display directly inside the browser window. It turns out, however, that in the Adobe Reader Preferences there is a checkbox labeled "Display PDF in browser" [or something similar]. When you disable this checkbox, the plugin will be disabled [at least for some browsers and some versions of Adobe Reader], and your pdf documents will no longer display inside the browser. So when you click on a link (in a web page) to a pdf document, the standalone app can/will take over to display the document.
We can therefore say that there are several possibilities to consider when trying to detect the Adobe Reader:
1) Adobe Reader is installed, and the browser plugin is enabled in the Adobe Reader preferences. Your pdf documents can be displayed in the browser window. The Adobe Reader plugin can be detected by PluginDetect.
OR
2) Adobe Reader is installed, and the browser plugin is disabled in the Adobe Reader preferences. Your pdf documents cannot be displayed in the browser window. Instead, the Adobe Reader standalone application will display the pdf. The Adobe Reader plugin can still be detected by PluginDetect.
OR
3) Adobe Reader is installed, and the browser plugin is disabled in the Adobe Reader preferences. Your pdf documents cannot be displayed in the browser window. Instead, the Adobe Reader standalone application will display the pdf. The Adobe Reader plugin cannot be detected by PluginDetect.
OR
4) Adobe Reader is not installed, and therefore the browser plugin is not present
. Your pdf documents cannot be displayed in the browser window, and also not in the Adobe Reader standalone app. The Adobe Reader plugin therefore cannot be detected by PluginDetect.
Note: To keep things simple in this discussion, we ignore any 3rd party PDF Readers being present.
The problem here is that PluginDetect has no good way of distinguishing between cases 3) and 4). This is an important limitation that you should keep in mind. The reason for this limitation is that PluginDetect cannot detect standalone applications outside of the browser.
It can only detect browser plugins.
In both cases 3) and 4), PluginDetect.isMinVersion("AdobeReader") will be -1.
In both cases 3) and 4), the Adobe Reader plugin will not display a pdf document within your browser window.
But in case 3),
the user can still read pdf documents outside the browser, using the Adobe standalone app.
Plugin Version Precision
The precision of the detected Adobe Reader version will vary greatly between browsers. The reason for this discrepancy is that the amount of information available to PluginDetect varies between browsers and operating systems.
The plugin version is detected by PluginDetect.getVersion('AdobeReader'). The getVersion() method will return a value of either null or a string of 4 numbers "A,B,C,D" separated by a comma. Each of these 4 numbers is an integer >=0.
For Internet Explorer, the first 3 numbers "A,B,C" can be detected. For all other browsers, the precision can range from only being able to detect the first number "A", to being able to detect all 4 numbers "A,B,C,D".
The only time (so far) I have seen all 4 numbers "A,B,C,D" available is for Firefox 3.6+ on Windows.
Detecting Reader for Firefox/Chrome/Safari and other non-IE browsers
For Adobe Reader 8.0 thru 9.3 on Windows/non-IE browsers, the plugin version is not directly detectable. PluginDetect can, however, deduce the first digit of the plugin version by looking at all available information within the browser. The format of this deduced version will be "A,0,0,0". [Note: Firefox 3.6+ appears to be the exception. It allows all 4 digits "A,B,C,D" of the plugin version to be detected, regardless of the Adobe Reader version.]
For Adobe Reader < 8.0 and >=5.0, and Adobe Reader 9.3.3 or higher, on Windows/non-IE browsers, the plugin version is detectable. The format of the detected version will be "A,B,C,0".
For Adobe Reader/Macintosh, it appears that the plugin version can be detected as "A,B,C,0" (at least for Reader 7+).
For Adobe Reader/Linux, it appears that the plugin version can be detected as "A,B,0,0".
Select minVersion input argument with care
Please note again that the number of digits that can be detected for the Adobe Reader version will vary. In some cases, the format will be "A,0,0,0", and in others the format will be "A,B,C,D". Therefore, you need to specify the 'minVersion' input argument to PluginDetect.isMinVersion("AdobeReader", minVersion) very carefully.
In the case of Adobe Reader 8 - 9.3 in Windows/non-IE browsers, we have already shown you that the version is only detectable as "A,0,0,0". So, Adobe Reader 8.2 would be detected as "8,0,0,0" and Adobe Reader 8.0 would be detected as "8,0,0,0". Adobe Reader 9.3 would be detected as "9,0,0,0" and Adobe Reader 9.0 would be detected as "9,0,0,0".
So be careful when specifying 'minVersion'.
A few examples...
Below we show a few simple detection examples.
[Example 1] Let us use the following code to determine the Adobe Reader plugin status...
var status =
PluginDetect.isMinVersion("AdobeReader", "0");
var AdobeRdrInstalledEnabled = (status >=0 ? true : false);
This code means that the default mimetype assumed by PluginDetect is "application/pdf". Note that any file name that has the "pdf" suffix, such as "MyTestFile.pdf", is considered to have a mimetype of "application/pdf".
If the status variable is >= 0, then the Adobe Reader plugin is installed and enabled for the "application/pdf" mimetype. This means that your browser will use the Adobe Reader plugin to display "MyTestFile.pdf".
Because minVersion is "0" in this example, it is not possible for the Adobe Reader version to be < 0. Therefore status will never have a value of -0.1 in this example.
If, on the other hand, status is -0.2, then the Adobe Reader plugin is installed but not enabled for the specified mimetype (ie. "application/pdf"). It means that any files with the "application/pdf" mimetype will not be displayed by the Adobe Reader in your browser.
Most likely, you have another PDF Reader (ie. a 3rd party plugin, or alternative pdf reader) installed. This 3rd party plugin is probably associated with the mimetype, and therefore it would be used by the browser to display the pdf file.
For instance, when I install Foxit Reader 5.0, and then install Adobe Reader 10.1 on Windows, my Firefox 6.0 browser will use the Foxit Reader to display pdf files. I get a value of -0.2 for status in this particular case.
If status receives a value of -1, then the Adobe Reader plugin is not installed or not enabled.
[Example 2 ] Let us use the following code to determine the Adobe Reader plugin status...
var status =
PluginDetect.isMinVersion("AdobeReader", "0", "application/vnd.fdf");
var AdobeRdrInstalledEnabled = (status >=0 ? true : false);
This code means that PluginDetect will test to see if the Adobe Reader plugin is present, and whether the mimetype "application/vnd.fdf" is associated with the Adobe Reader . Note that any file name that has the "fdf" suffix, such as "MyTestFile.fdf", is considered to have a mimetype of "application/vnd.fdf".
If the status variable is >= 0, then the Adobe Reader plugin in installed and enabled for the "application/vnd.fdf" mimetype. This means that your browser will use the Adobe Reader plugin to display "MyTestFile.fdf".
Because minVersion is "0" in this example, it is not possible for the Adobe Reader version to be < 0. Therefore status will never have a value of -0.1 in this example.
If, on the other hand, status is -0.2, then the Adobe Reader plugin is installed but any files with "application/vnd.fdf" mimetype will not be displayed by the Adobe Reader. If a 3rd party plugin is associated with this mimetype, then it would be used by the browser to display the file.
For these reasons, we say that a status of -0.2 means that the Adobe Reader plugin is installed but not enabled for the specified mimetype.
If status receives a value of -1, then the Adobe Reader plugin is not installed or not enabled.
[Example 3 ] Let us use the following code to determine the Adobe Reader plugin status...
var status =
PluginDetect.isMinVersion("AdobeReader", "10");
var AdobeRdrInstalledEnabled = (status >=0 ? true : false);
The default mimetype assumed by PluginDetect here is "application/pdf".
If status is 1, then the Adobe Reader plugin is installed & enabled for the "application/pdf" mimetype, and the plugin version is >= 10.
If status is 0,
then the Adobe Reader plugin is installed & enabled for the "application/pdf" mimetype, but the plugin version was not detected by PluginDetect.
If status is -0.1, then the plugin is installed & enabled, but the version is < 10. Time to update your Adobe Reader!
If status is -0.2, then the plugin is installed, but not enabled for the given mimetype. Most likely, a 3rd party pdf reader has hijacked the mimetype, and it (instead of Adobe Reader) will display the pdf file in your browser.
If status is -1, then Adobe Reader is not installed or not enabled.
Detecting Reader for Internet Explorer
For Internet Explorer, the plugin version appears to be detectable for Adobe Reader 5+. The plugin version will have the format of "A,B,C,0".
PluginDetect will not check which mimetypes in Internet Explorer are or are not associated with the Adobe Reader plugin. The reason is that Internet Explorer does not populate its navigator.mimeTypes array with any data. So one cannot know which mimetypes the browser can or cannot handle. [Of course, one could insert an <object> tag into the page, with the "type" property set. But for IE 7+, this could cause a security popup to occur in the browser.]
For these reasons, Internet Explorer will always ignore the 3rd input argument in this statement:
// Internet Explorer ignores 3rd input arg.
// Therefore, isMinVersion('AdobeReader', minVersion, mimeType) will never be -0.2 for IE.
var status =
PluginDetect.isMinVersion("AdobeReader", "0", "application/vnd.fdf");