• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

How to view PDF or Word doc on Valence Mobile

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to view PDF or Word doc on Valence Mobile

    Hello all,
    I have been working on my NAB app and on my Windows computer, everything works great and I am able to view either a word document(using office APIs, not ideal but it works) or PDF. The pdf can be viewed very easily. Things do not work as well on the mobile app. If I open a URL to the document I want, my Andriod tablet (Samsung tab 8) just downloads the file. A user would then have to do to downloads and click the file to open it.
    I would love to be able to click a button in my app, and the document opens right there in the app. I have the document stored on the IFS in the resources folder, so what can I do to get the document to display in the app? I tried so many different ways today that I'm running out of ideas. I have a datasource that is used with a form with some simple HTML that loads the documents when launched on desktop.
    For a little context, this app pulls up safety requirements for a user and then updates the completion date and time once they are done. As I said, on my desktop, works great. On my mobile app, not so great. The tablet is going to be the preferred way of doing this as my user are working on a factory floor and a computer will not be easily available.
    Thank you for the help.

  • #2
    Mobile handles pdf documents in an iframe differently than desktop unfortunately. I would suggest using our Valence.mobile.InAppBrowser to display your pdf. I am not sure about the word document "office apis"

    If you need to use this application on both desktop and mobile you can check the app variable "nabIsDesktop" to determine if you need to turn on/off features since Valence.mobile.InAppBrowser is only available on mobile.

    Example:

    The application sets the document path to an app variable then executes a script that opens the document in the mobile application. The app variable is "docPath" and was set with the value of "/resources/uploads/NitroAppList.pdf" before executing the script.

    Code:
    // Script
    //
    
    // mask the screen
    //
    Valence.common.util.Helper.loadMask();
    
    // get the base url
    //
    var url = window.location.origin ||
              window.location.protocol +
              "//" +
              window.location.hostname +
              (window.location.port ? ':' + window.location.port : '');
    
    // add the document path from an app variable "/resources/uploads/NitroAppList.pdf"
    //
    url += getAppVar('docPath');
    
    // show the document in the app browser
    //
    Valence.mobile.InAppBrowser.show({
        url: url,
        callback : function () {
            // unmask the screen
            //
            Valence.common.util.Helper.destroyLoadMask();
        }
    });
    
    success();
    Last edited by Johnny Major; 04-26-2022, 09:52 AM.

    Comment

    Working...
    X