2

I am working on a phonegap-app. I am using the website 'build.phonegap.com' to build the apk(android) or IOS(ipa) file. The app basically uses html5, css3, jquery mobile and jquery only. I tried the code below in my config.xml file,

<plugin name="com.kernix.pdfviewer" spec="1.1.0" source="pgb" />
which i found here.

In my document.ready in js file, i have written something like,
window.open('http://www.example.com/foldername/document.pdf', '_blank');
But its not working. Am i doing anything wrong?. please help, thank you.

Ajit
  • 27
  • 3
  • Which version are you compiling with? Please add that information to your post. If you are not using a version, please ad that to your post and respond. –  Mar 30 '16 at 13:08
  • The phonegap version i am using is 3.6.3 – Ajit Mar 30 '16 at 13:15
  • Are you aware Beginning May 9, 2016, Google Play will block publishing of any new apps or updates that use pre-4.1.1 versions of Apache Cordova. [NOTES](https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/android-block-pre-4.1.1.md) –  Mar 30 '16 at 13:19
  • No..but i have an app on playstore built with same version mentioned above. Should i try updating the phonegap version?? – Ajit Mar 30 '16 at 13:22
  • Ok you mean my new app must be in the updated phonegap version. I got the point. – Ajit Mar 30 '16 at 13:25
  • Okay. I think you understand you MUST move to cli-5.1.1 or better. You will then be required to use the *whitelist* system and plugin. So I need to ask: Is this your first hybrid App? Are you using the Desktop App? Are you using [CLI, SDK or Build](https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/new-to-Phonegap.md#001) ? Please do not assume the answer, please read the link. Once you have answer the question *in the post*, respond in the comments so I know you have added information to the post. –  Mar 31 '16 at 12:38

2 Answers2

1

I tried the code below which worked for me, i got it here
window.open(encodeURI('https://docs.google.com/gview?embedded=true&url=http://www.your-server.com/files/your_file.pdf'), '_blank', 'location=yes,EnableViewPortScale=yes');

Community
  • 1
  • 1
Ajit
  • 27
  • 3
  • But i dont know if we can open a pdf file without using `https://docs.google.com/gview?embedded=true&url`. – Ajit Mar 30 '16 at 13:43
  • Now the problem with above code is, the pdf is opened with google's view and it also lets the user download the pdf. If possible, i do not want the pdf to be downloadable. – Ajit Mar 30 '16 at 14:03
0

The plugin com.kernix.pdfviewer supports only in ios, it won't work in android.

If u want to work it in ios you should use the following js code after deviceready event fired.

PDFViewer.open("file://sample.pdf","sample.pdf", function (msg) {
    console.log(msg);
});

To read the pdf files in both platforms use following plugin

https://github.com/siegfriedbolz/cordova-plugin-file-opener2/tree/dd31ffa

Hope it helps u.

Naresh Kumar
  • 938
  • 5
  • 12
  • No, its not working. I got the below code from https://build.phonegap.com/plugins/959 where i was redirected from github link you provided above ` ` – Ajit Mar 30 '16 at 10:18
  • I am actually trying to alert, in the onDeviceReady function, but i am actually not even getting the alert saying "in onDeviceReady". – Ajit Mar 30 '16 at 10:28
  • I have also added the cordova.js file in my js folder and mentioned it's path in index.html file – Ajit Mar 30 '16 at 10:28
  • are u running this in which device? means platform? – Ravi Mehta May 30 '16 at 12:04