I am developing an app for android using Sencha touch and Cordova which needs to load PDF files.I found the Child browser support on PDF is not there for Android.So I decided to use PDF.js.I am using the following line of code to open the PDF file :
window.open(\''+ ROOT_FOLDER+'/app/util/PDFJS/web/viewer.html?file='+ROOT_FOLDER + '<Path to PDF file>\'
ROOT_FOLDER is the local file path URL like file://app/utils.."
But the pdf is not loading in this case and it is throwing an exception like
XMLHttpRequest cannot load file:///android_asset/www/<path to PDF file>. Cross origin requests are only supported for HTTP.
Please let me know how to fix this issue, or how to load PDF files from local location using PDF.js
If you want to load the files from local location, then it should be present in the same folder with viewer.html. In short the PDF should not be outside the main folder where all these html and js files are present.
Related
I am making one PDF reader app.
I am using android pdfViewer library
com.github.barteksc:android-pdf-viewer:2.8.2
My issue is their are some links inside my PDF pages. when user clicks on it the link should open in phone's default browser.
Note: I am not using Webview. PDFs are simply stored in assets folder and i am loading it from that folder
Is there any way to create the server in android and iOS to run a web-view? I want to run a local HTML file in a web-view with a local-host URL.
I have already searched for this on the following links but could not find any solution.
GCDWebServer
local-http-server-for-ios
Supercharging the Android WebView
Hereby i am sharing the actual scenario :
1) Download ".zip" file from server and save it on application library directory for offline use.
2) ".zip" file contents html and javascript files. It works when the HTML page is simple. But if the HTML references something else, i.e. a JavaScript file also in the library directory (with an absolute path like ), it will fail to load.
3) I need to setup local server in my device, On application launch local server starts and upload the application library directory on local server and then load the content using local host. See below example
Using Library directory path
file:////Users/prince/Library/Developer/CoreSimulator/Devices/75EF3DD7-DFD1-4EDB-9A6B-9FBA60F4D98C/data/Containers/Data/Application/32F774B2-E811-4281-A37A-DC8A5183B7C8/Library/Application%20Support/adededfe6c1c7bd8b5d5adb19861b9e0/Responses/36b8f6a8d6f58d58f117856dc80b0d37/abc.html
Using localhost path
http://localhost:8080/Application%20Support/adededfe6c1c7bd8b5d5adb19861b9e0/Responses/36b8f6a8d6f58d58f117856dc80b0d37/abc.html
Does anyone know why this happens, and how to resolve the issue?
My Application has custom webviews loading html (react based webpack build) from local assets folder. When I tried to load the webview , I see the error
"Not allowed to load local resource : file:///android_asset/index.html/#/initialize?..."
Please note : the route ("index.html/#/..") added along with the html. If I load the html only, it works fine.
My application has permission to read and write from storage.
I cannot use loadDataWithBaseURL because the 2nd parameter expects a html data.
Sorry - it was a simple issue.
When using react route - the URL should be :
file:///android_asset/index.html#/initialize?...
and not file:///android_asset/index.html/#/initialize?...
Notice the extra '/' after the .html
I'm working on a hybrid app with Cordova/phonegap using AngularJs and some plugins and trying to show an image stored in the storage directory the path is:
"file:///data/data/com.myapp/images/dot.png"
In the html page I just try to access this file with
<img src="file:///data/data/com.myapp/images/dot.png">
but it never show anything:
I checked the file with the cordova plugin file and is there!
any tips or work around for showing images from this directory?
use following plugin to open images,audio file, video and pdf files.
https://github.com/pwlin/cordova-plugin-file-opener2
I am developing an web+cross platform app using Jquery Mobile+PhoneGap+Android. In web app, I am able to open pdf file links within my app page using iframe. But, in Phonegap generated Android build, iframe is unable to render pdf content,it is showing that iframe area as empty.How can I display the pdf file/content, whose src I know at runtime, within android webview. Thanks In Advance.
I've just published my plugin, which can open almost any type of file, which is stored locally on Android device.
Please take a look at: https://github.com/markeeftb/FileOpener
Plugin opens external application which handles the preview of the document.