How to open external pdf url in app

  1. Install this plugin https://github.com/apache/cordova-plugin-inappbrowser/blob/8ce6b497fa803936784629187e9c66ebaddfbe1b/doc/index.md

  2. Function to open link inside inAppBrowser. This can be any link like html, image or pdf. In case of android we use GoogleDocs to open pdf file as by default android browser does not support pdf viewing. iOS is smart enough to handle pdf itself as usual :slight_smile: .

Example :

 $scope.view_link = function (url, link_type) {
            if (ionic.Platform.isAndroid()) {
                if (link_type !== undefined && link_type !== null) {
                    if (link_type.toLowerCase() !== 'html') {
                        url = 'https://docs.google.com/viewer?url=' + encodeURIComponent(url);
                    }
                }
            }
            var ref = window.open(url, '_blank', 'location=no');
        }
9 Likes