0

I have a situation where in clients system active-x checking is disabled it seems and because of security reason they cant enable it.

In my application i have to test whether client system has adobe reader installed or not. Is it possible without checking/creating new active-x object to validate for IE?

If above thing is not possible, is there any api/code available to check through JAVA?

techiepark
  • 343
  • 2
  • 7
  • 23
  • If this is not through a browser applet since it is restricted...maybe you can read Adobe Reader key values in Windows registry... may not be so foolproof against improper app installation/un-installation http://stackoverflow.com/questions/62289/read-write-to-windows-registry-using-java – eee Apr 13 '11 at 07:32
  • Do you really need to find out if Adobe Reader is installed or just to find out whether the browser can show PDF directly? – Pavel Hodek Apr 14 '11 at 09:16

3 Answers3

0

The only solution for running in browser would be to have a Java applet, with correct security ceritifcates, checking install of a PDF viewer on system.

Riduidel
  • 22,052
  • 14
  • 85
  • 185
0

If Active-X is disabled try this (using to load a small test hidden pdf document):

Script in the header:

var PDFOK = true;
function PDFLoadError() {
    PDFOK = false;
}

Then somewhere in the body:

<object height=0 width=0 type="application/pdf" data="pdf/AdobeAcrobatReaderTestFile.pdf" id=Object1 onerror="PDFLoadError()">
    <param name="src" value="AdobeAcrobatReaderTestFile.pdf">
</object>

And at the end of html document (before </body>):

if (!PDFOK) {
    // PDF reader is not installed...
}

If ActiveX is enabled use this code snippet to detect from any browser. For IE checks it using ActiveX, for other browsers using navigator.plugins.

<script type="text/javascript">
var acrobat=new Object();
acrobat.installed=false;
acrobat.version='0.0';

if (navigator.plugins && navigator.plugins.length){
  for ( var x = 0, l = navigator.plugins.length; x < l; ++x ) {
    if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1 || navigator.plugins[x].description.indexOf('PDF') != -1) {
      acrobat.version=(navigator.plugins[x].description.indexOf('PDF')!=-1)?'7+':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+';
    }
  }
  catch(e) {}
}

alert (acrobat.version);
</script>
Pavel Hodek
  • 14,319
  • 3
  • 32
  • 37
  • -1 The failing of loading a PDF document in an `object` has absolutely nothing to do whether the user Adobe Reader installed or not. – RoToRa Apr 14 '11 at 08:39
  • @RoToRa: Yes, you are right, but I think asker want to know if user browser can or can not display PDF directly - and then do some consequent actions related to it. It was only attempt to advise how it can be checked on client-side. Maybe I'm wrong. – Pavel Hodek Apr 14 '11 at 08:59
  • yeah i just wanted to validate it on client side whether browser supports pdf or not.. i will give a try to this soln..thanks – techiepark Apr 21 '11 at 10:21
  • @RoToRa: I think I provided working solution for what techiepark wanted (based on comments). So, I don't understand why I have -1, any you have 0. :( Could you please alter your rating? Thanks. – Pavel Hodek Apr 29 '12 at 19:15
0

Simply said: No it's not possible. Websites have no business knowing what software the user may or may not have installed. It would be a breach of privacy.

You'll need to take a step back, and explain, why you think you "have to" know this, then there may be alternatives, that we could suggest.

Keep in mind, that Adobe Reader isn't the only PDF reader software out there.

RoToRa
  • 37,635
  • 12
  • 69
  • 105