1

can some one tell me where can i find a good tutorial that explains how to download a PDFs using phone gap, Im really new with phone gap and programming and Im complety lost

user3424633
  • 51
  • 2
  • 6

2 Answers2

1

You can use the File Transfer plugin API

Here is an example from the documentation http://cordova.apache.org/docs/en/3.4.0/cordova_plugins_pluginapis.md.html#Plugin%20APIs

// !! Assumes variable fileURL contains a valid URL to a path on the device,

// for example, cdvfile://localhost/persistent/path/to/downloads/

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/download.pdf");

fileTransfer.download(
    uri,
    fileURL,
    function(entry) {
        console.log("download complete: " + entry.fullPath);
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("upload error code" + error.code);
    },
    false,
    {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
);
Nurdin
  • 23,382
  • 43
  • 130
  • 308
csantanapr
  • 5,002
  • 2
  • 19
  • 15
0

hey refer my answer to following question -

Phonegap - Save image from url into device photo gallery

You can use that code for downloading any type of file and store that in sdcard by creating new folder in your sdcard. In your case you wants to download PDF file. So you can use that code.

Community
  • 1
  • 1
Suhas Gosavi
  • 2,170
  • 19
  • 40