views:

467

answers:

3

I know that starting with version 8, the name of the Adobe Reader plugin was changed to "Adobe PDF Plug-In for Firefox and Netscape", and does not include any version information. However, the version information does appear in the "Plugins" tab when viewing Firefox Add-ons. Does anyone know where that information comes from, and if it's possible to access that value with JavaScript?

Adobe has made significant changes to Acrobat Reader between version 8 and 9, so it's hard to believe that there's no way to distinguish between the two versions in browsers other than IE.

A: 

Here is code to detect Acrobat for all versions in IE and FF. The key is that it does detect the version using:

oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
if (oAcro)
{
acrobat.installed=true;
acrobat.version=x+'.0';
}

So with a little customization you can use something similar to detect the version.

Here is the full code:

var acrobat=new Object();

acrobat.installed=false;
acrobat.version='0.0';

if (navigator.plugins && navigator.plugins.length)
{
for (x=0; x
{
if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
{
acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);

if (acrobat.version.toString().length == 1) acrobat.version+='.0';

acrobat.installed=true;
break;
}
}
}
else if (window.ActiveXObject)
{
for (x=2; x<10; x++)
{
try
{
oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
if (oAcro)
{
acrobat.installed=true;
acrobat.version=x+'.0';
}
}
catch(e) {}
}

try
{
oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
if (oAcro4)
{
acrobat.installed=true;
acrobat.version='4.0';
}
}
catch(e) {}

try
{
oAcro7=new ActiveXObject('AcroPDF.PDF.1');
if (oAcro7)
{
acrobat.installed=true;
acrobat.version='7.0';
}
}
catch(e) {}

}

see http://www.oreillynet.com/cs/user/view/cs_msg/4055 for more details.

Todd Moses
Unfortunately, this does not do what I'm looking for. Adobe changed the way they label the Acrobat plugin starting with version 8, so the version information is no longer included. Using this method does not even catch version 8 or 9 because the description was changed to "Adobe PDF Plug-In For Firefox and Netscape".I know that Firefox can detect the plugin version from somewhere because it shows up when you view your installed plugins. I just don't know if that data is accessible through JavaScript because I can't find it anywhere in the DOM.
ctn8iv
+1  A: 

I still need to distinguish between versions 8 and 9 for all major browsers, but here's the code I'm currently using that works for all versions in IE, and all version up to 8 in Firefox, Safari and Chrome. It also detects whether the plugin is installed but no version info for versions 8+ in Firefox, Safari and Chrome:

var isInstalled = false;
var version = null;
var versionMessage = "";

if (window.ActiveXObject)
{
    var control = null;
    try
    {
        // AcroPDF.PDF is used by version 7 and later
        control = new ActiveXObject('AcroPDF.PDF');
    }
    catch (e)
    {
        // Do nothing
    }

    if (!control)
    {
        try
        {
            // PDF.PdfCtrl is used by version 6 and earlier
            control = new ActiveXObject('PDF.PdfCtrl');
        }
        catch (e)
        {
            // Do nothing
        }
    }

    if (control)
    {
        isInstalled = true;
        version = control.GetVersions().split(',');
        version = version[0].split('=');
        version = parseFloat(version[1]);
    }
    if (isInstalled)
    {
        if (version >= 9.0)
        {
            alert("You are using Adobe Reader "+ version +". You may continue.");
        }
        else
        {
            alert("You are using Adobe Reader "+ version +". You must download Adobe Reader 9 to continue.");
        }
    }
}
else
{
    for(var i = 0; i < navigator.plugins.length; i++)
    {
        if(navigator.plugins[i].name == "Adobe Acrobat")
        {
            isInstalled = true;

            if(navigator.plugins[i].description == "Adobe PDF Plug-In For Firefox and Netscape")
            {
                versionMessage = "You are using at least version 8 of Adobe Reader. If you cannot see any of the PDF's listed on this page, you may need to upgrade to version 9.";
            }
            else
            {
                versionMessage = "You are using a version of Adobe Reader that is not supported. You must download Adobe Reader 9 to continue.";
            }
        }
    }
    if (isInstalled)
    {
        alert(versionMessage);
    }
}
ctn8iv
A: 

I'm looking for an answer on this any new developments?

eric