How to retrieve text from webview - java

I am Having an HTML file in the asset folder. The following is the way I am loading to view the HTML content. I am having a text view. Now I want to retrieve the HTML content in the string and display that in a text view using text.settext(). Please suggest me how to retrieve the content in a string.
view.loadUrl("file:///android_asset/www/index.html");

Related

How to read the logos and image in the Email using Java where the content of Email is html/Plain text

I want validate the logo of Facebook, Instagram and other social network in the email footer where the type of email content is "text/html" .
If there are images in HTML then they must be sourced, you need to follow the source. In my view, you should write simple data scraper for plain html in email to get image source and follow that to get image. This would be worked only for html in-line images. For attachments, you need to write get file methods.

How to show JSON volley request reponse's object (in HTML) form in textView?

I have a JSON response in which object values are in HTML form. In which i have a Paragraph, a img src and video src link. How can i parse or show the image and video onto the Activity. Any help would be appreciated.
Response I'm receiving from server(only showing one object here)
{
"description":"<p>The Sarawak Ministry of Modernisation of Agriculture</p>\n
<p><video src=\"https://myurl.biz/media/media/Nokia_X3_sample_video.3gp.3gp\" autoplay=\"autoplay\" controls=\"controls\" width=\"300\" height=\"150\">
<span id=\"mce_marker\" data-mce-type=\"bookmark\">â</span></video>
</p>\n<p><img src=\"https://myurl.biz/media/media/bird_SJhLHPo.jpg\" width=\"547\" height=\"264\" /></p>"
}
I have tried :
txtDetails.setText( Html.fromHtml(extras.getString("details"));
Actual Result I'm receiving in my text view:
The Sarawak Ministry of Modernisation of Agriculture,
​
What you're trying to do is impossible. You can't display an image/video in a TextView (this is not a browser). First, you need to parse the HTML. Then, once you have the components you can plug them in separate views. For example,
You parse the HTML (there are a lot of frameworks for that)
Get the image URL link and use Picasso (popular framework for displaying images from URLs) to display it on your Activity.
Get the paragraph and display it in a TextView
etc..

Android Java generate PDF file from webview with separate header and footer

I was having some problem when trying to include header and footer in multiple pages of pdf file when trying to convert from webview into pdf. Here is how I formed the content to be displayed in webview:
public String toHtml() {
StringBuilder htmlStr = new StringBuilder("");
htmlStr.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html\"; charset=utf-8>");
htmlStr.append("<title>").append("").append("</title>");
htmlStr.append("</head>\n");
htmlStr.append("<body>").append("").append("</body>");
htmlStr.append("<footer>").append("").append("</footer>");
htmlStr.append("</html>");
return htmlStr.toString();
}
And I followed this guide to generate PDF from webview. It did managed to generate the PDF file. However, the header only appeared in the first page and the footer only appeared in the last page of PDF file. Any ideas how to include the header and footer across all pages in the PDF file?
Thanks!
I had the same problem.
My working solution:
Generate Pdf from Webview
Save this Pdf
Reopen the Pdf with PdfBox GitHub - TomRoush/PdfBox
Add Header and Footer (with addCenterText) PdfBox - How to Center...
Save the extended Version

JavaFX HTML Editor display raw HTML code on the editor

I was wondering if there's a way to load an HTML file on JavaFx's HTMLEditor but rather then loading it as a web page, show the actual raw source code on the HTMLEditor. Is this possible with JavaFX's HTMLEditor?
I tried the following:
File f = fc.showOpenDialog(null); //This allows a user to find a file in a dialog
String textRead = readFile(f); //store the files content in a string
htmlFileEditor.setHtmlText(textRead); //displays the source but not as raw HTML
This only loads the html file and displays it, Im wondering if there is a way to show the raw source code of the HTML file loaded with tags and all on the HTMLEditor.

How to render image within an html dynamically?

I am having some html content with images(html+images) embedded inside it on my local drive. When i open it by double clicking on browser directly, i am able to see the content with embedded images in it.
Now i have to render this content on web browser using java apis.I am able to render html content without any issue but while rendering , image is not getting rendered , instead alt text is getting rendered on browser.
I got to know that i can not set two mime types in java code to render image as well as text on same page.I want to know how can i render html content with image inside it so that it can be rendered.
Regards.
Code added:
public void readFile() throws FileNotFoundException{
String lsFilePath = "D:\\alf3.3\\deployment\\target\\";
//String lsFilename = "/WEB-INF/message.properties";
String lsFilename = "spcontent2.html";
File loNewFile = new File(lsFilePath + lsFilename);
FileInputStream loFileInputStream = new FileInputStream(loNewFile);
FileOutputStream loFilOutputStream = new FileOutputStream(loNewFile);
}
It is fine till now but i need to know how can i render an image that is referred to in file mentioned.
For embedding an Image into html source page by adding content id into image source. This is usually practised while sending HTML emails with embedded images
Please refer following document for more info.
http://www.faqs.org/rfcs/rfc2111.html

Categories

Resources