0
votes

I know this questions are already asked.But i couldn't find any proper answer for it.Here is my question. I tried to load pdf files for print preview in local machine using Webbrowser control.It works fine.But problem is if adobe reader is not installed webbrowser control doesn't open the file for preview.I mean say for example if Foxit reader is installed,then also the webbrowser control doesn't support.I can't access local machine registry to find installed application.Because application is installed for local users also.

 webBrowser1.Navigate("......");

Is it possible to show alert if webbrowser cant open the file with adobe reader?

1

1 Answers

0
votes

Detecting Adobe Reader

Hope this helps.

Edit:

webBrowser1.DocumentText = @"
            <html>
            <head>
                <script type='text/javascript'>
                    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) 
                            {
                              alert(e);
                              //return;
                            }
                          }
                          if (control) {
                                isInstalled = true;
                                version = control.GetVersions().split(',');
                                version = version[0].split('=');
                                version = parseFloat(version[1]);
                                alert('Adobe reader is installed. Version: ' + version);
                          }
                          else
                           {
                                alert('Adobe reader is not installed');
                           }
                    } 
                    else 
                    {
                      // Check navigator.plugins for ""Adobe Acrobat"" or ""Adobe PDF Plug-in""*
                    }

                </script>
            </head>
                <body>
                </body>
            </html>";