-1

I have developed an application using HTML 5. To make the application compatible with the mobile devices I have used cordova/phonegap.

Now the problem is that, the PDf files which is there inside the application is only getting downloaded, when clicked on the link. I need to get it opened in the browser, when clicked on the link. It works fine with the PC. But not with the mobile devices.

I stored the link to a variable and passed that variable to google. Now using some sort of services from google, the link is getting opened in the browser.

I tried installing inAppbrowser plugin also.

window.open(Furl, '_system', 'location=yes'); This was the line of code used, where Furl is the name of the variable, into which, the url address of the pdf file is passed.

This line of code works fine, when url address of a webpage is passed to the variable. But not with the pdf files.

Apart from that idea, is there any other solution for this problem?

Can someone help me out with this problem?

-Thank you

  • It works fine on PC because modern PC browsers know how to render a pdf file. If a browser does not know this... you will have to create this functionality by using pdf.js. But for android brwoser... I am not sure if you should... because it will cause freezing on some budget phones. – sarveshseri Feb 04 '15 at 10:48
  • Thank you Sarvesh, but it is not working – Priyanka Prakash Feb 04 '15 at 11:00

1 Answers1

0

As stated already on a comment, it is possible on modern browser since they have in-built PDF viewer. This isn't the case for Android or iOS currently. What you could do is to convert the PDF to PNG image and then show that. There is a PDF2PNG plugin available for this purpose. Also, if you only need to support iOS 6 & 7, you can take a look at the PDF Viewer plugin.

Roope Hakulinen
  • 7,326
  • 4
  • 43
  • 66