Skip to content Skip to sidebar Skip to footer

Open Pdf Using Phone Gap

I wan't to open a pdf file on Xcode using phone gap[corodova 1.7.0]. Is it possible ? I can read text files, but for pdf should I use a plugin or something ? Thanks.

Solution 1:

Why don't you try child browser plugin to view pdf in phonegap app.

functiononDeviceReady() {

        var root = this;
        cb = window.plugins.childBrowser;

        if(cb != null) {
        cb.onLocationChange = function(loc){ root.locChanged(loc); };
        cb.onClose = function(){root.onCloseBrowser(); };
        cb.onOpenExternal = function(){root.onOpenExternal(); };
        cb.showWebPage("http://xyz.com/server/data/test.pdf");

        }
    }

    functiononCloseBrowser() {
        console.log("onCloseBrowser!");
    }

    functionlocChanged(loc) {
        console.log("locChanged!");
    }

    functiononOpenExternal() {
        alert("onOpenExternal!");
    }

Solution 2:

No need to use plugin rigth now(cordova 2.4+)

IFRAME is not a solution.

OBJECT, EMBED is not a solution.


Solution

window.open('http://example.com/any.pdf', '_blank', 'location=no');

This code will open a child browser.


Phonegap PDF Viewer plugin made for local pdf files and It fails.

Solution 3:

Solution 4:

Solution

window.open("http://docs.google.com/viewer?url=" + pdflink +" ");

This code will open the pdf in android phones

Before using this, First add phonegap.js to your HTML page

Solution 5:

for local pdf files use:

window.open('./any.pdf', '_blank', 'location=no');

Post a Comment for "Open Pdf Using Phone Gap"