Opening a PDF Reader with Javascript and ActiveXObject

Posted on 2008-06-03
Last Modified: 2013-11-18
Hi, I've been trying to get the following code to work, it accesses what kind of PDF Reader the computer has and then should load it in the appropriate reader. The start, loads word and excel documents just fine in the applications I would like PDFs to do the same. This is in IE only and runs purely on an internal intranet. Maybe there's a totally better way to do this. This is also a classic ASP website.
If someone can give me some help I would really appreciate it!

function open_document()
      var document_object = "c:\documents\userguide.pdf";
      var extension = "pdf";
    if (extension == "csv" || extension == "xls")
     var xlApp = new ActiveXObject("Excel.Application");
     xlApp.Visible = 'True';
     var wb = xlApp.Workbooks;
    if (extension == "txt" || extension == "doc")
     var wdApp = new ActiveXObject("Word.Application");
     wdApp.Visible = 'True';
     var wdDoc = wdApp.Documents;
    if (extension == "pdf")
     var isInstalled = false;
     var version = null;
     if (window.ActiveXObject)
      var control = null;
       // AcroPDF.PDF is used by version 7 and later
       control_text = "AcroPDF.PDF";
       control = new ActiveXObject(control_text);
      catch (e)
       // Do nothing
      if (!control)
        // PDF.PdfCtrl is used by version 6 and earlier
        control_text = "PDF.PdfCtrl";
        control = new ActiveXObject(control_text);
       catch (e)
      if (control)
       isInstalled = true;
       version = control.GetVersions().split(",");
       version = version[0].split("=");
       version = parseFloat(version[1]);
       ** Using the control object I would like to 
       **     load the reader and pdf here        **
       alert("Could not find recent version of Adobe PDF Reader on this machine. Please install and try again");

Open in new window

Question by:ill_comms
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21717462
I looked hard but could not find a

xxx = new ActiveXObject('aaa.bbb')

for acrobat reader

Author Comment

ID: 21747658
Hi, never tried this, would it be possible for someone to build their own activeXObject that you could use through javascript to load various programs?

Accepted Solution

ill_comms earned 0 total points
ID: 23976561
Since this particular site was internal I decided to use the shell active x control to load all my external files from the network. Also using the shell object allows the system to do the work of figuring out what programs to launch the various file type in.

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question