Android Display .Doc File in WebView? - android

In my app,I have link http://mymobilece.com/api/api_getexammaterials.php?id=28,
I want to view in webview ,I try with google document viewer its work fine But i need it without google document viewer,How to show it??

you can use the js for google Doc viever
myScript="<html><iframe src='http://docs.google.com/gview?
url='http://mymobilece.com/api/api_getexammaterials.php?
id=28'&embedded='true' style='width:600px; height:500px;'
frameborder='0'></iframe></html>"
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadData(myscript,"text/html", "UTF-8");
you can use myscript as string variable and use this javascript code(please make sure to remove double quite if above code) and load in webview
You can change the url - width- height variables according to your scripting.

Docs.google.com has a document parser , which basically parses MS-Office files , thats why you can view it on google docs. without that you will have to write document parser. Which will parse files and fetch the contents to display on view. In Short it will be not a good idea to do that. :)

Related

How can i render html with using geckoview?

I wanted to download a html file from a website first and edit that website and print that html with geckoview render engine
I know how to fetch a html and parse it but i don't know how to render it with using the renderengine
Geckoview just uses a url of a website
I don't want to use webview because i don't think it's not that good to make my own web browser app
GeckoSession has loadString(String htmlString, String mimeType) method:
GeckoSession geckoSession = ...;// here you start session in your GeckoView
geckoSession.loadString(yourHTMLString, "text/html");
geckoSession.loadData("My First Heading. My first paragraph.".getBytes(StandardCharsets.UTF_8),"text/html");
geckoSession.loadString("<!DOCTYPE html><html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>","text/html") displays blank page. Awesome!

Android open pdf file from Url and diaplay in web view?

I know this question has been asked so many time , but i didn't get any proper and satisfactory solution. I want to show the Pdf file in web view , which is coming from the url ,when i click on the URL , my pdf downloads. Currently i am usinghtml following code for showing pdf file in web view , but it is opening the html file. I am getting stuck in this since 4 hours.Kindly suggest me where i am doing wrong.
Thanks in advance.
mWebview.getSettings().setJavaScriptEnabled(true);
WebSettings settings = mWebview.getSettings();
settings.setDefaultTextEncodingName("utf-8");
mWebview.loadData(response, "application/pdf; charset=utf-8",null);
i have following response coming in following format :-
**%PDF-1.4%���5 0 obj<</E 74937/H [ 1453 173 ]/L 75330/Linearized 1/N 1/O 8/T 75180>>**
I want to show the Pdf file in web view
WebView does not have a PDF renderer.
Kindly suggest me where i am doing wrong.
You are attempting to load a PDF directly into a WebView. Use something else to render the PDF.
For show pdf in webview use Direct url:
https://docs.google.com/gview?embedded=true&url="PDF_FILE_URL"
Now load above url in webview.
mWebview.loadUrl("https://docs.google.com/gview?embedded=true&url="PDF_FILE_URL"");

How to loaded survey form dynamically in android from url?

i need to know how to load Survey Form dynamically from my web url and show it in android.
For that you have to use WebView.
in your OnCreate() method use following code
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("http://www.tutorialspoint.com");
Tutorial for implementing the complete solution : Open URL in WebView.

Read content (XML) from Android WebView

when i try to get the html source code from webview i use this example for my solution:
Extracting HTML from a WebView
now i want to parse a page which has no html content. the page displays only a text extracted from xml source.
does anybody have an idea how to get the content (or xml source code) from webview?
best regards
EXAMPLE: XML
< ID >test< /ID > <BR>
< Status >0< /Status >
Is shown as: test0 in webview
I want get the "test0" and put it to string
Option #1: Use the same approach as is shown in the linked-to blog post. Devise some JavaScript that grabs the data out of your Web page and call that JavaScript via loadUrl(), routing the results to some JavaScript interface you injected into the WebView via addJavascriptInterface().
Option #2: Don't use WebView at all, and use HttpURLConnection or HttpClient to fetch the XML source.

Android EPUBLIB read/load content

I'm playing with http://www.siegmann.nl/epublib on Android. Can someone please explain the right way to
read epub HTML content,
how to show this on Android (using WebView?),
how to split content into pages and
how to search the content.
Thx 10x.
Answers #2:
Extract epub on file system /mnt/sdcard/epub/
Loading values in webview
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.epub_reader);
webView = (WebView) findViewById(R.id.webview);
Book book = (new EpubReader()).readEpub(new FileInputStream(filename);
String baseUrl="file://mnt/sdcard/epub/OEBPS/"
String data = new String(book.getContents().get(2).getData());
webView.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
}
Regarding your questions:
How to read epub HTML content
I'm not sure what you mean. Do you want all the content? Or something specific?
All the content can be retrieved using Book.getContent().
how to show this on Android (using WebView?),
I would use WebView for this. Haven't tried that myself though.
how to split content into pages
This I don't know what would work best.
how to search the content.
The nl.siegmann.epublib.search package in epublib-tools has code for a simple search functionality.

Categories

Resources