Creating a professional changelog using an AlertDialog (on Android in Java) - java

I am new to the Android app development (in Java) and I am also new to stackoverflow, so this is my first post/question. :)
Anyway, what I want, is, to create a more or less professional changelog using an AlertDialog. I wanted to set the message of it unsing strings. Ok, this worked well. But then it looked like this:
Text Text Text Text Text Text Text Text
But I want that it looks like this:
Text Text Text Text
Text Text
Text Text Text Text Text
For this I tried to add HTML tags to the string.xml file:<string name="About"><html><head>Text Text Text</head><body><b><p>Text Text Text Text Text Text </p></b></body></html></string>
(Just trying out what possibly could work)
And this worked for me only with bold-tags and stuff but I just couldn't figure out, how I can do it that my changelog looks like about the second example.
Can you help me, pls?
I'm looking forward to your suggestions!
PS: Sorry for the bad examples but I can't add images yet! :( and Sorry for my not so good English but I hope you could understand me! ;)

Either use \n in your String for a newline. Or use the paragraph tag, but I don't know if it is recognized. Like
<p>Texttext</p><p>second line</p>

u can use HTML as source eg. on .setText(String) / .append(String) via:
String fromHtml = Html.fromHtml("<u>html code</u>"))
for new line use escape char \n or in html < br />

Related

Input the file and count the characters

I am writing a code that calculates how many words in a file
And my problem is: when I input the file, there will have more word than the original file...For example, in the file, the content is abcdabcd, but when I run the code, the console shows Total no. of letters: 194
I am using netbeans IDE and mac, when I click the blank space instead of directly open the file, I found there are many words in front of abcdabcd, I guess perhaps this is the reason... But I don't know how to fix this problem on my code
[![enter image description here][1]][1]
Can anyone help me solve this problem?
Thanks!
The input file is encoded with rtf (Rich Text Format), despite it being saved with a .txt extension. This encoding is commonly used to do many things plain text cannot do, such as bold and italic etc. However, to accomplish this, the file is filled with all sorts of other things to accompany the normal text, in your case "abcdef". Of course, java reads all of this as if it were a plain text file, and ends up counting all of the rtf formatting as well.
I assume you're using TextEdit, so look at this tutorial to see how to use only plain text, so all of the extra formatting is not included in the final file.
Hope this helped :)

Print html portion into pdf using Java

community!
My project is simple: I have a link to a website that has multiple information on different chemical substances and I want to extract some data and put in into pdf. Thing is that I want to keep the formatting of the original HTML (using it's css, of course).
Example of substance: http://www.molbase.com/en/msds_1659-31-0-moldata-2.html#tabs
I used jsoup to read the HTML of the table on the bottom of the page, the MSDS one, containing multiple sections with different information about the substance, but I really don't know how to save the exact HTML format into my pdf file. I have tried with iText too, but it gives me "missing ending tag" error, and if it worked, it would print the full page, not only that msds table.
Here is what I have tried to do, but ain't effective:
Document docu = Jsoup.connect(urlbun).get();
Element tableHeader = docu.select("div[class=\"msds\"]")
.first();
String[] finSyn = tableHeader.text().split(" ");
String moreText =" ";
I tried to split the text that the webpage has under that div ("class = "msds"") but I cannot find a way to split it the good way.
Please, could you please give me a hint on what to do? Even if the formating is not the same, I would like to be able to display the information in the same way, with indentation and such.
Thank you!
You can put the content that you want to convert to PDF inside a CSS ID (such as a DIV) and then use the PDFmyURL API to convert only that section to PDF.
Please refer to this on our website about how to select pieces from a page to convert to PDF
Disclosure: I work for the company that owns this site

Program with PDFBox searching for words

I would like to make a program that search for words in a pdf
using PDFBox.
Here is my little program:
List<String> words ;// List of words
PDDocument document = PDDocument.load("D:\\INIT.pdf");
PDFTextStripper s = new PDFTextStripper();
String content = s.getText(document);
Comparing(content,words);//methode for searching those words on my text
System.out.println(content);
But is it possible to look directly into the PDF without the text with getText?
getText returns a string .in the case we have a big text in pdf File can this String bear the same text , is there another type to use for this case when the text is big and not supported by String ????
I hope you find a solution for this within PDFBox.
The whole process is rather more difficult than it seems. For example PDF text is broken into discontinuous fragments and spaces are often represented as gaps rather than space characters. There's a need both to abstract the fragments and also to retain the link between the human-readable text and the underlying fragments within the PDF. It is quite tricky.
Anyhow if you don't find a satisfactory solution within PDFBox ABCpdf will do this for you. For example the link below shows how to find and highlight keywords in a PDF.
http://www.websupergoo.com/helppdf9net/source/8-abcpdf.operations/8-textoperation/1-methods/group.htm
I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. It's just what I know. :-)

Android text to speech reads html tags

I have a strange one, I am using text to speech in my app which works perfectly apart from the fact that it reads out some of the Html code from my formatted string.
Example:
<string name="Aggression">
<![CDATA[
<p><b>Identifying Obsessive Behaviours</b></p>
]]>
</string>
When reading out the string it ignores "< p >" and "< / p >" but reads out the bold tags!
So my question is, any ideas to stop it reading out some html tags?
P.S Im using CDATA due to the length of some of the strings used and formatting issues.
Ok so I found a pretty amazing workaround. My goal was to still display perfectly formatted html style text which was easy to maintain yet have a text-to-speech engine read out the string for accessibility.
My TextView still used this to display the html formatted text:
contentTextView.setText(Html.fromHtml(content));
My text-to-speech function now uses this which strips all of the tags and headers out and only reads the bare text:
String editedTextReadable = android.text.Html.fromHtml(content).toString();

Convert html code into plain text

I am developing android application in which i want to convert html code in to plain text and display it in the editText. I use Jsoup.jar for that but it shrink the data. Like it just remove the tag.I will not got to the next line. Does any one has the solution to display html code in the plain text? Any help or suggestions are accepted. Thank you.
Use Html.fromHtml(htmltext).

Categories

Resources