Software Archive
Read-only legacy content

open PDF

Christopher_H_3
Beginner
783 Views

I'm a bit of a n00b when it comes to apps and all. To explain what I would like to do is add a PDF file within the app file structure, so that it will be contained within the app. Is there a way to then refer to this PDF location and open it.

I can successfully refer to the PDF on googledrive and get it to open and run, however this is going to be using mobile data limits to open each time, but some I would like to be within the app so that there is always access to these files without 3g or wi-fi signal. As well as other security implications so no need to share these online.

Is this possible, if so how do I refer to the folder structure within the app. Can PDFs be used. Its really a case of having images and text in specific way, so doing these documents as separate html would have a lot of workflow time needed, which I would like to prevent.

Can anyone help?

...Thanks!...

 

0 Kudos
5 Replies
John_H_Intel2
Employee
783 Views

You should be able to do this

           window.open('default.pdf', '_blank', 'location=yes');

However, not all devices have a built in pdf viewer in the webview. For example, Android does not, but iOS does.

 

0 Kudos
Christopher_H_3
Beginner
783 Views

Thanks for your reply John. I was along this line of code too, but I guess the lack of pdf viewer was what was causing the stump.

Is there a way to get the file to open, such as within Chrome browser as a way around this?

I have seen this line from another site, but not sure how/if this could be modified to open a pdf saved within the app in the browser to be readable?:

<a href="#" onclick="intel.xdk.device.launchExternal('http://www.intel.com');">Launch in Browser</a>

 

0 Kudos
John_H_Intel2
Employee
783 Views

You could use that line to launch the default for the file type you are opening. It will only work if you include the Intel XDK Device plugin. You can do this where you pick your plugins to be included in the app when built.

0 Kudos
Sachin_J_
Beginner
783 Views

Hello Sir,

How to open pdf file in mobile app using cordova-plugin-document-viewer plugin in HTML5 android mobile app???

 

 

 

 

0 Kudos
PaulF_IntelCorp
Employee
783 Views

http://stackoverflow.com/questions/29815812/how-to-display-pdf-file-with-in-the-same-app-in-phonegap might offer some better solutions for working with PDF files.

That plugin author does include a sample > https://github.com/sitewaerts/cordova-plugin-document-viewer-sample-app < but the instructions assume you are building with Cordova CLI installed on your machine. The instructions are bit opaque, if you want help understanding how to use that plugin you might try to contact the author directly.

0 Kudos
Reply