I have a PhoneGap app for Android which I am trying to run in the Android emulator. The app has a simple html page which has a button. On click, the button calls a RESTful webservice using javascript XMLHttpRequest and the service returns back base 64 encoded data for a pdf. Then from the javascript function, I try to load the pdf data in my html page in the app as below
document.location.href = 'data:application/pdf;base64,' + pdfData.childNodes[0].data;
But this does nothing. The data is returned correctly and I checked the logs for it. But the pdf is not displayed at all. Any idea what is causing the issue?
In Android you not show pdf file in Webview. Have some solution to view pdf file in Android:
Use google pdf view
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo_pdfFile);
Download pdf file and view by pdf reader in device. Check this
(My solution) I parse pdf file to image and store onto server and i only download and view image directly.(It have bit complex, but you can view pdf, docx, xls,..). Example here
Related
I have the webpage created with angular js file. There are pdf files inside the webpage we want to download and show.
when clicking the pdf file, it just show loading and nth happened. Also shouldOverrideUrlLoading method is never called. This method is not deprecated.
We tried to load the url in external browser and open the pdf, it successfully download and open the pdf file.
I would like to know is there any webview setting I missed out?
current webview settings in my implementation is as below . Kindly help. thank you
webView?.settings?.builtInZoomControls = true
webView?.settings?.domStorageEnabled = true
webView?.settings?.allowFileAccess = true
webView?.settings?.allowContentAccess = true
You should try this one might be it work by WebViewClient.
Check out this -- https://stackoverflow.com/a/14201778/18858169
PDF is a file format NOT handled by WebView, it's designed to show web content, not some documents
if you really want to show PDF inside WebView then you should use some web application, which can take a PDF file (or URL pointing on some) and render content of your file in a "web way", thus WebView could print it
for example Google have such web app and you can open PDFs in it using some of below URLs (these may changed)
https://docs.google.com/viewer?url=http://customdomain.com/pdffile.pdf
https://docs.google.com/gview?embedded=true&url=http://customdomain.com/pdffile.pdf
https://drive.google.com/viewerng/viewer?embedded=true&url=http://customdomain.com/pdffile.pdf
note that you are basing on 3rd-party service - your PDF may be online, but 3rd-party companys server-side may be down or changed routing and your hardcoded URL prefix stop working
and if you want to show "real" PDF then use PdfRenderer class, which will give you a set of Bitmaps, which can be shown with ImageView, no WebView needed
I'm using Xamarin Forms with Android, I need to open a PDF from an URL in my WebView. For some reason, sometime the the Webview is blank. I've searched a lot on Internet and I found some solution that give me the same result, sometime the PDF in the PDF is showed without problem, sometime is a blank page. I'm using "https://drive.google.com/viewerng/viewer?embedded=true&url=" with no results, I'm using this solution ( https://acaliaro.wordpress.com/2017/11/30/open-a-pdf-inside-a-webview-in-xamarin-forms-android/ ) that describe exactly my problem but WebView still show me a blank page sometime.
So, why is so hard to open a PDF Url on Android in a WebView? There is some solution to fix this problem? I don't know what can i else do.
Android WebView not support .pdf file from website, infact, if you try to copy an url with .pdf extension in chrome browser, this will download the file and open in an app. So there is no way to show a PDF in an App in a simple way. But there are two solution:
On Google there are a lot solutions that tells you to download the PDF and show in an webview, but in my case I can't download a PDF and show.
You can write an .html page in your Server that can "wrap" the PDF sended with an URL in GET mode and show it in an .html page without problem ( using jsPDF is an example ) or by using this prefix ( http://drive.google.com/viewerng/viewer?embedded=true&url= ) but sometime i give a blank page, so i write my own pdf viewer. In this link ( https://acaliaro.wordpress.com/2017/11/30/open-a-pdf-inside-a-webview-in-xamarin-forms-android/ ) you can find another solution, but for some reason, it still doesn't works. Maybe because I'm on Android 5.0 device.
I am trying to display a PDF in an Android application.
Constraints are: PDF cannot be downloaded to the mobile phone. Server through which PDF is getting downloaded is on Local network.
I can work on any option: getting the PDF to display on webview (more preferable) or getting the PDF to display using native technique.
Also if any solution involves converting the PDF to HTML and then displaying it will also be acceptable.
you can use third party library for this
https://github.com/voghDev/PdfViewPager
it works for me
Hey I'm struggling to get a tiff image downloaded from an FTP site to display in a WebView. After entering in the url in the format imageView.loadUrl("ftp://username:password#ftpsite/path");
(and the url is able to successfully download an image in ie or chrome)
I get an error message saying net::ERROR_UNKNOWN_URL_SCHEME. Does FTP not work in WebView? What else could the problem be?
(I later tried just downloading from the ftp site to the app but the image is .tiff and that opened up a whole new can of worms so I'm back to trying to use WebView instead of ImageView)
Edit: updated url with the path I actually use, I sloppily typed it in before :/
I am new for android server side..i want to store html page and images in xampp server and retrive it and show it in android app.
Your question is unclear.
for loading a HTML saved document, you must use WebView .
WebView can load html file saved in your assets file of your android application or from special URL like http://google.com
i did'nt know more about your question about xampp!
i think saving html pages in Xampp automatically is another discuss .