1

What is the best way to get the adobe reader version in Javascript.

2 Answers 2

1

I've modified the code you gave above to work with non-IE browsers.

function CheckAdobeVersion() {
    var isInstalled = false;
    var version = null;
    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) {
                return;
            }
        }
        if (control) {
            isInstalled = true;
            version = control.GetVersions().split(',');
            version = version[0].split('=');
            version = parseFloat(version[1]);
            return version;
        }
    } else {
        // Changes added in here
        var plugins = navigator.plugins;

        for(var i = 0; i < plugins.length; i++){
            if (plugins[i].name === "Adobe Acrobat"){
                version = plugins[i].version;

                if(!version) {
                    version = plugins[i].description.split('"')[1];
                }

                return parseFloat(version);
            }
        }    
    }
}

This uses the navigator.plugins property to look for Adobe Reader. It works for me with Firefox, Chrome, Safari and Opera, but I've only tested this with version 9 of Reader.

See the live version: http://jsfiddle.net/EGbY5/3/

Sign up to request clarification or add additional context in comments.

Comments

0

I have found this but it only works in Internet Explorer

 function CheckAdobeVersion() {


        var isInstalled = false;
        var version = null;
        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) {
                    return;
                }
            }
            if (control) {
                isInstalled = true;
                version = control.GetVersions().split(',');
                version = version[0].split('=');
                version = parseFloat(version[1]);
                return version;
            }
        } else {
            // Check navigator.plugins for "Adobe Acrobat" or "Adobe PDF Plug-in"*
        }
    }    

Any ideas how i could get it to work in Firefox or chrome?

Sp

1 Comment

This should be added into the original question as an edit. The obvious reason for this not working on anything that isn't IE is because it uses ActiveX, which is proprietary IE technology, so "making this work on other browser" isn't an option - you need an entirely different approach for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.