Intending to view a PDF File from the Hybrid Mobile App , created using HTML5 Jquery and Packaged with Phonegap.
But unable to achieve it ,
Things i tried
<object src="xyz.pdf" type="application/pdf"></object>
also,
window.open('xyz.pdf'); //through javascript
and
$(document).load('xyz.pdf');
Can anyone suggest the best way for viewing the PDF in a Hybrid Android Mobile App.
with cordova you must think about these:
HTML 5 object tag: not working
If you try with:
window.open('http://www.???.com/my.pdf', '_blank', 'location=yes');
The InAppViewer canĀ“t open this kind of files.
I think that there aren't an hybrid solution for this problem.
You must start to search or write about a plugin that use a native pdf's opening and then use it.
An example:
cordova-plugin-file-opener
The latest solution, a little more simple but include to open google docs is:
window.open('https://docs.google.com/viewer? url=http://www.example.com/test.pdf&embedded=true', '_blank', 'location=yes');
ref = window.open('index.html', '_self');
Go look at the Mozilla pdfJS project.
This project allows you to open a pdf (embedded in app or remote) in your app. No break-out links that relies on native viewers.
They also give you a very full featured sample viewer, that you can use as is, but much of functionality in that does not apply to mobile applications.
I have had success with this on Android 4.3 Devices.
Try installing the InAppBrowser plugin to do so. I have use it to open PDF files right inside the app on both iOS and Android.
Check the official InAppBrowser doc with full doc and examples, it has several options you can enable/disable (be sure to point to your current cordova version documentation):
My solution for connected apps with offline availability...
window.open('http://www.someserver.com/doc.pdf', '_system')
...this will open in default pdf viewer. I have my clients use adobe reader for obvious reasons. And also because once it is downloaded the first time, adobe app manages and edits the documents well, and the documents are also available offline from within adobe reader thereafter. Even pdf forms.
Have cordova.js linked on the page.
Have inAppBrowser added.
For full offline you may try FileOpener plugin. I have not needed to do that on android, but I have used that way in iOS.
Hope any of this may help.
Though am late here, still want to share what I know. You can use this plugin to view PDFs in the app (without inappbrowser). Supports only Android and iOS.
Related
I successfully added the inAppBrowser Plugin to my Cordova (Ionic) app, but browsing through pages in the link I cannot download files or display PDFs, even though I can in other pages of my app (not in the iAB).
I tried to debug the plugin with adb, but i could not find anything.
Anyone has a solution for this?
I have had issues with the inAppBrowser and PDF's.
The current way I am doing it is by using a document viewer plugin: https://github.com/sitewaerts/cordova-plugin-document-viewer
It isn't ideal as it uses a 2nd app to display the PDF, but it's good enough for now. My aim is to eventually develop my own solution using PDF.js
I want you to open a link in my app via browser not in Appview. I ma making my html5 mobile app via xdk. I don't want to use cordova in my app as my app is heavy enogh and don't want to make it heavier because of just one link.
I saw this :
www.kidzout.com
But the problem is I must install Cordova InAppBrowser plugin for this to work. Do you have any solution without using Cordova or external plugins? Do you think is it possible at all?
You can open a link in the native browser(Mobile Safari, Android, etc.) from within a HTML5 Mobile app using the intel.xdk API formerly AppMobi.
In the head, include a reference to the intelxdk.js file.
<script src="intelxdk.js"></script>
Use this for opening your link:
Launch in Browser
For more information, go to http://www.html5dev-software.intel.com/documentation/jsAPI/device/launchExternal/index.html
If you are opening a remote URL in your webview and adding javascript is not an option, you can make a patch in native code.
Here I show the workaround for Android:
https://stackoverflow.com/a/35037737/813951
I know about phonegap but here i am want to know if it
is possible to have an android application which is not
really an application but merely a browser that opens only
a particular webpage, that is only the mobile site i already
designed, am not sure but i have seen some android apps and i know
they do something similar , below are the things i want :
The app should be installable.
Just opens a link to an existing webpage online.i.e its more like a browser
only it just opens only a specified web page
is this possible with Phonegap for Android ?
You can do that. You would want to use the inappbrowser plugin to open an external page when ondeviceready is fired. Take a look at my SO answer here for a guide on how to use the inappbrowser, and you can take a look here for the docs about ondeviceready.
I have a dynamic HTML5 document that does not contain any external resources (no images, css and scripts are coded inside of document). This HTML5 application is working fine with internet browser. I was wondering, if it would be possible to convert this HTML5 application into standalone Android application, so it can be executed directly without browser. Please advise.
Create an Android app using Eclipse.
Create a layout that has a <WebView> control.
Move your HTML code to /assets folder.
Load webview with your file:///android_asset/ file.
And you have an android app!
Edit:
PhoneGap has now been discontinued.
Original answer:
You could use PhoneGap.
http://phonegap.com/
http://docs.phonegap.com/en/2.1.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android
This has the benefit of being a cross-platform solution. Be warned though that you may need to pay subscription fees. The simplest solution is to just embed a WebView as detailed in #Enigma's answer.
You can use https://appery.io/
It is the same phonegap but in very convinient wrapper
I use the childbrowser in my jqtouch - phonegap iPhone app and have now created it in Eclipse aswell, I have got the childbrowser to work in Android.
In the iPhone the childbrowser has a Done button and in the Android it opens a window with a address field at the top, is this how it suppose to look like - work?
When I open a .pdf or .doc document in the iPhone it opens in the childbrowser so I can read it, but in the Android it downloads the document, is this what it suppose to do?
If so, is there a way to open .pdfs so you can read it without downloading it first?
3. Is the childbrowser suppose to work in the emulator?
Thanks.
Yes, that's how it's supposed to work. The child browser is a bit non-idiomatic on the Android platform, since the Android way is generally more to open content that isn't native to the app on another app where it is (see question 2). The typical way in Android when you encounter a link is rather to open the web browser with that link, but in iOS the Child Brower UI pattern is very common. The Child Browser Android plugin also have a way of sending links to the web browser, I'd recommend you try it and consider using that instead of the Child Browser for your Android app version.
Also yes, that's also how Android generally works. Creating in-app viewers for .doc of .pdf -files would be too difficult if that's not the app's primary task.