Docx/Pdf/etc and WebView - android

How I can laod doc/docx/pdf and xls files into WebView?
I tried to use loadData(myBase64, "mime type for example application/pdf", "base64), I tried to use loadUrl("file///...") - no effect.
Or how I can view this files in my application? (without external programs)
...And I CAN'T to use web readers.

How I can laod doc/docx/pdf and xls files into WebView?
You don't. WebView does not have the ability to display these file types. WebView handles HTML, CSS, JS, some image formats, and the like.
Or how I can view this files in my application? (without external programs)
You spend a lot of money on libraries to do this.

Related

How to open internal storage files in webview?

I want to open files into WebView. My all files saved in internal storage. I want to keep my files private. Files type can be PDF, txt and MS-Word etc.
I have tried using Content Provider but it not works for PDF and MS-Word files.
I tried the below code for open in WebView.
String doc= "<iframe src='http://docs.google.com/viewer?url="+Uri.parse(path)+"width='100%' height='100%' style='border: none;'></iframe>";
web.loadUrl(doc);
How can I open internally stored files in webview?
I have tried using Content Provider but it not works for PDF and MS-Word files.
A ContentProvider works equally well for all MIME types.
I tried the below code for open in WebView.
That is using an undocumented, unsupported URL for displaying Web-hosted content in a Google-supplied document-rendering page. That has no ability to access files on a device.
How can I open internally stored files in webview?
For certain types of files — such as plain text, HTML, and some image formats — WebView will be able to display the content directly. Just use loadUrl() with the file URL.
For a few other types of files, you may be able to find third-party JavaScript that you can use. For example, for PDF, you could modify Mozilla's PDF.js to be able to work with local PDFs.
The only general-purpose solution is for you to learn JavaScript and write your own document-rendering code. Put that JavaScript (and related HTML/images/CSS) in your Android app, and have it open the local filesystem content using file URL values.

android webview load html from server and other files from assets

im a new android developer.
My app has WebView which loads lot of data from my site (which has pics, css, JS files).only the html code is updated weekly. other files are almost never changed. so i was thinking of including these static files in android assets, loading only the html from server and other files from assets and cutting down the loading time. how do i do it.
Android WebView Javascript from assets
and as shown in the above solution i cant change the html code to load these from assets because this site will also be accessed by web users.
Is there a way to do this. Thanks in advance..
Firstly you need to have relative paths
<img src="images/someimage.png">
not
<img src="www.mysite.com/images/someimage.png">
Then you need to load the HTML code not using webBrowser, for example like here
And then you can load HTML source into WebBrowser using base URL pointing to your assets like here

View PDF files via PDFBox-android

I need to view PDF files (just view, nothing more) on my Android application, and i've been asked to use pdfbox for android.
What is the simplest way to view PDF files via this library? i don't seem to find an example for doing that

How to load a .pdf or a .doc file in android

I want to show a pdf (preferably) or a word document in my app; like a privacy notice screen. Many applications have it, so it should be possible. i tried loading a simple text file as a start but doesn't provide formatting, fonts or trade mark symbols. I've gone through a few posts but I couldn't apply it to my app. Could anyone tell me how is it done? Could I store the file somewhere in res folder and provide a path to open it through my code? I looked into the following link but I'm not sure if that's the right approach in my case android: open a pdf from my app using the built in pdf viewer.
Android does not support opening PDF and DOC files natively. You'd have to make your own implementation.
Like t0mm13b said, you should consider using HTML (+ CSS) instead and use a WebView.

Android - epub reader to read .epub files..

I am developing and EPUB reader. I want to know some things related to other EPUB readers there in the market (like Cool reader, FBReader, Amazon Kindle and many more).
What type of view they use to show pages of .EPUB books?
Is it normal textview, webview or something custom?
How to implement search and bookmark functionality in epub reader as we loaded single html pages in webview?
I want to know how to read epub ? Is there any api in Android?
Any better solution is appreciated.
Look at Epublib – a java epub library it supports in the Android.
EPUB is simply a ZIP file containing HTML, CSS, images, and metadata.
So you can use WebView to display that HTML pages. Or possible convert it to in .png or bitmap then use in ImageView.

Categories

Resources