3 Replies Latest reply on Jul 10, 2014 6:42 AM by kglad

    Open PDF file locally + on web server with Javascript for all browsers

    Tom De Rouck

      Dear,

       

      I have the following code that needs to open an image (PDF file) that is located in a folder above my PDF from which it is called. My code is associated to a 3D annotation object in my PDF file.

       

      var openImage = function() {

      if((strImagePath.indexOf('http://')!==0) && (strImagePath.indexOf('https://')!==0)){

      if (strImagePath.indexOf('file://') === 0) {

      strImagePath = host.decodeURI(strImagePath);

      strImagePath = strImagePath.replace("file://", "");

      strImagePath = strImagePath.replace(":/", "/");

      strImagePath = strImagePath.replace("|/", "/");

      }

      1. host.app.openDoc(strImagePath);

                  } else {

      host.getURL(strImagePath)

      }

      };

       

      The PDF should be opened from a HTML page that is hosted on a web server, but also can be opened from the harddrive.

      This code works when the PDF file is opened from a hosted website. It also works when the PDF is opened local in Chrome, Firefox and Internet Explorer. But to make it work in Safari on OSX I need to change host.app.openDoc(strImagePath) to host.getURL(strImagePath). But then it only works local in Safari and Firefox.

      Does anyone know how I can make this work for all these webbrowsers?


      Thanks a lot for your help !

      Tom