?
Solved

Opening a PDF Reader with Javascript and ActiveXObject

Posted on 2008-06-03
3
Medium Priority
?
11,258 Views
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;
     wb.Open(document_object.path);
    }
 
    if (extension == "txt" || extension == "doc")
    {
     var wdApp = new ActiveXObject("Word.Application");
     wdApp.Visible = 'True';
     var wdDoc = wdApp.Documents;
     wdDoc.Open(document_object.path);
    }
 
    if (extension == "pdf")
    {
     var isInstalled = false;
     var version = null;
     if (window.ActiveXObject)
     {
      var control = null;
      try
      {
       // AcroPDF.PDF is used by version 7 and later
       control_text = "AcroPDF.PDF";
       control = new ActiveXObject(control_text);
      }
      catch (e)
      {
       // Do nothing
      }
      if (!control)
      {
       try
       {
        // PDF.PdfCtrl is used by version 6 and earlier
        control_text = "PDF.PdfCtrl";
        control = new ActiveXObject(control_text);
       }
       catch (e)
       {
        return;
       }
      }
      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        **
       *********************************************/
      }
      else
      {
       alert("Could not find recent version of Adobe PDF Reader on this machine. Please install and try again");
      }
     }
    }
   }

Open in new window

0
Comment
Question by:ill_comms
  • 2
3 Comments
 
LVL 75

Expert Comment

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

xxx = new ActiveXObject('aaa.bbb')
xxx.open()

for acrobat reader
0
 

Author Comment

by:ill_comms
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?
0
 

Accepted Solution

by:
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

621 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