Is posible to display html & css formatted static content in JasperReports? - jasper-reports

I want to combine dynamically generated tables with a human created content formatted in html in the same document. The ultimate target will probably be PDF. The human generated content will generally consist of formatted text, tables and images. The formatting and layout requirements are generally fairly simple. This content will be specified in html, styled with css. The content itself will static in nature in that it will not be generated from data, but it could be sourced from files or a database. Is there a way to do this?

Static text and Text field element support html syntax (you just have to chose it in properties), but you have to use in line style formatting. Something like:
<span style="color: #999">Some gray text</span><span style="color: #000"> black text</span>

Related

Sendgrid Template: How to change text color dynamically?

with Sendgrid dynamic template, I'm trying to figure out how to use dynamic data for style property so I can change text color depending on some dynamic data.
in the following example, I'm trying to use dynamic data colorHash such as #ddd for style color property. but it doesn't seem to work. so I'd appreciate it if anyone knows how to dynamically change text color in a smart way.
<p style="color: {{ colorHash }}">Ciao {{{ username }}}</p>
Contacted the sendgrid support team, they told me how to achieve what I want to do.
pass css in string as dynamic data, not just color hash you wanna use, so you can insert it into style property in a dynamic template html.
dynamic_data: {
yourCSS: `color: ${yourDynamicColor};`
}
in template html,
<span style={{ yourCSS }}>Dynamic Color Text</span>

Is wicket:label needed with wicket:for?

In the past I have built labels for my form like this:
<label wicket:for="name"><wicket:label><wicket:message key="name"></wicket:message></wicket:label>:</label><input wicket:id="name" type="text"/>
Do I still need to use the wicket:label tag? I am not using wicket:label in wicket 7 and it seems to work fine. I may not be understanding the purpose of using wicket:label. It seems like wicket:label is just additional markup. Below is what I am doing now. Is this correct?:
<label wicket:for="name"><wicket:message key="name"></wicket:message>:</label><input wicket:id="name" type="text"/>
This example is related to Wicket XHTML tags
Have a look at the JavaDoc of AutoLabelResolver and AutoLabelTextResolver.
The <label wicket:for="name"> is handled by AutoLabelResolver. It links the HTML label tag to the HTML form component (in your case the input tag) by filling in the correct ID in the HTML for attribute of the label. It also adds css classes to the label tag for for example errors, so you can style the text in the label tag in case of an error.
The <wicket:label> has two purposes. If you give it a value either by the key attribute (as you did) or by having some text between the tags, the text is set as the label model of the Java FormComponent, which then is used in validation messages like this '${label}' is required. (see LabeledWebMarkupContainer#setLabel and LabeledWebMarkupContainer#getLabel).
If you don't assign any text to the <wicket:label> tag, then it is used as output. That means the value of the label model of your Java FormComponent is used to replace the tag.
If you have no <wicket:label> in the HTML markup and no label model set in your Java code, then your Java FormComponent will have an empty label model and Wicket falls back to using the Wicket ID as label. So depending on how your Wicket IDs look, you will get validator messages like 'user_name' is required. instead of something nice looking like 'User name' is required.

Jasper Reports - How to get JRXML components with mixed styles or dynamic widths on text boxes?

When buliding jasper reports JRXML files I want to be able to have a row of dynamically width'd text boxes of mixing styles. It does not seem like Jasper supports that so I'm stuck with this:
Notice how I used two static text boxes for this display with fixed widths. This is because I cannot mix the bold + normal font styles inside a component.
I would rather something like this:
Where the NOW() and $P{name} will automatically stretch out and look real nice.
Note: I cannot use the HTML component due to this issue http://community.jaspersoft.com/questions/540569/html-component-font and https://community.jaspersoft.com/jasperreports-library/issues/4411-0
Is there a way to code JRXML files with dynamically width'd Textboxes?
Actually, you can mix styles using markup in a single text box. Jasper supports (simple) HTML, RTF and a custom jasper-styling.
Check the "markup" property.
But I am not aware that you could insert artificial borders around the values when using a single textbox.

Typo3 - wrap content coming from RTE into a div tag

I need a custom styling for different elements (ul li, ol li, tables, links etc.) that are added through Typo3 RTE.
Thus I want to configure the RTE so every time some content is added through RTE it is outputted in the front-end with a wrapping div e.g. <div class="added_through_rte"></div>.
Is there a way to do it?
Put this in yout TypoScript setup
tt_content.text.20.wrap = <div class="added_through_rte"> | </div>
This wraps all content from the field "text" of the table tt_content.
If you use RTE in other records, you will have to configure each one in a simmilar way.
On the other hand, you can define custom CSS classes for the most elements (ul, ol, links, headers, paragraphs etc.) managed by a RTE. This is a lot more configure work but more flexibel, so you can have many different list classes to chose from etc. This is quite a huge topic and lot to research.

GWT label with line breaks

GWT Label widgets iterprets everything as text, not as html tags - that's good, but I would like it to interpret \n as a <br /> how do i do that.
I would make subclass, but I cant find what to override to achieve this behaviour
(I could use HTML widget, but it would interpret all tags - and all I need is an line brak)
Use an HTML widget and set its value using a SafeHtml constructed with SafeHtmlBuilder.appendEscapedLines:
HTML label = new HTML(new SafeHtmlBuilder().appendEscapedLines("foo<bar\nbaz>quux").toSafeHtml());
(alternatively, you can split("\n", -1) your text, call SafeHtml.htmlEscape on each part and join them back with a <br>, that's what appendEscapedLines does)
Another option is to use CSS, which may be sufficient in some cases where this problem emerges.
Add the CSS attribute white-space: pre or pre-wrap in the area where you display the text. It will ensure that line breaks are respected when rendering the document.
This approach has the potential to reduce some complexity, e.g. the processing of input where \n is replaced with <br/>.
You can use com.google.gwt.user.client.ui.HTML class to achieve this or simply write,
Label label = new HTML("// html code you wnat to write");
The problem to display multi-line text with HTML in XML files is that we are not allowed to use character < in the content. For example the below code cannot be compiled:
<g:HTML HTML="Line 1<br />Line2<br />Line 3" />
In my case, I declare that text as a i18n string then use in html
<ui:with field='ln' type='com.mycompany.i18n.LocalizableStrings'/>
<g:HTML HTML="{ln.EXPLAINATION}" />