How to Display PDF File with in the same App in phonegap

前端 未结 3 1286
滥情空心
滥情空心 2020-12-30 09:24

how to show Pdf file with in the same phonegap app. i tried Inappbrowser,Mupdf,PDFJS all are displaying PDF using other pdf viewer.i would like to open the pdf file with in

3条回答
  •  轮回少年
    2020-12-30 09:37

    for cordova, sachinM's answer is perfect - but with an extensions Use uriEncodeComponent(link) and https://docs.google.com/viewer?url= link

    Doc, Excel, Powerpoint and pdf all supported.

    Use the cordova in app browser.

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        window.open = cordova.InAppBrowser.open;
            }
    
                $("body").on("click",function(e){
               var clicked = $(e.target);
             if(clicked.is('a, a *'))
           {
                 clicked = clicked.closest("a");
                 var link = clicked.attr("href");
                if(link.indexOf("https://") !== -1)
               {
                   if(true) //use to be able to determine browser from app
                     {
                        link = "http://docs.google.com/viewer?url=" +  encodeURIComponent(link) + "&embedded=true";
                 }
    
                     window.open(link, "_blank", "location=no,toolbar=no,hardwareback=yes");
                    return false;
                }
        }
        });
    

提交回复
热议问题