How to convert html text to Plain Text in report - java

I am passing HTML text as parameter value in java. like
parameter.put("TEMP_TEXT","<p>test</P>");
I have bound this parameter in ireport as static text field like $P{TEMP_TEXT} then it will be converted in plain text.
output ought to be 'test'
Which setting need to be added on staticText in iReport for acquire same?

Add a Text Field to your report.
Text Field Expression : $P{TEMP_TEXT}
Markup : html

Related

Couldn't get text from a text field using selenium

I am trying to get value from a text field using selenium, but I am not able to. The value is neither present between the tags nor in the attribute "value".Please help me with this.
I have tried following ways but nothing worked.
Webelement.getAttribute("innerText");
Webelement.gettext();
Webelement.getAttribute("value");
Webelement.getAttribute("textcontent");
Below is the HTML for the text field.
<input name="quantityField_valueFieldKeyboard" id="quantityField_valueFieldKeyboard" data-mini="true" data-clear-btn="false" maxlength="61" seyctype="numeric" class="seyc-visually-important seyc-ui-input-icon-white seyc-ui-input-text">
is this what you are trying?
driver.findElement(By.id("quantityField_valueFieldKeyboard")).getAttribute("value");
driver.findElement(By.id("quantityField_valueFieldKeyboard")).getAttribute("value");
is correct way. You are getting empty string is also correct because your text field has no data in it. Since this is an input field, first enter some text and once text is saved. Try to fetch the entered text you will get your desired results.

How to Render HTML content from Database in Jasper 1.3

I am using ireport version 1.3.0. I have a description field in database. This field contains some html tags. How to render the html content in Jasper PDF report?
I tried with markup, I got an error markup attribute not found.
Notes fields in EA are not really HTML. They use HTML like tags to do store formatted text.
The easiest way to translate the internal format to something standard such as HTML, RTF or plain text, is to use the API method GetFormatFromField (string Format, string Text)
String
Notes: After accessing a field that contains formatting, use this
method to convert it to your preferred format; returns the field in
the format specified.
Parameters:
Format: String - The format to convert the field to; valid formats
are:
- HTML - Full HTML
- RTF - Rich Text Format
- TXT - Plain text
Text: String - The field to be converted

converting HTML to String without TextView

I am having Problems filling my TextView.
I have an HTML String that needs to be converted from HTML to String and the replace some characters.
Problem is: I can convert it directly with:
TextView.setText(Html.fromHtml(sampleText);
But I need to alter the converted sampleText before giving it to the TextView.
E.g.:
String sampleText = "<b>Some Text</b>"
newSampleText = Html.fromHtml(sampleText);
newSampleText.replace(char1, char2);
TextView.setText(newSampletext);
Does anyone know how to convert the HTML saved inside the String?
if you don't need formatting, use Html.fromHtml(sampleText).toString()
otherwise, you need to extract text from html with jsoup to find and change text like here
please try this one:
You need to use Html.fromHtml() to use HTML in your XML Strings. Simply referencing a String with HTML in your layout XML will not work.
DEMO
Try use This version of setText and use SPANNABLE buffer type
DEMO1

using JSF PrimeFaces' text editor, how to add text in PDF using iText

We are using JSF PrimeFaces' text editor. When we receive String from text editor in backing bean, it also includes HTML tags. Following image might help in understanding this problem.
Following is what we wrote:
Following is what we received:
Next thing we want to do is, to write what was written in text editor, as it is, into PDF using iText. But we do not know how to convert this string (with HTML tags) into only data.
Following was the code:
You can go for XMLWorker in iText. Below code will give you the content in Orange color
document.open();
String finall= "<style>h1{color:orange;} </style><body><h1>This is a Demo</h1></body>";
InputStream is = new ByteArrayInputStream(finall.getBytes());
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter,document, is);
document.close();
Whatever HTML content we are giving it will create it as PDF. The only thing to take care is it will work for XHTML means all the opening tags should have a end tag.
For example in HTML for break we will use <br> but here it should be <br/>Hope this will help you.
Use JSoup to achieve this. Jsoup
Then in your code
Jsoup.parse(textRecievedFromEditor).text();
This will return text without HTML Tags.
e.g.
For example, given HTML {#code <p>Hello <b>there</b> now!</p>},
{#code p.text()} returns {#code "Hello there now!"}

displaying a XML file in JEditorPane

I want to display a regular XML or any other file in text format in JEditorPane..I don't want to display the content in html page... the content should be exactly the same as in file with line break..the XML file is located on local system
Do you need syntax highlighting?
or just show plain text?
If syntax try to use this
http://java-sl.com/xml_editor_kit.html
If not just use JTextArea or normal JEditorPane with default editor kit. And call setText() to set your content.

Categories

Resources