3

I know this can be done in IE by creating an ActiveX object, but how do I do it in FF. The navigator.plugins['Adobe Acrobat'] object lets me know if it's installed or not, but it doesn't contain the version number. Any ideas?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Snocrash
  • 31
  • 1
  • 2
  • 5

6 Answers6

10

navigator.plugins[n].name where n is the index of the Acrobat plugin is supposed have the version number in it. Unfortunately, starting with Adobe Reader 8, they changed the name to "Adobe PDF Plug-In for Firefox and Netscape", with no version information. So, if this is the name you've detected at least Reader 8, but can't tell versions 8 from 9.

Also, make sure you take into account that Macs don't need Acrobat Reader to render PDF files. (I booted my Windows partition just to test this.)

Allen Pike
  • 6,107
  • 1
  • 19
  • 12
  • Great answer. Is this available on IE as well or is a different method needed? – Casey Watson Oct 09 '08 at 16:23
  • Good advice about the Macs, but this solution has the same problem as the SWFObject one, the description for Adobe Acrobat doesn't include a version number. – Snocrash Oct 09 '08 at 18:39
  • Regarding the IE comment, this description method can be used for other plugins on IE, but a more reliable way is to create an ActiveXObject as described here: http://www.builtfromsource.com/tag/safari/ – Snocrash Oct 09 '08 at 18:45
  • Sorry Snocrash - I didn't realize that Adobe stopped putting version numbers in there with v8. I updated the answer with more info. – Allen Pike Oct 10 '08 at 07:06
  • 1
    No system needs Acrobat Reader to render PDF files. I'm much happier with Foxit on Windows. – Quentin Apr 20 '10 at 16:20
2

It should be possible to do this like swfobject detects flash version:

SWFObject source code

Kristian J.
  • 10,273
  • 2
  • 21
  • 21
  • I would have said it if you hadn't - SWFObject is making the lives of thousands of web developers easier, one include at a time. – matt lohkamp Oct 09 '08 at 09:40
  • Good advice, I hadn't thought to look there, but unfortunately it only works because the navigator.plugins['Shockwave Flash'].description actually contains the version number. Adobe Acrobat doesn't do this, the only thing in their description is "Adobe PDF Plug-In for Firefox and Netscape". – Snocrash Oct 09 '08 at 18:36
0
var browser_info = {
    name: null,
    acrobat : null,
    acrobat_ver : null
  };


if(navigator.plugins != null)
  {      
   var acrobat = navigator.plugins['Adobe Acrobat'];
   if(acrobat == null)
   {           
    browser_info.acrobat = null;
    return browser_info;
   }
   browser_info.acrobat = "installed";
   browser_info.acrobat_ver = parseInt(acrobat.version[0]);                   
  }


where navigator is the property of Window
0
var p = document.getElementById('Pdf1');
//p.GetVersions()
if(p.GetVersions().indexOf("7.0") != -1)
    alert("Acrobat 7 Found")
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
0

This script detects the reader in all browsers - even detects Chrome's PDF Reader...

Acrobat Detection Javascript code

Ben
  • 1,203
  • 13
  • 8