Tuesday, January 18, 2011

Detect the Adobe Reader Plugin

Recently I had to be able to detect the Adobe Reader Plugin in Javascript. I have included the code I used to flag if the Adobe Reader Plugin is installed, as well as get the version of the current adobe reader plugin. This code will detect:

  • Adobe Reader Plugin for Firefox
  • Adobe Reader Plugin for IE ( <5 and 5+)
  • Adobe Reader Plugin for Chrome and
  • WebKit PDF Reader for Safari
  • The PDF Reader for Chrome (Chrome's default alternative to the Adobe Reader Plugin)
  • Adobe Reader Plugin for most other browsers

To call it in javascript:

var info = getAcrobatInfo();
alert(info.browser+ " " + info.acrobat + " " + info.acrobatVersion);


Anonymous said...

Hi Ben,

Found this site today and LOVE IT. It's working for the most part but I have a question for you. I have a couple PC's, setup all the same, running XP SP3, IE 7 and Adobe Reader 9.4. Most PC's show the correct version but some show null. Any ideas?

THANK YOU for any help you can provide.

thatsgame1 said...

I forgot that I set identity to Anonymous so let me give you my email address for comment (if you have time).

I'm using this code and it is great. Seems to be working. I have several PC's I've tried this on and most of them work. We all have same settings, Windows XP SP3, Adobe Reader 9.4.1, and IE 7. A few of these PC's say null. Any advice? Thank you


Ben Kitzelman said...

Hey Andrew,
You said that it only returns null on SOME pcs with this setup, and not all.... I'm suspecting browser configuration differences? Maybe on the affected pcs the js permissions are configured differently (allowing plugin access maybe?).

Hina Haq said...

Thanks Ben,

The script is flawless and worked as a charm. I was totally confused about how to detect if a Acrobat plugin is installed. Thanks again.

DGruhin said...

Is there a way to use this code in a way that if a PDF plugin is not installed it would direct a user to install one or display a link to acrobat reader site or something?

DGruhin said...

Is there a way to use this JS in a way that will prompt a user to install a plugin or display a message and a url to where to get adobe acrobat?

Ben Kitzelman said...

for sure....
to do so you would do something like:

var browser_info = perform_acrobat_detection();

if(browser_info.acrobat == null){
document.location.href = "http://www.getacrobataddress.com/"

Rok said...

Thanks for this great code. A few comments though:

1. The version number extracted for Adobe Reader 10 is 1, due to this line:

browser_info.acrobat_ver = parseInt(acrobat.version[0])

Just replace with this and it will work:

vers = acrobat.version.split(".");
browser_info.acrobat_ver = parseInt(vers[0]);

2. Doesn't work for me in Safari & Chrome Browsers (WinXP). That's because version property doesn't exist. I discovered that description string has something like this:
Adobe PDF Plug-In For Firefox and Netscape 10.1.0
So I made this code at the end (just above of the 'return'), works for me:

// Last try for version number
if (browser_info.acrobat_ver == null){
  arDesc = browser_info.plugin_description.split(" ");
  if (arDesc.length > 0){
    browser_info.acrobat_ver = parseFloat(arDesc[arDesc.length-1]);


Raiken said...

thx a lot for that nice script, think its exactly that what i searched for.

just a question, is there a possibility to show the pdf in an iframe f.e. after the script runs true and if not to show just a download link on that same page?

Daniel Bakiaraj A said...

great, its working fine

Daniel Bakiaraj A said...

great, working fine. my googling comes to end for this issue. earlier my code was not works in Chrome. This script works in chrome too. Thanks again..

Anonymous said...

Nice job!

Anonymous said...

Thanks for sharing.
Rok, thank you for your changes too.

Anonymous said...

excellent stuff sir.
Thanks for you help

Serdar G√ľner said...

great, its working fine for me

Thanks for sharing

Anonymous said...

Thank you very much. This tool is amazingly helpful and you've made me feel a bit better about my job security :P

Anonymous said...

Muchas Gracias me sirvio muy bien el codigo...saludos desde colombia

Matthew Nichols said...


Very nice. Works great for me.

One small request; can you explicitly say what license this is under (BSD is nice and open) or at least say "Do whatever you like with it"? Without that a lot of people (me included) will not be able to use it, since without such a statement it is technically under copyright (yes I agree that is silly but apparently it is the law at least in the US).

Thanks for the post at any rate.


Edgar de Graaff said...

Great work! In Safari the name of the PDF plugin may vary on the set locale, so I made the following modification. The name seems to start with WebKit and it should contain either pdf or PDF. This was added:

var getWebKitPlugin = function() {
for (var key in navigator.plugins) {
var plugin = navigator.plugins[key];
if(plugin.name && plugin.name.substring(0,6)=="WebKit" && (plugin.name.indexOf("pdf")!=-1 || plugin.name.indexOf("PDF")!=-1)) return plugin;

and then, within getWebKitPlugin, replace getNavigatorPlugin('WebKit built-in PDF') by getWebKitPlugin()

Vijay P.V said...

how to invoke adobe reader print option in javascript..

Kiran Gopal said...


But its seem its not working with ie11 and ie10